Skip to content

Commit

Permalink
fix: comments resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
marnas committed Nov 26, 2024
1 parent f6d0044 commit 33bf1fb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/generic_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/group_v2_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kafka_cluster_v2_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kafka_connect_v2_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
32 changes: 18 additions & 14 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/user_v2_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions internal/schema/provider_conduktor/conduktor_provider_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions provider_code_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down

0 comments on commit 33bf1fb

Please sign in to comment.