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

Commit9d92c3f

Browse files
committed
reduce logging
1 parentdfc658e commit9d92c3f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎provisioner/terraform/tfparse/tfextract.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ const maxFileSizeBytes = 10 * (10 << 20) // 10 MB
3333
// WorkspaceTags extracts tags from coder_workspace_tags data sources defined in module.
3434
// Note that this only returns the lexical values of the data source, and does not
3535
// evaluate variables and such. To do this, see evalProvisionerTags below.
36-
funcWorkspaceTags(ctx context.Context,logger slog.Logger,module*tfconfig.Module) (map[string]string,error) {
36+
funcWorkspaceTags(ctx context.Context,module*tfconfig.Module) (map[string]string,error) {
3737
workspaceTags:=map[string]string{}
3838

3939
for_,dataResource:=rangemodule.DataResources {
4040
ifdataResource.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)
4241
continue
4342
}
4443

@@ -47,7 +46,6 @@ func WorkspaceTags(ctx context.Context, logger slog.Logger, module *tfconfig.Mod
4746
parser:=hclparse.NewParser()
4847

4948
if!strings.HasSuffix(dataResource.Pos.Filename,".tf") {
50-
logger.Debug(ctx,"only .tf files can be parsed","filename",dataResource.Pos.Filename)
5149
continue
5250
}
5351
// 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
10199
returnnil,xerrors.Errorf("can't preview the resource file: %v",err)
102100
}
103101

104-
logger.Info(ctx,"workspace tag found","key",key,"value",value)
105-
106102
if_,ok:=workspaceTags[key];ok {
107103
returnnil,xerrors.Errorf(`workspace tag %q is defined multiple times`,key)
108104
}
@@ -135,14 +131,14 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
135131

136132
// This only gets us the expressions. We need to evaluate them.
137133
// Example: var.region -> "us"
138-
tags,err=WorkspaceTags(ctx,logger,module)
134+
tags,err=WorkspaceTags(ctx,module)
139135
iferr!=nil {
140136
returnnil,xerrors.Errorf("extract workspace tags: %w",err)
141137
}
142138

143-
// Toevalute the expressions, we need to load the default values for
139+
// Toevaluate the expressions, we need to load the default values for
144140
// variables and parameters.
145-
varsDefaults,paramsDefaults,err:=loadDefaults(ctx,logger,module)
141+
varsDefaults,paramsDefaults,err:=loadDefaults(module)
146142
iferr!=nil {
147143
returnnil,xerrors.Errorf("load defaults: %w",err)
148144
}
@@ -162,6 +158,8 @@ func WorkspaceTagDefaultsFromFile(ctx context.Context, logger slog.Logger, file
162158
}
163159
returnnil,xerrors.Errorf("provisioner tag %q evaluated to an empty value, please set a default value",k)
164160
}
161+
logger.Info(ctx,"found workspace tags",slog.F("tags",evalTags))
162+
165163
returnevalTags,nil
166164
}
167165

@@ -209,7 +207,7 @@ func loadModuleFromFile(file []byte, mimetype string) (module *tfconfig.Module,
209207

210208
// loadDefaults inspects the given module and returns the default values for
211209
// all variables and coder_parameter data sources referenced there.
212-
funcloadDefaults(ctx context.Context,logger slog.Logger,module*tfconfig.Module) (varsDefaultsmap[string]string,paramsDefaultsmap[string]string,errerror) {
210+
funcloadDefaults(module*tfconfig.Module) (varsDefaultsmap[string]string,paramsDefaultsmap[string]string,errerror) {
213211
// iterate through module.Variables to get the default values for all
214212
// variables.
215213
varsDefaults=make(map[string]string)
@@ -226,15 +224,14 @@ func loadDefaults(ctx context.Context, logger slog.Logger, module *tfconfig.Modu
226224
paramsDefaults=make(map[string]string)
227225
for_,dataResource:=rangemodule.DataResources {
228226
ifdataResource.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
230228
}
231229

232230
varfile*hcl.File
233231
vardiags hcl.Diagnostics
234232
parser:=hclparse.NewParser()
235233

236234
if!strings.HasSuffix(dataResource.Pos.Filename,".tf") {
237-
logger.Debug(ctx,"only .tf files can be parsed","filename",dataResource.Pos.Filename)
238235
continue
239236
}
240237

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp