Skip to content

Commit

Permalink
fix: warn on 'hidden' being used with conflicting fields
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleMaywood committed Sep 6, 2024
1 parent b3cbc0c commit bbe8e25
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,36 @@ func appResource() *schema.Resource {
Description: "Use this resource to define shortcuts to access applications in a workspace.",
CreateContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
resourceData.SetId(uuid.NewString())
return nil

diags := diag.Diagnostics{}

hiddenData := resourceData.Get("hidden")
if hidden, ok := hiddenData.(bool); !ok {
return diag.Errorf("hidden should be a bool")
} else if hidden {
if _, ok := resourceData.GetOk("display_name"); ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "`display_name` set when app is hidden",
})
}

if _, ok := resourceData.GetOk("icon"); ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "`icon` set when app is hidden",
})
}

if _, ok := resourceData.GetOk("order"); ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "`order` set when app is hidden",
})
}
}

return diags
},
ReadContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
return nil
Expand Down

0 comments on commit bbe8e25

Please sign in to comment.