Skip to content

Commit

Permalink
Kafka Access cert is considered sensitive value
Browse files Browse the repository at this point in the history
  • Loading branch information
tgrondier committed Dec 9, 2024
1 parent 6cd9d57 commit 6068888
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
12 changes: 10 additions & 2 deletions cmd/dbaas_user_reveal_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"time"

"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
Expand All @@ -10,11 +11,16 @@ import (
)

type dbaasKafkaUserRevealOutput struct {
AccessKey string `json:"access-key,omitempty"`
AccessKey string `json:"access-key,omitempty"`
AccessCert string `json:"access-cert,omitempty"`
AccessCertExpiry time.Time `json:"access-cert-expiry,omitempty"`
}

func (o *dbaasKafkaUserRevealOutput) formatUser(t *table.Table) {
t.Append([]string{"Access Cert", o.AccessCert})
t.Append([]string{"Access Key", o.AccessKey})
t.Append([]string{"Access Cert Expiry", o.AccessCertExpiry.String()})

}

func (c *dbaasUserRevealCmd) revealKafka(ctx context.Context) (output.Outputter, error) {
Expand All @@ -32,7 +38,9 @@ func (c *dbaasUserRevealCmd) revealKafka(ctx context.Context) (output.Outputter,
return &dbaasUserRevealOutput{
Password: s.Password,
Kafka: &dbaasKafkaUserRevealOutput{
AccessKey: s.AccessKey,
AccessKey: s.AccessKey,
AccessCert: s.AccessCert,
AccessCertExpiry: s.AccessCertExpiry,
},
}, nil
}
3 changes: 0 additions & 3 deletions cmd/dbaas_user_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type dbaasUserShowOutput struct {

// Additional user info for some DBAAS Services
MySQL *dbaasMysqlUserShowOutput `json:"mysql,omitempty"`
Kafka *dbaasKafkaUserShowOutput `json:"kafka,omitempty"`
PG *dbaasPGUserShowOutput `json:"pg,omitempty"`
}

Expand All @@ -34,8 +33,6 @@ func (o *dbaasUserShowOutput) ToTable() {
switch {
case o.MySQL != nil:
o.MySQL.formatUser(t)
case o.Kafka != nil:
o.Kafka.formatUser(t)
case o.PG != nil:
o.PG.formatUser(t)
}
Expand Down
18 changes: 0 additions & 18 deletions cmd/dbaas_user_show_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,12 @@ package cmd
import (
"context"
"fmt"
"time"

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

type dbaasKafkaUserShowOutput struct {
AccessKey string `json:"access-key,omitempty"`
AccessCert string `json:"access-cert,omitempty"`
AccessCertExpiry time.Time `json:"access-cert-expiry,omitempty"`
}

func (o *dbaasKafkaUserShowOutput) formatUser(t *table.Table) {
t.Append([]string{"Access Key", o.AccessKey})
t.Append([]string{"Access Cert", o.AccessCert})
t.Append([]string{"Access Cert Expiry", o.AccessCertExpiry.String()})
}

func (c *dbaasUserShowCmd) showKafka(ctx context.Context) (output.Outputter, error) {

client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(c.Zone))
Expand All @@ -40,10 +26,6 @@ func (c *dbaasUserShowCmd) showKafka(ctx context.Context) (output.Outputter, err
return &dbaasUserShowOutput{
Username: c.Username,
Type: u.Type,
Kafka: &dbaasKafkaUserShowOutput{
AccessCert: u.AccessCert,
AccessCertExpiry: u.AccessCertExpiry,
},
}, nil
}

Expand Down

0 comments on commit 6068888

Please sign in to comment.