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

Commit0f34937

Browse files
committed
parse
1 parent8507793 commit0f34937

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

‎provisioner/terraform/parse.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *server) loadWorkspaceTags(ctx context.Context, module *tfconfig.Module)
7171

7272
for_,dataResource:=rangemodule.DataResources {
7373
ifdataResource.Type!="coder_workspace_tags" {
74-
s.logger.Debug(ctx,"skip resource as it is not a coder_workspace_tags","resource_name",dataResource.Name)
74+
s.logger.Debug(ctx,"skip resource as it is not a coder_workspace_tags","resource_name",dataResource.Name,"resource_type",dataResource.Type)
7575
continue
7676
}
7777

@@ -114,6 +114,8 @@ func (s *server) loadWorkspaceTags(ctx context.Context, module *tfconfig.Module)
114114
iferr!=nil {
115115
returnnil,xerrors.Errorf("can't preview the resource file: %v",err)
116116
}
117+
key=strings.Trim(key,`"`)
118+
117119
value,err:=previewFileContent(tagItem.ValueExpr.Range())
118120
iferr!=nil {
119121
returnnil,xerrors.Errorf("can't preview the resource file: %v",err)
@@ -124,14 +126,15 @@ func (s *server) loadWorkspaceTags(ctx context.Context, module *tfconfig.Module)
124126
}
125127
}
126128
}
127-
returnworkspaceTags,nil// TODO
129+
returnworkspaceTags,nil
128130
}
129131

130132
funcpreviewFileContent(fileRange hcl.Range) (string,error) {
131133
body,err:=os.ReadFile(fileRange.Filename)
132134
iferr!=nil {
133135
return"",err
134136
}
137+
returnstring(fileRange.SliceBytes(body)),nil
135138

136139
}
137140

‎provisioner/terraform/parse_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestParse(t *testing.T) {
2323
// If ErrorContains is not empty, then the ParseComplete should have an Error containing the given string
2424
ErrorContainsstring
2525
}{
26-
/*{
26+
{
2727
Name:"single-variable",
2828
Files:map[string]string{
2929
"main.tf":`variable "A" {
@@ -200,7 +200,7 @@ func TestParse(t *testing.T) {
200200
},
201201
},
202202
},
203-
},*/
203+
},
204204
{
205205
Name:"workspace-tags",
206206
Files:map[string]string{
@@ -252,6 +252,14 @@ func TestParse(t *testing.T) {
252252
}
253253
}`,
254254
},
255+
Response:&proto.ParseComplete{
256+
WorkspaceTags:map[string]string{
257+
"cluster":`"developers"`,
258+
"os":`data.coder_parameter.os_selector.value`,
259+
"debug":`"${data.coder_parameter.feature_debug_enabled.value}+12345"`,
260+
"cache":`data.coder_parameter.feature_cache_enabled.value == "true" ? "nix-with-cache" : "no-cache"`,
261+
},
262+
},
255263
},
256264
}
257265

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp