@@ -43,14 +43,15 @@ type Parser interface {
43
43
// Note that this only returns the lexical values of the data source, and does not
44
44
// evaluate variables and such. To do this, see evalProvisionerTags below.
45
45
// If the provided Parser is nil, a new instance of hclparse.Parser will be used instead.
46
- func WorkspaceTags (parser Parser , module * tfconfig.Module ) (map [string ]string , error ) {
46
+ func WorkspaceTags (ctx context. Context , logger slog. Logger , parser Parser , module * tfconfig.Module ) (map [string ]string , error ) {
47
47
if parser == nil {
48
48
parser = hclparse .NewParser ()
49
49
}
50
50
tags := map [string ]string {}
51
-
51
+ var skipped [] string
52
52
for _ , dataResource := range module .DataResources {
53
53
if dataResource .Type != "coder_workspace_tags" {
54
+ skipped = append (skipped , strings .Join ([]string {"data" , dataResource .Type , dataResource .Name }, "." ))
54
55
continue
55
56
}
56
57
@@ -118,6 +119,7 @@ func WorkspaceTags(parser Parser, module *tfconfig.Module) (map[string]string, e
118
119
}
119
120
}
120
121
}
122
+ logger .Debug (ctx , "found workspace tags" , slog .F ("tags" , maps .Keys (tags )), slog .F ("skipped" , skipped ))
121
123
return tags , nil
122
124
}
123
125
@@ -145,18 +147,18 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
145
147
146
148
// This only gets us the expressions. We need to evaluate them.
147
149
// Example: var.region -> "us"
148
- tags , err = WorkspaceTags (parser , module )
150
+ tags , err = WorkspaceTags (ctx , logger , parser , module )
149
151
if err != nil {
150
152
return nil , xerrors .Errorf ("extract workspace tags: %w" , err )
151
153
}
152
154
153
155
// To evaluate the expressions, we need to load the default values for
154
156
// variables and parameters.
155
- varsDefaults , err := loadVarsDefaults (maps .Values (module .Variables ))
157
+ varsDefaults , err := loadVarsDefaults (ctx , logger , maps .Values (module .Variables ))
156
158
if err != nil {
157
159
return nil , xerrors .Errorf ("load variable defaults: %w" , err )
158
160
}
159
- paramsDefaults , err := loadParamsDefaults (parser , maps .Values (module .DataResources ))
161
+ paramsDefaults , err := loadParamsDefaults (ctx , logger , parser , maps .Values (module .DataResources ))
160
162
if err != nil {
161
163
return nil , xerrors .Errorf ("load parameter defaults: %w" , err )
162
164
}
@@ -176,8 +178,6 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
176
178
}
177
179
return nil , xerrors .Errorf ("provisioner tag %q evaluated to an empty value, please set a default value" , k )
178
180
}
179
- logger .Info (ctx , "found workspace tags" , slog .F ("tags" , evalTags ))
180
-
181
181
return evalTags , nil
182
182
}
183
183
@@ -224,7 +224,7 @@ func loadModuleFromFile(file []byte, mimetype string) (module *tfconfig.Module,
224
224
}
225
225
226
226
// loadVarsDefaults returns the default values for all variables passed to it.
227
- func loadVarsDefaults (variables []* tfconfig.Variable ) (map [string ]string , error ) {
227
+ func loadVarsDefaults (ctx context. Context , logger slog. Logger , variables []* tfconfig.Variable ) (map [string ]string , error ) {
228
228
// iterate through vars to get the default values for all
229
229
// variables.
230
230
m := make (map [string ]string )
@@ -238,18 +238,21 @@ func loadVarsDefaults(variables []*tfconfig.Variable) (map[string]string, error)
238
238
}
239
239
m [v .Name ] = strings .Trim (sv , `"` )
240
240
}
241
+ logger .Debug (ctx , "found default values for variables" , slog .F ("defaults" , m ))
241
242
return m , nil
242
243
}
243
244
244
245
// loadParamsDefaults returns the default values of all coder_parameter data sources data sources provided.
245
- func loadParamsDefaults (parser Parser , dataSources []* tfconfig.Resource ) (map [string ]string , error ) {
246
+ func loadParamsDefaults (ctx context. Context , logger slog. Logger , parser Parser , dataSources []* tfconfig.Resource ) (map [string ]string , error ) {
246
247
defaultsM := make (map [string ]string )
248
+ var skipped []string
247
249
for _ , dataResource := range dataSources {
248
250
if dataResource == nil {
249
251
continue
250
252
}
251
253
252
254
if dataResource .Type != "coder_parameter" {
255
+ skipped = append (skipped , strings .Join ([]string {"data" , dataResource .Type , dataResource .Name }, "." ))
253
256
continue
254
257
}
255
258
@@ -296,6 +299,7 @@ func loadParamsDefaults(parser Parser, dataSources []*tfconfig.Resource) (map[st
296
299
}
297
300
}
298
301
}
302
+ logger .Debug (ctx , "found default values for parameters" , slog .F ("defaults" , defaultsM ), slog .F ("skipped" , skipped ))
299
303
return defaultsM , nil
300
304
}
301
305
0 commit comments