@@ -33,12 +33,11 @@ const maxFileSizeBytes = 10 * (10 << 20) // 10 MB
33
33
// WorkspaceTags extracts tags from coder_workspace_tags data sources defined in module.
34
34
// Note that this only returns the lexical values of the data source, and does not
35
35
// evaluate variables and such. To do this, see evalProvisionerTags below.
36
- func WorkspaceTags (ctx context.Context , logger slog. Logger , module * tfconfig.Module ) (map [string ]string , error ) {
36
+ func WorkspaceTags (ctx context.Context , module * tfconfig.Module ) (map [string ]string , error ) {
37
37
workspaceTags := map [string ]string {}
38
38
39
39
for _ , dataResource := range module .DataResources {
40
40
if dataResource .Type != "coder_workspace_tags" {
41
- logger .Debug (ctx , "skip resource as it is not a coder_workspace_tags" , "resource_name" , dataResource .Name , "resource_type" , dataResource .Type )
42
41
continue
43
42
}
44
43
@@ -47,7 +46,6 @@ func WorkspaceTags(ctx context.Context, logger slog.Logger, module *tfconfig.Mod
47
46
parser := hclparse .NewParser ()
48
47
49
48
if ! strings .HasSuffix (dataResource .Pos .Filename , ".tf" ) {
50
- logger .Debug (ctx , "only .tf files can be parsed" , "filename" , dataResource .Pos .Filename )
51
49
continue
52
50
}
53
51
// We know in which HCL file is the data resource defined.
@@ -101,8 +99,6 @@ func WorkspaceTags(ctx context.Context, logger slog.Logger, module *tfconfig.Mod
101
99
return nil , xerrors .Errorf ("can't preview the resource file: %v" , err )
102
100
}
103
101
104
- logger .Info (ctx , "workspace tag found" , "key" , key , "value" , value )
105
-
106
102
if _ , ok := workspaceTags [key ]; ok {
107
103
return nil , xerrors .Errorf (`workspace tag %q is defined multiple times` , key )
108
104
}
@@ -135,14 +131,14 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
135
131
136
132
// This only gets us the expressions. We need to evaluate them.
137
133
// Example: var.region -> "us"
138
- tags , err = WorkspaceTags (ctx , logger , module )
134
+ tags , err = WorkspaceTags (ctx , module )
139
135
if err != nil {
140
136
return nil , xerrors .Errorf ("extract workspace tags: %w" , err )
141
137
}
142
138
143
- // To evalute the expressions, we need to load the default values for
139
+ // To evaluate the expressions, we need to load the default values for
144
140
// variables and parameters.
145
- varsDefaults , paramsDefaults , err := loadDefaults (ctx , logger , module )
141
+ varsDefaults , paramsDefaults , err := loadDefaults (module )
146
142
if err != nil {
147
143
return nil , xerrors .Errorf ("load defaults: %w" , err )
148
144
}
@@ -162,6 +158,8 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
162
158
}
163
159
return nil , xerrors .Errorf ("provisioner tag %q evaluated to an empty value, please set a default value" , k )
164
160
}
161
+ logger .Info (ctx , "found workspace tags" , slog .F ("tags" , evalTags ))
162
+
165
163
return evalTags , nil
166
164
}
167
165
@@ -209,7 +207,7 @@ func loadModuleFromFile(file []byte, mimetype string) (module *tfconfig.Module,
209
207
210
208
// loadDefaults inspects the given module and returns the default values for
211
209
// all variables and coder_parameter data sources referenced there.
212
- func loadDefaults (ctx context. Context , logger slog. Logger , module * tfconfig.Module ) (varsDefaults map [string ]string , paramsDefaults map [string ]string , err error ) {
210
+ func loadDefaults (module * tfconfig.Module ) (varsDefaults map [string ]string , paramsDefaults map [string ]string , err error ) {
213
211
// iterate through module.Variables to get the default values for all
214
212
// variables.
215
213
varsDefaults = make (map [string ]string )
@@ -226,15 +224,14 @@ func loadDefaults(ctx context.Context, logger slog.Logger, module *tfconfig.Modu
226
224
paramsDefaults = make (map [string ]string )
227
225
for _ , dataResource := range module .DataResources {
228
226
if dataResource .Type != "coder_parameter" {
229
- logger . Debug ( ctx , "skip resource as it is not a coder_parameter" , "resource_name" , dataResource . Name , "resource_type" , dataResource . Type )
227
+ continue
230
228
}
231
229
232
230
var file * hcl.File
233
231
var diags hcl.Diagnostics
234
232
parser := hclparse .NewParser ()
235
233
236
234
if ! strings .HasSuffix (dataResource .Pos .Filename , ".tf" ) {
237
- logger .Debug (ctx , "only .tf files can be parsed" , "filename" , dataResource .Pos .Filename )
238
235
continue
239
236
}
240
237
0 commit comments