Skip to content

Commit

Permalink
Remove default value for scalr_workspace.auto_queue_runs attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
petroprotsakh committed Feb 6, 2025
1 parent 4918ab0 commit baa428e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/provider/workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (r *workspaceResource) Create(ctx context.Context, req resource.CreateReque

opts := scalr.WorkspaceCreateOptions{
AutoApply: plan.AutoApply.ValueBoolPointer(),
AutoQueueRuns: ptr(scalr.WorkspaceAutoQueueRuns(plan.AutoQueueRuns.ValueString())),
DeletionProtectionEnabled: plan.DeletionProtectionEnabled.ValueBoolPointer(),
EnvironmentType: ptr(scalr.WorkspaceEnvironmentType(plan.Type.ValueString())),
ExecutionMode: ptr(scalr.WorkspaceExecutionMode(plan.ExecutionMode.ValueString())),
Expand All @@ -86,6 +85,10 @@ func (r *workspaceResource) Create(ctx context.Context, req resource.CreateReque
},
}

if !plan.AutoQueueRuns.IsUnknown() && !plan.AutoQueueRuns.IsNull() {
opts.AutoQueueRuns = ptr(scalr.WorkspaceAutoQueueRuns(plan.AutoQueueRuns.ValueString()))
}

if !plan.TerraformVersion.IsUnknown() && !plan.TerraformVersion.IsNull() {
opts.TerraformVersion = plan.TerraformVersion.ValueStringPointer()
}
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/workspace_schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package provider

import (
"context"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"

"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"
"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"
Expand Down Expand Up @@ -149,14 +149,16 @@ func workspaceResourceSchema(ctx context.Context) *schema.Schema {
"\n * `never` - configuration versions are uploaded into the workspace, but runs will not be triggered.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString(string(scalr.AutoQueueRunsModeSkipFirst)),
Validators: []validator.String{
stringvalidator.OneOf(
string(scalr.AutoQueueRunsModeSkipFirst),
string(scalr.AutoQueueRunsModeAlways),
string(scalr.AutoQueueRunsModeNever),
),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"created_by": schema.ListAttribute{
MarkdownDescription: "Details of the user that created the workspace.",
Expand Down

0 comments on commit baa428e

Please sign in to comment.