Skip to content

Commit

Permalink
fix: check if owner groups exist before marshaling (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarbs authored Apr 3, 2024
1 parent 176fb6a commit ebce4ce
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions provider/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ func workspaceDataSource() *schema.Resource {

ownerGroupsText := os.Getenv("CODER_WORKSPACE_OWNER_GROUPS")
var ownerGroups []string
err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups)
if err != nil {
return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText)
if ownerGroupsText != "" {
err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups)
if err != nil {
return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText)
}
}
_ = rd.Set("owner_groups", ownerGroups)

Expand Down

0 comments on commit ebce4ce

Please sign in to comment.