Skip to content

Commit 25a8198

Browse files
chore: parse *.tfvars files from templates (#68)
1 parent b768a21 commit 25a8198

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

internal/provider/template_resource.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -965,20 +965,18 @@ func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequ
965965
return nil, fmt.Errorf("failed to upload directory: %s", err)
966966
}
967967
tflog.Trace(ctx, "successfully uploaded directory")
968-
// TODO(ethanndickson): Uncomment when a released `codersdk` exports template variable parsing
969-
// tflog.Trace(ctx,"discovering and parsing vars files")
970-
// varFiles, err := codersdk.DiscoverVarsFiles(directory)
971-
// if err != nil {
972-
// return nil, fmt.Errorf("failed to discover vars files: %s", err)
973-
// }
974-
// vars, err := codersdk.ParseUserVariableValues(varFiles, "", []string{})
975-
// if err != nil {
976-
// return nil, fmt.Errorf("failed to parse user variable values: %s", err)
977-
// }
978-
// tflog.Trace(ctx,"discovered and parsed vars files", map[string]any{
979-
// "vars": vars,
980-
// })
981-
vars := make([]codersdk.VariableValue, 0, len(req.Version.TerraformVariables))
968+
tflog.Trace(ctx, "discovering and parsing vars files")
969+
varFiles, err := codersdk.DiscoverVarsFiles(directory)
970+
if err != nil {
971+
return nil, fmt.Errorf("failed to discover vars files: %s", err)
972+
}
973+
vars, err := codersdk.ParseUserVariableValues(varFiles, "", []string{})
974+
if err != nil {
975+
return nil, fmt.Errorf("failed to parse user variable values: %s", err)
976+
}
977+
tflog.Trace(ctx, "discovered and parsed vars files", map[string]any{
978+
"vars": vars,
979+
})
982980
for _, variable := range req.Version.TerraformVariables {
983981
vars = append(vars, codersdk.VariableValue{
984982
Name: variable.Name.ValueString(),

internal/provider/template_resource_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ func TestAccTemplateResource(t *testing.T) {
4848
// Auto-generated version name
4949
Directory: &exTemplateOne,
5050
Active: PtrTo(true),
51-
// TODO(ethanndickson): Remove this when we add in `*.tfvars` parsing
52-
TerraformVariables: []testAccTemplateKeyValueConfig{
53-
{
54-
Key: PtrTo("name"),
55-
Value: PtrTo("world"),
56-
},
57-
},
5851
},
5952
},
6053
ACL: testAccTemplateACLConfig{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy