Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Queue struct {
EnqueueingLabel string `json:"enqueueingLabel"`
LabelCommandsEnabled bool `json:"labelCommandsEnabled"`
StateLabelsEnabled bool `json:"stateLabelsEnabled"`
NotReadyTimeoutHours int `json:"notReadyTimeoutHours"`

// RequiredStatuses is null when no manual override is set (uses branch protection / trunk.yaml defaults).
RequiredStatuses *[]string `json:"requiredStatuses"`
Expand Down Expand Up @@ -96,6 +97,7 @@ type UpdateQueueRequest struct {
EnqueueingLabel *string `json:"enqueueingLabel,omitempty"`
LabelCommandsEnabled *bool `json:"labelCommandsEnabled,omitempty"`
StateLabelsEnabled *bool `json:"stateLabelsEnabled,omitempty"`
NotReadyTimeoutHours *int `json:"notReadyTimeoutHours,omitempty"`
RequiredStatuses *[]string `json:"requiredStatuses,omitempty"`

// DeleteRequiredStatuses reverts required statuses to branch protection / trunk.yaml defaults
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/merge_queue_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ func (r *mergeQueueResource) Schema(_ context.Context, _ resource.SchemaRequest,
boolplanmodifier.UseStateForUnknown(),
},
},
"not_ready_timeout_hours": schema.Int64Attribute{
Description: "Hours a PR can wait to enter the queue after submission before being automatically cancelled. Set to 0 to disable.",
Optional: true,
Computed: true,
Validators: []validator.Int64{
int64validator.AtLeast(0),
},
PlanModifiers: []planmodifier.Int64{
int64planmodifier.UseStateForUnknown(),
},
},
"required_statuses": schema.ListAttribute{
Description: "Override required status checks. Set to null to revert to branch protection or trunk.yaml defaults; set to [] to explicitly require no statuses.",
Optional: true,
Expand Down Expand Up @@ -501,6 +512,7 @@ func (r *mergeQueueResource) ImportState(ctx context.Context, req resource.Impor
EnqueueingLabel: types.StringNull(),
LabelCommandsEnabled: types.BoolNull(),
StateLabelsEnabled: types.BoolNull(),
NotReadyTimeoutHours: types.Int64Null(),
RequiredStatuses: types.ListNull(types.StringType),
}

Expand Down
6 changes: 6 additions & 0 deletions internal/provider/merge_queue_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type mergeQueueResourceModel struct {
EnqueueingLabel types.String `tfsdk:"enqueueing_label"`
LabelCommandsEnabled types.Bool `tfsdk:"label_commands_enabled"`
StateLabelsEnabled types.Bool `tfsdk:"state_labels_enabled"`
NotReadyTimeoutHours types.Int64 `tfsdk:"not_ready_timeout_hours"`
RequiredStatuses types.List `tfsdk:"required_statuses"`
}

Expand Down Expand Up @@ -155,6 +156,10 @@ func (m *mergeQueueResourceModel) toUpdateRequest(config *mergeQueueResourceMode
v := m.StateLabelsEnabled.ValueBool()
req.StateLabelsEnabled = &v
}
if !config.NotReadyTimeoutHours.IsNull() {
v := int(m.NotReadyTimeoutHours.ValueInt64())
req.NotReadyTimeoutHours = &v
}

// required_statuses: null in config means revert to branch protection / trunk.yaml defaults.
if config.RequiredStatuses.IsNull() {
Expand Down Expand Up @@ -208,6 +213,7 @@ func (m *mergeQueueResourceModel) fromQueue(q *client.Queue) {
m.EnqueueingLabel = types.StringValue(q.EnqueueingLabel)
m.LabelCommandsEnabled = types.BoolValue(q.LabelCommandsEnabled)
m.StateLabelsEnabled = types.BoolValue(q.StateLabelsEnabled)
m.NotReadyTimeoutHours = types.Int64Value(int64(q.NotReadyTimeoutHours))

if q.RequiredStatuses != nil {
elems := make([]attr.Value, len(*q.RequiredStatuses))
Expand Down
Loading