You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(cloud): add experimental cloud init for claimable organizations - #1531
Adds cloud init, which creates an unclaimed ClickHouse Cloud organization via the unauthenticated POST /v1/claimable endpoint. The command is gated behind the experimental-claimable Cargo feature.
Part of APIS-27.
API library (clickhouse-cloud-api)
ClaimableOrganization / ClaimableOrganizationApiKey models. They are Deserialize-only, so keySecret can never be serialized by accident. ClaimableOrganizationLimits is free-form JSON.
claimable_organization_create, which sends no Authorization header (security: []).
CLAIMABLE_ORGANIZATION_CREATE operation metadata, with no required permissions.
The vendored OpenAPI snapshot gets /v1/claimable and its schemas: organizationId, apiKey and expiresAt are required, limits is optional. The Rust response fields stay Option<T>, following the all-Option response policy. The CLI checks that the required fields are present.
CLI (clickhousectl)
cloud init [--region] runs before credential resolution, so it is fully unauthenticated. --org-id/--org-name/--api-key/--api-secret are rejected.
Saves the returned API key, API URL and expires_at to the project's .clickhouse/credentials.json. The key secret never appears on stdout or stderr.
Runs once per project. A TOCTOU-safe check rejects it when API key credentials already exist (already_initialized).
New CloudErrorCodes: already_initialized, claimable_unavailable.
Subprocess + wiremock tests cover the happy path, the JSON shape, the already-initialized guard, a 503 (claimable_unavailable), and a 403 that writes no credentials.
…able_organization_create
Add models for the POST /v1/claimable unauthenticated endpoint:
- ClaimableOrganization, ClaimableOrganizationApiKey (Deserialize-only;
no Serialize so key_secret can never be accidentally serialised),
ClaimableOrganizationLimits = serde_json::Value
- claimable_organization_create client method that bypasses self.request()
and sends no Authorization header (security: [] in the spec)
- CLAIMABLE_ORGANIZATION_CREATE OperationMetadata constant (required_permissions: &[])
- Vendored OpenAPI snapshot updated with /v1/claimable path and schemas
Part of APIS-27.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Initialization can retain an existing same-API organization pin, causing subsequent commands to use newly created credentials against the wrong organization.
After cloud init followed by cloud auth login --api-key ... --api-secret ..., set_api_credentials replaces the pair and API URL but retains this expires_at. The file then associates one organization's expiry with unrelated credentials. Clear expires_at whenever ordinary login replaces the pair.
Reject empty API key credentials before saving
crates/clickhousectl/src/cloud/init.rs:115
The required-field checks accept empty keyId or keySecret strings. These are saved and init reports success, but Credentials::api_credentials explicitly rejects empty strings, so subsequent commands cannot use the new key and another init bypasses the already-initialized guard. Reject an empty pair before persisting it.
Preserve 401 auth classification for CLI exit handling
crates/clickhousectl/src/cloud/init.rs:164
A 401 is converted into a generic CloudError here, so cloud_error_to_top_level produces exit 1 instead of the CLI's required auth exit 4. Attaching an auth failure classification does not set CloudError.kind. Preserve the 401/auth distinction as the existing converter in cloud/client.rs:1342-1346 does, while keeping 403 generic.
let resolved_base_url = resolve_base_url(base_url);
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
cloud init, which creates an unclaimed ClickHouse Cloud organization via the unauthenticatedPOST /v1/claimableendpoint. The command is gated behind theexperimental-claimableCargo feature.Part of APIS-27.
API library (
clickhouse-cloud-api)ClaimableOrganization/ClaimableOrganizationApiKeymodels. They are Deserialize-only, sokeySecretcan never be serialized by accident.ClaimableOrganizationLimitsis free-form JSON.claimable_organization_create, which sends noAuthorizationheader (security: []).CLAIMABLE_ORGANIZATION_CREATEoperation metadata, with no required permissions./v1/claimableand its schemas:organizationId,apiKeyandexpiresAtare required,limitsis optional. The Rust response fields stayOption<T>, following the all-Optionresponse policy. The CLI checks that the required fields are present.CLI (
clickhousectl)cloud init [--region]runs before credential resolution, so it is fully unauthenticated.--org-id/--org-name/--api-key/--api-secretare rejected.expires_atto the project's.clickhouse/credentials.json. The key secret never appears on stdout or stderr.already_initialized).CloudErrorCodes:already_initialized,claimable_unavailable.claimable_unavailable), and a 403 that writes no credentials.