diff --git a/docs/index.md b/docs/index.md index db221e2..4014501 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,8 +52,8 @@ provider "conduktor" { - `gateway_insecure` (Boolean) Skip TLS verification flag. May be set using environment variable `CDK_GATEWAY_INSECURE`. - `gateway_key` (String) Key in PEM format to authenticate using client certificates. May be set using environment variable `CDK_GATEWAY_KEY`. Must be used with cert. If cert is provided, key is required. Useful when Gateway is behind a reverse proxy with client certificate authentication. - `gateway_password` (String, Sensitive) The password of Gateway the admin user. May be set using environment variable `CDK_GATEWAY_PASSWORD`. Required if gateway_url is set. -- `gateway_url` (String) The URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment. -- `gateway_user` (String) The email of the Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set. +- `gateway_url` (String) The administration URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment. +- `gateway_user` (String) The login of a Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set. - `insecure` (Boolean) Skip TLS verification flag. May be set using environment variable `CDK_INSECURE`. - `key` (String) Key in PEM format to authenticate using client certificates. May be set using environment variable `CDK_KEY`. Must be used with cert. If cert is provided, key is required. Useful when Console is behind a reverse proxy with client certificate authentication. diff --git a/internal/provider/generic_resource.go b/internal/provider/generic_resource.go index bb546bb..d1a8ff8 100644 --- a/internal/provider/generic_resource.go +++ b/internal/provider/generic_resource.go @@ -56,7 +56,7 @@ func (r *GenericResource) Configure(ctx context.Context, req resource.ConfigureR if data.ConsoleClient == nil { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - "Console Client not configured. Please provide client configuration details.", + "Console Client not configured. Please provide client configuration details for Console API.", ) return } diff --git a/internal/provider/group_v2_resource.go b/internal/provider/group_v2_resource.go index 8df3c02..e8a7ebe 100644 --- a/internal/provider/group_v2_resource.go +++ b/internal/provider/group_v2_resource.go @@ -57,7 +57,7 @@ func (r *GroupV2Resource) Configure(ctx context.Context, req resource.ConfigureR if data.ConsoleClient == nil { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - "Console Client not configured. Please provide client configuration details.", + "Console Client not configured. Please provide client configuration details for Console API.", ) return } diff --git a/internal/provider/kafka_cluster_v2_resource.go b/internal/provider/kafka_cluster_v2_resource.go index 2e7ac73..bfad53c 100644 --- a/internal/provider/kafka_cluster_v2_resource.go +++ b/internal/provider/kafka_cluster_v2_resource.go @@ -56,7 +56,7 @@ func (r *KafkaClusterV2Resource) Configure(_ context.Context, req resource.Confi if data.ConsoleClient == nil { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - "Console Client not configured. Please provide client configuration details.", + "Console Client not configured. Please provide client configuration details for Console API.", ) return } diff --git a/internal/provider/kafka_connect_v2_resource.go b/internal/provider/kafka_connect_v2_resource.go index dc0c62d..9d0f74d 100644 --- a/internal/provider/kafka_connect_v2_resource.go +++ b/internal/provider/kafka_connect_v2_resource.go @@ -63,7 +63,7 @@ func (r *KafkaConnectV2Resource) Configure(_ context.Context, req resource.Confi if data.ConsoleClient == nil { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - "Console Client not configured. Please provide client configuration details.", + "Console Client not configured. Please provide client configuration details for Console API.", ) return } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 1854415..eceea40 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -67,10 +67,10 @@ func (p *ConduktorProvider) Configure(ctx context.Context, req provider.Configur cacert := schemaUtils.GetStringConfig(config.Cacert, []string{"CDK_CACERT"}) key := schemaUtils.GetStringConfig(config.Key, []string{"CDK_KEY"}) insecure := schemaUtils.GetBooleanConfig(config.Insecure, []string{"CDK_INSECURE"}, false) - gatewayCert := schemaUtils.GetStringConfig(config.Cert, []string{"CDK_GATEWAY_CERT"}) - gatewayCacert := schemaUtils.GetStringConfig(config.Cacert, []string{"CDK_GATEWAY_CACERT"}) - gatewayKey := schemaUtils.GetStringConfig(config.Key, []string{"CDK_GATEWAY_KEY"}) - gatewayInsecure := schemaUtils.GetBooleanConfig(config.Insecure, []string{"CDK_GATEWAY_INSECURE"}, false) + gatewayCert := schemaUtils.GetStringConfig(config.GatewayCert, []string{"CDK_GATEWAY_CERT"}) + gatewayCacert := schemaUtils.GetStringConfig(config.GatewayCacert, []string{"CDK_GATEWAY_CACERT"}) + gatewayKey := schemaUtils.GetStringConfig(config.GatewayKey, []string{"CDK_GATEWAY_KEY"}) + gatewayInsecure := schemaUtils.GetBooleanConfig(config.GatewayInsecure, []string{"CDK_GATEWAY_INSECURE"}, false) // Validate mandatory configurations if consoleUrl == "" && gatewayUrl == "" { @@ -101,8 +101,8 @@ func (p *ConduktorProvider) Configure(ctx context.Context, req provider.Configur if gatewayUrl != "" && (gatewayUser == "" || gatewayPassword == "") { details := "The provider cannot create the Gateway API client as there is a missing or empty value for the admin email/password. " + "Set both : " + - " - the gateway_admin_login value in the configuration or use the CDK_GATEWAY_USER environment variable. " + - " - the gateway_admin_password value in the configuration or use the CDK_GATEWAY_PASSWORD environment variable. " + + " - the gateway_user value in the configuration or use the CDK_GATEWAY_USER environment variable. " + + " - the gateway_password value in the configuration or use the CDK_GATEWAY_PASSWORD environment variable. " + "If either is already set, ensure the value is not empty." resp.Diagnostics.AddAttributeError(path.Root("gateway_user"), "Missing Gateway Admin login", details) @@ -118,16 +118,16 @@ func (p *ConduktorProvider) Configure(ctx context.Context, req provider.Configur ctx = tflog.SetField(ctx, "admin_email", adminEmail) ctx = tflog.SetField(ctx, "admin_password", adminPassword) ctx = tflog.SetField(ctx, "gateway_url", gatewayUrl) - ctx = tflog.SetField(ctx, "gateway_admin_login", gatewayUser) - ctx = tflog.SetField(ctx, "gateway_admin_password", gatewayPassword) + ctx = tflog.SetField(ctx, "gateway_user", gatewayUser) + ctx = tflog.SetField(ctx, "gateway_password", gatewayPassword) ctx = tflog.SetField(ctx, "cert", cert) ctx = tflog.SetField(ctx, "cacert", cacert) ctx = tflog.SetField(ctx, "key", key) ctx = tflog.SetField(ctx, "insecure", insecure) - ctx = tflog.SetField(ctx, "gatewayCert", gatewayCert) - ctx = tflog.SetField(ctx, "gatewayCacert", gatewayCacert) - ctx = tflog.SetField(ctx, "gatewayKey", gatewayKey) - ctx = tflog.SetField(ctx, "gatewayIsecure", gatewayInsecure) + ctx = tflog.SetField(ctx, "gateway_cert", gatewayCert) + ctx = tflog.SetField(ctx, "gateway_cacert", gatewayCacert) + ctx = tflog.SetField(ctx, "gateway_key", gatewayKey) + ctx = tflog.SetField(ctx, "gateway_insecure", gatewayInsecure) // Avoid leaking sensitive information in logs ctx = tflog.MaskFieldValuesWithFieldKeys(ctx, "api_token") ctx = tflog.MaskFieldValuesWithFieldKeys(ctx, "admin_password") @@ -187,8 +187,12 @@ func (p *ConduktorProvider) Configure(ctx context.Context, req provider.Configur resp.DataSourceData = data resp.ResourceData = data - tflog.Info(ctx, "Configured Conduktor Console client", map[string]any{"success": true}) - tflog.Info(ctx, "Configured Conduktor Gateway client", map[string]any{"success": true}) + if consoleApiClient != nil { + tflog.Info(ctx, "Configured Conduktor Console client", map[string]any{"success": true}) + } + if gatewayApiClient != nil { + tflog.Info(ctx, "Configured Conduktor Gateway client", map[string]any{"success": true}) + } } func (p *ConduktorProvider) Resources(ctx context.Context) []func() resource.Resource { diff --git a/internal/provider/user_v2_resource.go b/internal/provider/user_v2_resource.go index 15c2554..14eb350 100644 --- a/internal/provider/user_v2_resource.go +++ b/internal/provider/user_v2_resource.go @@ -57,7 +57,7 @@ func (r *UserV2Resource) Configure(ctx context.Context, req resource.ConfigureRe if data.ConsoleClient == nil { resp.Diagnostics.AddError( "Unexpected Resource Configure Type", - "Console Client not configured. Please provide client configuration details.", + "Console Client not configured. Please provide client configuration details for Console API.", ) return } diff --git a/internal/schema/provider_conduktor/conduktor_provider_gen.go b/internal/schema/provider_conduktor/conduktor_provider_gen.go index 7b38ff2..30fea0b 100644 --- a/internal/schema/provider_conduktor/conduktor_provider_gen.go +++ b/internal/schema/provider_conduktor/conduktor_provider_gen.go @@ -72,13 +72,13 @@ func ConduktorProviderSchema(ctx context.Context) schema.Schema { }, "gateway_url": schema.StringAttribute{ Optional: true, - Description: "The URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", - MarkdownDescription: "The URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", + Description: "The administration URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", + MarkdownDescription: "The administration URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", }, "gateway_user": schema.StringAttribute{ Optional: true, - Description: "The email of the Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", - MarkdownDescription: "The email of the Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", + Description: "The login of a Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", + MarkdownDescription: "The login of a Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", }, "insecure": schema.BoolAttribute{ Optional: true, diff --git a/provider_code_spec.json b/provider_code_spec.json index 6fc20a7..506a603 100644 --- a/provider_code_spec.json +++ b/provider_code_spec.json @@ -64,14 +64,14 @@ { "name": "gateway_url", "string": { - "description": "The URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", + "description": "The administration URL of the Conduktor Gateway. May also be set using environment variable `CDK_GATEWAY_BASE_URL`. Required either here or in the environment.", "optional_required": "optional" } }, { "name": "gateway_user", "string": { - "description": "The email of the Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", + "description": "The login of a Gateway admin user. May be set using environment variable `CDK_GATEWAY_USER`. Required if gateway_url is set.", "optional_required": "optional" } },