diff --git a/preview.go b/preview.go index 3e2cd13..4ba7789 100644 --- a/preview.go +++ b/preview.go @@ -97,7 +97,9 @@ func Preview(ctx context.Context, input Input, dir fs.FS) (output *Output, diagn // moduleSource is "" for a local module p := parser.New(dir, "", parser.OptionStopOnHCLError(false), + // Obviously prevent http downloads. parser.OptionWithDownloads(false), + // Cached moules are sourced from a file on the host disk. parser.OptionWithSkipCachedModules(true), parser.OptionWithTFVarsPaths(varFiles...), parser.OptionWithEvalHook(planHook), diff --git a/preview_test.go b/preview_test.go index 0c91d36..24ae446 100644 --- a/preview_test.go +++ b/preview_test.go @@ -403,6 +403,16 @@ func Test_Extract(t *testing.T) { unknownTags: []string{}, params: map[string]assertParam{}, }, + { + name: "diskaccess", + dir: "diskaccess", + expTags: map[string]string{}, + unknownTags: []string{}, + params: map[string]assertParam{ + "file": ap(). + optVals("hello world", types.UnknownStringValue), + }, + }, } { t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/testdata/diskaccess/hello.txt b/testdata/diskaccess/hello.txt new file mode 100644 index 0000000..95d09f2 --- /dev/null +++ b/testdata/diskaccess/hello.txt @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/testdata/diskaccess/main.tf b/testdata/diskaccess/main.tf new file mode 100644 index 0000000..60828f4 --- /dev/null +++ b/testdata/diskaccess/main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + coder = { + source = "coder/coder" + version = "2.4.0-pre0" + } + } +} + + +data "coder_parameter" "file" { + name = "file" + description = "Attempt to read some files." + type = "string" + order = 1 + + option { + name = "Local" + value = file("./hello.txt") + } + + option { + name = "Outer" + value = file("../README.md") + } +}