Skip to content

Commit

Permalink
show datadog endpoint+settings
Browse files Browse the repository at this point in the history
  • Loading branch information
simisoft-exo committed Sep 11, 2024
1 parent 3e7df5d commit 011d40d
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion cmd/dbaas_external_endpoint_show_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package cmd

import (
"fmt"
"os"
"strconv"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
"github.com/exoscale/cli/table"
v3 "github.com/exoscale/egoscale/v3"
)

Expand All @@ -20,7 +23,43 @@ func (o *datadogOutput) ToJSON() { output.JSON(o) }

func (o *datadogOutput) ToText() { output.Text(o) }

func (o *datadogOutput) ToTable() { output.Table(o) }
func (o *datadogOutput) ToTable() {
t := table.NewTable(os.Stdout)
t.SetHeader([]string{"Datadog External Endpoint"})
defer t.Render()

t.Append([]string{"Endpoint ID", o.ID})
t.Append([]string{"Endpoint Name", o.Name})
t.Append([]string{"Endpoint Type", o.Type})

settings := o.Settings
t.Append([]string{"Datadog API Key", settings.DatadogAPIKey})
t.Append([]string{"Site", string(settings.Site)})

disableConsumerStats := "false"
if settings.DisableConsumerStats != nil && *settings.DisableConsumerStats {
disableConsumerStats = "true"
}

t.Append([]string{"Disable Consumer Stats", disableConsumerStats})
t.Append([]string{"Kafka Consumer Check Instances", strconv.FormatInt(settings.KafkaConsumerCheckInstances, 10)})
t.Append([]string{"Kafka Consumer Stats Timeout", strconv.FormatInt(settings.KafkaConsumerStatsTimeout, 10)})
t.Append([]string{"Max Partition Contexts", strconv.FormatInt(settings.MaxPartitionContexts, 10)})


if len(settings.DatadogTags) > 0 {
tagLines := make([]string, len(settings.DatadogTags))
for i, tag := range settings.DatadogTags {
tagLines[i] = fmt.Sprintf("%s (%s)", tag.Tag, tag.Comment)
}
t.Append([]string{"Datadog Tags", tagLines[0]})
for _, line := range tagLines[1:] {
t.Append([]string{"", line})
}
} else {
t.Append([]string{"Datadog Tags", "None"})
}
}

func (c *dbaasExternalEndpointShowCmd) showDatadog() (output.Outputter, error) {
ctx := gContext
Expand Down

0 comments on commit 011d40d

Please sign in to comment.