Skip to content

Commit

Permalink
Should be able to update config name (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
Etourneau Gwenn authored Sep 27, 2023
1 parent 02b0463 commit 85aeb73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/metrics_exporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ var updateMetricsExporterCmd = &cobra.Command{
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err))
}

oldname := metricsExporterName
if cmd.Flags().Changed("new-config-name") {
metricsExporterName, _ = cmd.Flags().GetString("new-config-name")
}
//We initialise this one here, even if we error out later
metricsExporterConfigSpec := ybmclient.NewMetricsExporterConfigurationSpec(metricsExporterName, *metricsSinkTypeEnum)

Expand Down Expand Up @@ -386,7 +390,7 @@ var updateMetricsExporterCmd = &cobra.Command{
logrus.Fatalf("Only datadog is accepted as third party sink for now")
}

config, err := authApi.GetConfigByName(metricsExporterName)
config, err := authApi.GetConfigByName(oldname)
if err != nil {
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err))
}
Expand Down Expand Up @@ -463,4 +467,5 @@ func init() {
updateMetricsExporterCmd.Flags().StringToString("grafana-spec", nil, `Configuration for Grafana.
Please provide key value pairs as follows:
access-policy-token=<your-grafana-token>,zone=<your-grafana-zone-parameter>,instance-id=<your-grafana-instance-id>,org-slug=<your-grafana-org-slug>`)
updateMetricsExporterCmd.Flags().String("new-config-name", "", "[OPTIONAL] The new name of the metrics exporter configuration")
}
1 change: 1 addition & 0 deletions docs/ybm_metrics-exporter_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ybm metrics-exporter update [flags]
--grafana-spec stringToString Configuration for Grafana.
Please provide key value pairs as follows:
access-policy-token=<your-grafana-token>,zone=<your-grafana-zone-parameter>,instance-id=<your-grafana-instance-id>,org-slug=<your-grafana-org-slug> (default [])
--new-config-name string [OPTIONAL] The new name of the metrics exporter configuration
-h, --help help for update
```

Expand Down

0 comments on commit 85aeb73

Please sign in to comment.