Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(provisionersdk): allow.terraform.lock.hcl files to be archived#7604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coadler merged 1 commit intomainfromcolin/tflock
May 19, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletionprovisionersdk/archive.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,9 @@ func Tar(w io.Writer, directory string, limit int64) error {
if err != nil {
return err
}
if strings.HasPrefix(rel, ".") || strings.HasPrefix(filepath.Base(rel), ".") {
// We want to allow .terraform.lock.hcl files to be archived. This
// allows provider plugins to be cached.
if (strings.HasPrefix(rel, ".") || strings.HasPrefix(filepath.Base(rel), ".")) && filepath.Base(rel) != ".terraform.lock.hcl" {
if fileInfo.IsDir() && rel != "." {
// Don't archive hidden files!
return filepath.SkipDir
Expand Down
71 changes: 47 additions & 24 deletionsprovisionersdk/archive_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import (
"io"
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand DownExpand Up@@ -39,25 +40,39 @@ func TestTar(t *testing.T) {
Name string
Archives bool
}
files := []*file{{
Name: "*.tf",
Archives: true,
}, {
Name: ".*",
Archives: false,
}, {
Name: "./testing/.test/*.tf",
Archives: false,
}, {
Name: "./testing/asd.*",
Archives: true,
}, {
Name: ".terraform/.*",
Archives: false,
}, {
Name: "example/.terraform/*",
Archives: false,
}}
files := []*file{
{
Name: "*.tf",
Archives: true,
}, {
Name: ".*",
Archives: false,
}, {
Name: "./testing/.test/*.tf",
Archives: false,
}, {
Name: "./testing/asd.*",
Archives: true,
}, {
Name: ".terraform/.*",
Archives: false,
}, {
Name: "example/.terraform/*",
Archives: false,
}, {
Name: ".terraform.lock.hcl",
Archives: true,
}, {
Name: "example/.terraform.lock.hcl",
Archives: true,
}, {
Name: ".terraform/.terraform.lock.hcl",
Archives: false,
}, {
Name: "terraform.tfstate",
Archives: false,
},
}
for _, file := range files {
newDir := dir
file.Name = filepath.FromSlash(file.Name)
Expand All@@ -67,11 +82,19 @@ func TestTar(t *testing.T) {
require.NoError(t, err)
file.Name = filepath.Base(file.Name)
}
tmpFile, err := os.CreateTemp(newDir, file.Name)
require.NoError(t, err)
_ = tmpFile.Close()
file.Name, err = filepath.Rel(dir, tmpFile.Name())
require.NoError(t, err)
if strings.Contains(file.Name, "*") {
tmpFile, err := os.CreateTemp(newDir, file.Name)
require.NoError(t, err)
_ = tmpFile.Close()
file.Name, err = filepath.Rel(dir, tmpFile.Name())
require.NoError(t, err)
} else {
name := filepath.Join(newDir, file.Name)
err := os.WriteFile(name, []byte{}, 0o600)
require.NoError(t, err)
file.Name, err = filepath.Rel(dir, name)
require.NoError(t, err)
}
}
archive := new(bytes.Buffer)
err := provisionersdk.Tar(archive, dir, 1024)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp