Skip to content

Commit

Permalink
handling bool flags for datadog and rsyslog
Browse files Browse the repository at this point in the history
  • Loading branch information
simisoft-exo committed Oct 7, 2024
1 parent 9d89396 commit 065a116
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/dbaas_external_endpoint_create_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
v3 "github.com/exoscale/egoscale/v3"
)

func (c *dbaasExternalEndpointCreateCmd) createDatadog(_ *cobra.Command, _ []string) error {
func (c *dbaasExternalEndpointCreateCmd) createDatadog(cmd *cobra.Command, _ []string) error {
ctx := gContext

client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(account.CurrentAccount.DefaultZone))
Expand Down Expand Up @@ -39,7 +39,7 @@ func (c *dbaasExternalEndpointCreateCmd) createDatadog(_ *cobra.Command, _ []str
if c.DatadogTags != "" {
datadogRequestPayload.Settings.DatadogTags = datadogTags
}
if c.DatadogDisableConsumerStats {
if cmd.Flags().Changed("datadog-disable-consumer-stats") {
datadogRequestPayload.Settings.DisableConsumerStats = v3.Bool(c.DatadogDisableConsumerStats)
}
if c.DatadogKafkaConsumerCheckInstances != 0 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/dbaas_external_endpoint_create_rsyslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
v3 "github.com/exoscale/egoscale/v3"
)

func (c *dbaasExternalEndpointCreateCmd) createRsyslog(_ *cobra.Command, _ []string) error {
func (c *dbaasExternalEndpointCreateCmd) createRsyslog(cmd *cobra.Command, _ []string) error {
ctx := gContext
client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(account.CurrentAccount.DefaultZone))
if err != nil {
Expand Down Expand Up @@ -46,7 +46,7 @@ func (c *dbaasExternalEndpointCreateCmd) createRsyslog(_ *cobra.Command, _ []str
if c.RsyslogServer != "" {
rsyslogRequestPayload.Settings.Server = c.RsyslogServer
}
if c.RsyslogTls {
if cmd.Flags().Changed("rsyslog-tls") {
rsyslogRequestPayload.Settings.Tls = v3.Bool(c.RsyslogTls)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/dbaas_external_endpoint_update_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
v3 "github.com/exoscale/egoscale/v3"
)

func (c *dbaasExternalEndpointUpdateCmd) updateDatadog(_ *cobra.Command, _ []string) error {
func (c *dbaasExternalEndpointUpdateCmd) updateDatadog(cmd *cobra.Command, _ []string) error {
ctx := gContext

client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(account.CurrentAccount.DefaultZone))
Expand Down Expand Up @@ -39,7 +39,7 @@ func (c *dbaasExternalEndpointUpdateCmd) updateDatadog(_ *cobra.Command, _ []str
if c.DatadogTags != "" {
datadogRequestPayload.Settings.DatadogTags = datadogTags
}
if c.DatadogDisableConsumerStats {
if cmd.Flags().Changed("datadog-disable-consumer-stats") {
datadogRequestPayload.Settings.DisableConsumerStats = v3.Bool(c.DatadogDisableConsumerStats)
}
if c.DatadogKafkaConsumerCheckInstances != 0 {
Expand Down
7 changes: 2 additions & 5 deletions cmd/dbaas_external_endpoint_update_rsyslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
v3 "github.com/exoscale/egoscale/v3"
)

func (c *dbaasExternalEndpointUpdateCmd) updateRsyslog(_ *cobra.Command, _ []string) error {
func (c *dbaasExternalEndpointUpdateCmd) updateRsyslog(cmd *cobra.Command, _ []string) error {
ctx := gContext
client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(account.CurrentAccount.DefaultZone))
if err != nil {
Expand Down Expand Up @@ -46,13 +46,10 @@ func (c *dbaasExternalEndpointUpdateCmd) updateRsyslog(_ *cobra.Command, _ []str
if c.RsyslogServer != "" {
rsyslogRequestPayload.Settings.Server = c.RsyslogServer
}
if c.RsyslogTls {
if cmd.Flags().Changed("rsyslog-tls") {
rsyslogRequestPayload.Settings.Tls = v3.Bool(c.RsyslogTls)
}

fmt.Printf("Sending Update request for %s\n", c.ID)
fmt.Printf("Sending Update request for UUID %s\n", v3.UUID(c.ID))

op, err := client.UpdateDBAASExternalEndpointRsyslog(ctx, v3.UUID(c.ID), rsyslogRequestPayload)
if err != nil {
return err
Expand Down

0 comments on commit 065a116

Please sign in to comment.