Skip to content

Commit d4f92f1

Browse files
authored
add support for slow release channel (#327)
1 parent 394ea23 commit d4f92f1

File tree

10 files changed

+41
-36
lines changed

10 files changed

+41
-36
lines changed

.github/actions/e2e/action.yaml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,33 @@ runs:
112112
113113
echo "::endgroup::"
114114
115-
- shell: bash
116-
id: get_latest_stable_release
115+
- id: get_latest_stable_release
117116
if: ${{ inputs.upgrade_test == 'true' && steps.defined.outputs.defined == 'true' }}
118117
name: Upgrade test - Retrieve latest stable version
119-
run: |
120-
if [ "${{ inputs.upgrade_from }}" == "" ]
121-
then
122-
# Get latest stable release
123-
LATEST="$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/ClickHouse/terraform-provider-clickhouse/releases/latest | jq -r '.name')"
124-
echo "tag=$LATEST" >> "$GITHUB_OUTPUT"
125-
else
126-
echo "tag=${{ inputs.upgrade_from }}" >> "$GITHUB_OUTPUT"
127-
fi
118+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08
119+
with:
120+
timeout_minutes: 2
121+
max_attempts: 3
122+
retry_wait_seconds: 0
123+
shell: bash
124+
command: |
125+
set -eo pipefail
126+
127+
if [ "${{ inputs.upgrade_from }}" == "" ]
128+
then
129+
# Get latest stable release
130+
LATEST="$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/ClickHouse/terraform-provider-clickhouse/releases/latest | jq -r '.name')"
131+
132+
if [ "$LATEST" == "null" ]
133+
then
134+
echo "Error getting latest release"
135+
exit 1
136+
fi
137+
138+
echo "tag=$LATEST" >> "$GITHUB_OUTPUT"
139+
else
140+
echo "tag=${{ inputs.upgrade_from }}" >> "$GITHUB_OUTPUT"
141+
fi
128142
129143
- shell: bash
130144
if: ${{ inputs.upgrade_test == 'true' && steps.defined.outputs.defined == 'true' }}

docs/resources/service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "clickhouse_service" "service" {
7171
- `password_hash` (String, Sensitive) SHA256 hash of password for the default user. One of either `password` or `password_hash` must be specified.
7272
- `query_api_endpoints` (Attributes) Configuration of the query API endpoints feature. (see [below for nested schema](#nestedatt--query_api_endpoints))
7373
- `readonly` (Boolean) Indicates if this service should be read only. Only allowed for secondary services, those which share data with another service (i.e. when `warehouse_id` field is set).
74-
- `release_channel` (String) Release channel to use for this service. Either 'default' or 'fast'. Switching from 'fast' to 'default' release channel is not supported.
74+
- `release_channel` (String) Release channel to use for this service. Can be 'default', 'fast' or 'slow'.
7575
- `tier` (String) Tier of the service: 'development', 'production'. Required for organizations using the Legacy ClickHouse Cloud Tiers, must be omitted for organizations using the new ClickHouse Cloud Tiers.
7676
- `transparent_data_encryption` (Attributes) Configuration of the Transparent Data Encryption (TDE) feature. Requires an organization with the Enterprise plan. (see [below for nested schema](#nestedatt--transparent_data_encryption))
7777
- `warehouse_id` (String) Set it to the 'warehouse_id' attribute of another service to share the data with it. The service must be in the same cloud and region.

examples/full/basic/aws/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ variable "release_channel" {
2424
type = string
2525
default = "default"
2626
validation {
27-
condition = var.release_channel == "default" || var.release_channel == "fast"
28-
error_message = "Release channel can be either 'default' or 'fast'."
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
2929
}
3030
}
3131

examples/full/basic/azure/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ variable "release_channel" {
2424
type = string
2525
default = "fast"
2626
validation {
27-
condition = var.release_channel == "default" || var.release_channel == "fast"
28-
error_message = "Release channel can be either 'default' or 'fast'."
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
2929
}
3030
}
3131

examples/full/basic/gcp/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ variable "release_channel" {
2424
type = string
2525
default = "default"
2626
validation {
27-
condition = var.release_channel == "default" || var.release_channel == "fast"
28-
error_message = "Release channel can be either 'default' or 'fast'."
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
2929
}
3030
}
3131

examples/full/tde/aws/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ variable "release_channel" {
2424
type = string
2525
default = "default"
2626
validation {
27-
condition = var.release_channel == "default" || var.release_channel == "fast"
28-
error_message = "Release channel can be either 'default' or 'fast'."
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
2929
}
3030
}
3131

examples/full/tde/gcp/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ variable "release_channel" {
2424
type = string
2525
default = "default"
2626
validation {
27-
condition = var.release_channel == "default" || var.release_channel == "fast"
28-
error_message = "Release channel can be either 'default' or 'fast'."
27+
condition = contains(["default", "fast", "slow"], var.release_channel)
28+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
2929
}
3030
}
3131

pkg/internal/api/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const (
77

88
ReleaseChannelDefault = "default"
99
ReleaseChannelFast = "fast"
10+
ReleaseChannelSlow = "slow"
1011

1112
StateProvisioning = "provisioning"
1213
StateStopped = "stopped"

pkg/resource/service.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ func (r *ServiceResource) Schema(_ context.Context, _ resource.SchemaRequest, re
181181
},
182182
},
183183
"release_channel": schema.StringAttribute{
184-
Description: "Release channel to use for this service. Either 'default' or 'fast'. Switching from 'fast' to 'default' release channel is not supported.",
184+
Description: "Release channel to use for this service. Can be 'default', 'fast' or 'slow'.",
185185
Optional: true,
186186
Computed: true,
187187
Validators: []validator.String{
188-
stringvalidator.OneOf(api.ReleaseChannelDefault, api.ReleaseChannelFast),
188+
stringvalidator.OneOf(api.ReleaseChannelSlow, api.ReleaseChannelDefault, api.ReleaseChannelFast),
189189
},
190190
PlanModifiers: []planmodifier.String{
191191
stringplanmodifier.UseStateForUnknown(),
@@ -573,16 +573,6 @@ func (r *ServiceResource) ModifyPlan(ctx context.Context, req resource.ModifyPla
573573
)
574574
}
575575

576-
if !plan.ReleaseChannel.IsUnknown() && !plan.ReleaseChannel.IsNull() {
577-
if plan.ReleaseChannel.ValueString() == api.ReleaseChannelDefault && state.ReleaseChannel.ValueString() == api.ReleaseChannelFast {
578-
resp.Diagnostics.AddAttributeError(
579-
path.Root("release_channel"),
580-
"Invalid Update",
581-
"Switching from 'fast' to 'default' release channel is not supported",
582-
)
583-
}
584-
}
585-
586576
var isEnabled, wantEnabled bool
587577
{
588578
if !state.TransparentEncryptionData.IsNull() {

tests/import/service/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ variable "release_channel" {
2626
type = string
2727
default = "default"
2828
validation {
29-
condition = var.release_channel == "default" || var.release_channel == "fast"
30-
error_message = "Release channel can be either 'default' or 'fast'."
29+
condition = contains(["default", "fast", "slow"], var.release_channel)
30+
error_message = "Release channel can be 'default', 'fast' or 'slow'."
3131
}
3232
}
3333

0 commit comments

Comments
 (0)