Skip to content

Commit fd88b11

Browse files
committed
chore: push all owner context fields into eval context
1 parent b379cc5 commit fd88b11

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

owner.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ func workspaceOwnerHook(dfs fs.FS, input Input) (func(ctx *tfcontext.Context, bl
1414
if input.Owner.Groups == nil {
1515
input.Owner.Groups = []string{}
1616
}
17-
ownerGroups, err := gocty.ToCtyValue(input.Owner.Groups, cty.List(cty.String))
17+
18+
ownerType, err := gocty.ImpliedType(input.Owner)
1819
if err != nil {
19-
return nil, xerrors.Errorf("converting owner groups: %w", err)
20+
return nil, xerrors.Errorf("getting owner cty type: %w", err)
2021
}
2122

22-
ownerValue := cty.ObjectVal(map[string]cty.Value{
23-
"groups": ownerGroups,
24-
})
23+
ownerValues, err := gocty.ToCtyValue(input.Owner, ownerType)
24+
if err != nil {
25+
return nil, xerrors.Errorf("converting owner context to cty: %w", err)
26+
}
2527

2628
return func(ctx *tfcontext.Context, blocks terraform.Blocks, inputVars map[string]cty.Value) {
2729
for _, block := range blocks.OfType("data") {
2830
// TODO: Does it have to be me?
2931
if block.TypeLabel() == "coder_workspace_owner" && block.NameLabel() == "me" {
30-
block.Context().Parent().Set(ownerValue,
32+
block.Context().Parent().Set(ownerValues,
3133
"data", block.TypeLabel(), block.NameLabel())
3234
}
3335
}

0 commit comments

Comments
 (0)