Skip to content

Commit

Permalink
fix: default values
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Theuermann <[email protected]>
  • Loading branch information
mati007thm committed Dec 12, 2024
1 parent 8d79b24 commit cc6dfe3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/provider/integration_email_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -246,10 +248,14 @@ func (r *integrationEmailResource) Schema(ctx context.Context, req resource.Sche
"is_default": schema.BoolAttribute{
MarkdownDescription: "Mark this recipient as default. This needs to be set if auto_create is enabled.",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"reference_url": schema.StringAttribute{
MarkdownDescription: "Reference URL for the recipient.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString(""),
},
},
},
Expand All @@ -260,13 +266,17 @@ func (r *integrationEmailResource) Schema(ctx context.Context, req resource.Sche
"auto_create": schema.BoolAttribute{
MarkdownDescription: "Auto create tickets (defaults to false).",
Optional: true,
Computed: true,
Validators: []validator.Bool{
NewAutoCreateValidator(),
},
Default: booldefault.StaticBool(false),
},
"auto_close": schema.BoolAttribute{
MarkdownDescription: "Auto close tickets (defaults to false).",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
},
}
Expand Down Expand Up @@ -364,8 +374,7 @@ func (r *integrationEmailResource) Read(ctx context.Context, req resource.ReadRe
// Read API call logic
integration, err := r.client.GetClientIntegration(ctx, data.Mrn.ValueString())
if err != nil {
resp.Diagnostics.
AddError("Client Error", fmt.Sprintf("Unable to read Email integration, got error: %s", err))
resp.State.RemoveResource(ctx)
return
}

Expand All @@ -384,7 +393,7 @@ func (r *integrationEmailResource) Read(ctx context.Context, req resource.ReadRe
Name: types.StringValue(integration.Name),
SpaceID: types.StringValue(integration.SpaceID()),
AutoCreateTickets: types.BoolValue(integration.ConfigurationOptions.EmailConfigurationOptions.AutoCreateTickets),
AutoCloseTickets: types.BoolValue(data.AutoCreateTickets.ValueBool()),
AutoCloseTickets: types.BoolValue(data.AutoCloseTickets.ValueBool()),
Recipients: &recipients,
}

Expand Down

0 comments on commit cc6dfe3

Please sign in to comment.