diff --git a/owner.go b/owner.go index b3f7b56..8c3cdb4 100644 --- a/owner.go +++ b/owner.go @@ -14,20 +14,22 @@ func workspaceOwnerHook(dfs fs.FS, input Input) (func(ctx *tfcontext.Context, bl if input.Owner.Groups == nil { input.Owner.Groups = []string{} } - ownerGroups, err := gocty.ToCtyValue(input.Owner.Groups, cty.List(cty.String)) + + ownerType, err := gocty.ImpliedType(input.Owner) if err != nil { - return nil, xerrors.Errorf("converting owner groups: %w", err) + return nil, xerrors.Errorf("getting owner cty type: %w", err) } - ownerValue := cty.ObjectVal(map[string]cty.Value{ - "groups": ownerGroups, - }) + ownerValues, err := gocty.ToCtyValue(input.Owner, ownerType) + if err != nil { + return nil, xerrors.Errorf("converting owner context to cty: %w", err) + } return func(ctx *tfcontext.Context, blocks terraform.Blocks, inputVars map[string]cty.Value) { for _, block := range blocks.OfType("data") { // TODO: Does it have to be me? if block.TypeLabel() == "coder_workspace_owner" && block.NameLabel() == "me" { - block.Context().Parent().Set(ownerValue, + block.Context().Parent().Set(ownerValues, "data", block.TypeLabel(), block.NameLabel()) } }