Skip to content

Commit

Permalink
Fixed errors in metrics resource doc (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
bansal01yash authored Nov 29, 2024
1 parent 98f64a6 commit d510fbf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
16 changes: 8 additions & 8 deletions docs/resources/associate_metrics_exporter_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The resource to manage metrics export configuration for a cluster in YugabyteDB
```terraform
resource "ybm_associate_metrics_exporter_cluster" "metrics-srcluster" {
cluster_id = ybm_cluster.single_region_cluster.cluster_id
config_id = ybm_metrics_exporter.test.config_id
depends_on = [ybm_cluster.single_region_cluster, ybm_metrics_exporter.test]
config_id = ybm_integration.test.config_id
depends_on = [ybm_cluster.single_region_cluster, ybm_integration.test]
}
```

Expand All @@ -24,12 +24,12 @@ resource "ybm_associate_metrics_exporter_cluster" "metrics-srcluster" {

### Optional

- `cluster_id` (String) The ID of the metrics exporter config.
- `cluster_name` (String) The name of the metrics exporter configuration
- `config_id` (String) The ID of the metrics exporter config.
- `config_name` (String) The name of the metrics exporter configuration
- `cluster_id` (String) ID of the cluster with which this metrics export configuration will be associated.
- `cluster_name` (String) Name of the cluster with which this metrics export configuration will be associated.
- `config_id` (String) ID of the integration for this metrics export configuration.
- `config_name` (String) Name of the integration for this metrics export configuration

### Read-Only

- `account_id` (String) The ID of the account this private service endpoint belongs to.
- `project_id` (String) The ID of the project this private service endpoint belongs to.
- `account_id` (String) ID of the account this metrics export configuration belongs to.
- `project_id` (String) ID of the project this metrics export configuration belongs to.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "ybm_associate_metrics_exporter_cluster" "metrics-srcluster" {
cluster_id = ybm_cluster.single_region_cluster.cluster_id
config_id = ybm_metrics_exporter.test.config_id
depends_on = [ybm_cluster.single_region_cluster, ybm_metrics_exporter.test]
}
config_id = ybm_integration.test.config_id
depends_on = [ybm_cluster.single_region_cluster, ybm_integration.test]
}
12 changes: 6 additions & 6 deletions managed/resource_associate_me_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ func (r resourceAssociateMetricsExporterClusterType) GetSchema(_ context.Context
Description: `The resource to manage metrics export configuration for a cluster in YugabyteDB Aeon.`,
Attributes: map[string]tfsdk.Attribute{
"account_id": {
Description: "The ID of the account this private service endpoint belongs to.",
Description: "ID of the account this metrics export configuration belongs to.",
Type: types.StringType,
Computed: true,
},
"project_id": {
Description: "The ID of the project this private service endpoint belongs to.",
Description: "ID of the project this metrics export configuration belongs to.",
Type: types.StringType,
Computed: true,
},
"cluster_id": {
Description: "The ID of the metrics exporter config.",
Description: "ID of the cluster with which this metrics export configuration will be associated.",
Type: types.StringType,
Optional: true,
Computed: true,
},
"cluster_name": {
Description: "The name of the metrics exporter configuration",
Description: "Name of the cluster with which this metrics export configuration will be associated.",
Type: types.StringType,
Optional: true,
Computed: true,
Expand All @@ -48,13 +48,13 @@ func (r resourceAssociateMetricsExporterClusterType) GetSchema(_ context.Context
},
},
"config_id": {
Description: "The ID of the metrics exporter config.",
Description: "ID of the integration for this metrics export configuration.",
Type: types.StringType,
Optional: true,
Computed: true,
},
"config_name": {
Description: "The name of the metrics exporter configuration",
Description: "Name of the integration for this metrics export configuration",
Type: types.StringType,
Optional: true,
Computed: true,
Expand Down
32 changes: 16 additions & 16 deletions managed/resource_db_query_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r resourceDbQueryLoggingType) GetSchema(ctx context.Context) (tfsdk.Schema
Computed: true,
},
"cluster_id": {
Description: "ID of the cluster with which this DB query logging config will be associated.",
Description: "ID of the cluster with which this DB query logging configuration will be associated.",
Type: types.StringType,
Required: true,
},
Expand Down Expand Up @@ -216,7 +216,7 @@ func getPgLogExporterConfig(ctx context.Context, accountId string, projectId str
}

if len(specList.GetData()) < 1 {
return nil, false, "no DB query logging config found for the cluster"
return nil, false, "no DB query logging configuration found for the cluster"
}
return &specList.Data[0], true, ""
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func (r resourceDbQueryLogging) Update(ctx context.Context, req tfsdk.UpdateReso
var planConfig DbQueryLoggingConfig
resp.Diagnostics.Append(getConfigFromPlan(ctx, req.Plan, &planConfig)...)
if resp.Diagnostics.HasError() {
tflog.Debug(ctx, "Error while getting the plan for the Db query logging config")
tflog.Debug(ctx, "Error while getting the plan for the Db query logging configuration")
return
}
integrationName := planConfig.IntegrationName.Value
Expand All @@ -305,7 +305,7 @@ func (r resourceDbQueryLogging) Update(ctx context.Context, req tfsdk.UpdateReso

spec, ok, errMsg := getPgLogExporterConfig(ctx, accountId, projectId, clusterId, apiClient)
if !ok {
resp.Diagnostics.AddError("Unable to fetch DB query logging config", errMsg)
resp.Diagnostics.AddError("Unable to fetch DB query logging configuration", errMsg)
return
}

Expand All @@ -323,13 +323,13 @@ func (r resourceDbQueryLogging) Update(ctx context.Context, req tfsdk.UpdateReso
// Use planConfig provided in tf file to build new API Pg log exporter config spec
apiConfigSpec, err := buildDbQueryLoggingSpec(planConfig, integrationId, &spec.Spec.ExportConfig)
if err != nil {
resp.Diagnostics.AddError("Unable to update DB query logging config", GetApiErrorDetails(err))
resp.Diagnostics.AddError("Unable to update DB query logging configuration", GetApiErrorDetails(err))
return
}

_, _, err = apiClient.ClusterApi.UpdatePgLogExporterConfig(ctx, accountId, projectId, clusterId, configId).PgLogExporterConfigSpec(*apiConfigSpec).Execute()
if err != nil {
resp.Diagnostics.AddError(fmt.Sprintf("Unable to update DB query logging config for cluster %s", clusterId), GetApiErrorDetails(err))
resp.Diagnostics.AddError(fmt.Sprintf("Unable to update DB query logging configuration for cluster %s", clusterId), GetApiErrorDetails(err))
return
}

Expand All @@ -342,25 +342,25 @@ func (r resourceDbQueryLogging) Update(ctx context.Context, req tfsdk.UpdateReso
return nil
}
if asState == string(openapiclient.TASKACTIONSTATEENUM_FAILED) {
return fmt.Errorf("failed to update DB query log config")
return fmt.Errorf("failed to update DB query log configuration")
}
} else {
return retry.RetryableError(errors.New("unable to check DB query log config update status: " + message))
return retry.RetryableError(errors.New("unable to check DB query log configuration update status: " + message))
}
return retry.RetryableError(errors.New("DB query log config is being updated"))
return retry.RetryableError(errors.New("DB query log configuration is being updated"))
})

if err != nil {
errorSummary := fmt.Sprintf("Unable to update DB query log config for cluster: %s", clusterId)
resp.Diagnostics.AddError(errorSummary, "The operation timed out waiting for DB query log config update operation.")
errorSummary := fmt.Sprintf("Unable to update DB query log configuration for cluster: %s", clusterId)
resp.Diagnostics.AddError(errorSummary, "The operation timed out waiting for DB query log configuration update operation.")
return
}

planConfig.ConfigID.Value = configId

dbqlConfig, readOK, readErrMsg := resourceRead(ctx, accountId, projectId, clusterId, integrationName, apiClient)
if !readOK {
resp.Diagnostics.AddError("Unable to read the state of Db Query log config ", readErrMsg)
resp.Diagnostics.AddError("Unable to read the state of Db Query log configuration ", readErrMsg)
return
}

Expand All @@ -382,7 +382,7 @@ func (r resourceDbQueryLogging) Delete(ctx context.Context, req tfsdk.DeleteReso

_, err := apiClient.ClusterApi.RemovePgLogExporterConfig(ctx, accountId, projectId, clusterId, configId).Execute()
if err != nil {
resp.Diagnostics.AddError(fmt.Sprintf("Unable to remove DB query logging config for cluster: %s", clusterId), GetApiErrorDetails(err))
resp.Diagnostics.AddError(fmt.Sprintf("Unable to remove DB query logging configuration for cluster: %s", clusterId), GetApiErrorDetails(err))
return
}

Expand All @@ -404,7 +404,7 @@ func (r resourceDbQueryLogging) Delete(ctx context.Context, req tfsdk.DeleteReso
})

if err != nil {
resp.Diagnostics.AddError("Unable to remove Db Logging config from the cluster ", "The operation timed out waiting for DB Query Logging removal to complete.")
resp.Diagnostics.AddError("Unable to remove Db Logging configuration from the cluster ", "The operation timed out waiting for DB Query Logging removal to complete.")
return
}

Expand Down Expand Up @@ -461,7 +461,7 @@ func (r resourceDbQueryLogging) Create(ctx context.Context, req tfsdk.CreateReso

dbQueryLoggingConfigSpec, err := buildDbQueryLoggingSpec(config, integrationId, openapiclient.NewPgLogExportConfigWithDefaults())
if err != nil {
tflog.Warn(ctx, "Unable to build DB query logging config spec"+GetApiErrorDetails(err))
tflog.Warn(ctx, "Unable to build DB query logging configuration spec"+GetApiErrorDetails(err))
resp.Diagnostics.AddError("Encountered error while enabling DB Query Logging", GetApiErrorDetails(err))
return
}
Expand Down Expand Up @@ -502,7 +502,7 @@ func (r resourceDbQueryLogging) Create(ctx context.Context, req tfsdk.CreateReso
dbQueryLoggingConfig, readOK, readErrMsg := resourceRead(ctx, accountId, projectId,
clusterId, integrationName, apiClient)
if !readOK {
resp.Diagnostics.AddError("Unable to read the state of Db Query log config for the cluster ", readErrMsg)
resp.Diagnostics.AddError("Unable to read the state of Db Query log configuration for the cluster ", readErrMsg)
return
}

Expand Down

0 comments on commit d510fbf

Please sign in to comment.