Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/stackit_argus_grafana_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Shows details of the Grafana configuration of an Argus instance

Shows details of the Grafana configuration of an Argus instance.
The Grafana dashboard URL and initial credentials (admin user and password) will be shown in the "pretty" output format. These credentials are only valid for first login. Please change the password after first login. After changing, the initial password is no longer valid.
The initial password is shown by default, if you want to hide it use the "--hide-password" flag.
The initial password is hidden by default, if you want to show it use the "--show-password" flag.

```
stackit argus grafana describe INSTANCE_ID [flags]
Expand All @@ -21,15 +21,15 @@ stackit argus grafana describe INSTANCE_ID [flags]
Get details of the Grafana configuration of an Argus instance with ID "xxx" in a table format
$ stackit argus credentials describe xxx --output-format pretty

Get details of the Grafana configuration of an Argus instance with ID "xxx" and hide the initial admin password
$ stackit argus credentials describe xxx --output-format pretty --hide-password
Get details of the Grafana configuration of an Argus instance with ID "xxx" and show the initial admin password
$ stackit argus credentials describe xxx --output-format pretty --show-password
```

### Options

```
-h, --help Help for "stackit argus grafana describe"
--hide-password Show the initial admin password in the "pretty" output format
--show-password Show the initial admin password in the "pretty" output format
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_logme_credentials_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ stackit logme credentials create [flags]
Create credentials for a LogMe instance
$ stackit logme credentials create --instance-id xxx

Create credentials for a LogMe instance and hide the password in the output
$ stackit logme credentials create --instance-id xxx --hide-password
Create credentials for a LogMe instance and show the password in the output
$ stackit logme credentials create --instance-id xxx --show-password
```

### Options

```
-h, --help Help for "stackit logme credentials create"
--hide-password Hide password in output
--instance-id string Instance ID
--show-password Show password in output
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_mariadb_credentials_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ stackit mariadb credentials create [flags]
Create credentials for a MariaDB instance
$ stackit mariadb credentials create --instance-id xxx

Create credentials for a MariaDB instance and hide the password in the output
$ stackit mariadb credentials create --instance-id xxx --hide-password
Create credentials for a MariaDB instance and show the password in the output
$ stackit mariadb credentials create --instance-id xxx --show-password
```

### Options

```
-h, --help Help for "stackit mariadb credentials create"
--hide-password Hide password in output
--instance-id string Instance ID
--show-password Show password in output
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_opensearch_credentials_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ stackit opensearch credentials create [flags]
Create credentials for an OpenSearch instance
$ stackit opensearch credentials create --instance-id xxx

Create credentials for an OpenSearch instance and hide the password in the output
$ stackit opensearch credentials create --instance-id xxx --hide-password
Create credentials for an OpenSearch instance and show the password in the output
$ stackit opensearch credentials create --instance-id xxx --show-password
```

### Options

```
-h, --help Help for "stackit opensearch credentials create"
--hide-password Hide password in output
--instance-id string Instance ID
--show-password Show password in output
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_rabbitmq_credentials_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ stackit rabbitmq credentials create [flags]
Create credentials for a RabbitMQ instance
$ stackit rabbitmq credentials create --instance-id xxx

Create credentials for a RabbitMQ instance and hide the password in the output
$ stackit rabbitmq credentials create --instance-id xxx --hide-password
Create credentials for a RabbitMQ instance and show the password in the output
$ stackit rabbitmq credentials create --instance-id xxx --show-password
```

### Options

```
-h, --help Help for "stackit rabbitmq credentials create"
--hide-password Hide password in output
--instance-id string Instance ID
--show-password Show password in output
```

### Options inherited from parent commands
Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_redis_credentials_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ stackit redis credentials create [flags]
Create credentials for a Redis instance
$ stackit redis credentials create --instance-id xxx

Create credentials for a Redis instance and hide the password in the output
$ stackit redis credentials create --instance-id xxx --hide-password
Create credentials for a Redis instance and show the password in the output
$ stackit redis credentials create --instance-id xxx --show-password
```

### Options

```
-h, --help Help for "stackit redis credentials create"
--hide-password Hide password in output
--instance-id string Instance ID
--show-password Show password in output
```

### Options inherited from parent commands
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/argus/grafana/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (

const (
instanceIdArg = "INSTANCE_ID"
hidePasswordFlag = "hide-password"
showPasswordFlag = "show-password"
)

type inputModel struct {
*globalflags.GlobalFlagModel
InstanceId string
HidePassword bool
ShowPassword bool
}

func NewCmd(p *print.Printer) *cobra.Command {
Expand All @@ -37,7 +37,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
Long: fmt.Sprintf("%s\n%s\n%s",
"Shows details of the Grafana configuration of an Argus instance.",
`The Grafana dashboard URL and initial credentials (admin user and password) will be shown in the "pretty" output format. These credentials are only valid for first login. Please change the password after first login. After changing, the initial password is no longer valid.`,
`The initial password is shown by default, if you want to hide it use the "--hide-password" flag.`,
`The initial password is hidden by default, if you want to show it use the "--show-password" flag.`,
),
Args: args.SingleArg(instanceIdArg, utils.ValidateUUID),
Example: examples.Build(
Expand All @@ -48,8 +48,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Get details of the Grafana configuration of an Argus instance with ID "xxx" in a table format`,
"$ stackit argus credentials describe xxx --output-format pretty"),
examples.NewExample(
`Get details of the Grafana configuration of an Argus instance with ID "xxx" and hide the initial admin password`,
"$ stackit argus credentials describe xxx --output-format pretty --hide-password"),
`Get details of the Grafana configuration of an Argus instance with ID "xxx" and show the initial admin password`,
"$ stackit argus credentials describe xxx --output-format pretty --show-password"),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -84,7 +84,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
}

func configureFlags(cmd *cobra.Command) {
cmd.Flags().Bool(hidePasswordFlag, false, `Show the initial admin password in the "pretty" output format`)
cmd.Flags().Bool(showPasswordFlag, false, `Show the initial admin password in the "pretty" output format`)
}

func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
Expand All @@ -98,7 +98,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
model := inputModel{
GlobalFlagModel: globalFlags,
InstanceId: instanceId,
HidePassword: flags.FlagToBoolValue(p, cmd, hidePasswordFlag),
ShowPassword: flags.FlagToBoolValue(p, cmd, showPasswordFlag),
}

if p.IsVerbosityDebug() {
Expand Down Expand Up @@ -127,7 +127,7 @@ func outputResult(p *print.Printer, inputModel *inputModel, grafanaConfigs *argu
switch inputModel.OutputFormat {
case print.PrettyOutputFormat:
initialAdminPassword := *instance.Instance.GrafanaAdminPassword
if inputModel.HidePassword {
if !inputModel.ShowPassword {
initialAdminPassword = "<hidden>"
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/argus/grafana/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ func TestParseInput(t *testing.T) {
isValid: false,
},
{
description: "hide password",
description: "show password",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[hidePasswordFlag] = "true"
flagValues[showPasswordFlag] = "true"
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.HidePassword = true
model.ShowPassword = true
}),
},
{
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/logme/credentials/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

const (
instanceIdFlag = "instance-id"
hidePasswordFlag = "hide-password"
showPasswordFlag = "show-password"
)

type inputModel struct {
*globalflags.GlobalFlagModel
InstanceId string
HidePassword bool
ShowPassword bool
}

func NewCmd(p *print.Printer) *cobra.Command {
Expand All @@ -40,8 +40,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Create credentials for a LogMe instance`,
"$ stackit logme credentials create --instance-id xxx"),
examples.NewExample(
`Create credentials for a LogMe instance and hide the password in the output`,
"$ stackit logme credentials create --instance-id xxx --hide-password"),
`Create credentials for a LogMe instance and show the password in the output`,
"$ stackit logme credentials create --instance-id xxx --show-password"),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -86,7 +86,7 @@ func NewCmd(p *print.Printer) *cobra.Command {

func configureFlags(cmd *cobra.Command) {
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "Instance ID")
cmd.Flags().Bool(hidePasswordFlag, false, "Hide password in output")
cmd.Flags().Bool(showPasswordFlag, false, "Show password in output")

err := flags.MarkFlagsRequired(cmd, instanceIdFlag)
cobra.CheckErr(err)
Expand All @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
model := inputModel{
GlobalFlagModel: globalFlags,
InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag),
HidePassword: flags.FlagToBoolValue(p, cmd, hidePasswordFlag),
ShowPassword: flags.FlagToBoolValue(p, cmd, showPasswordFlag),
}

if p.IsVerbosityDebug() {
Expand Down Expand Up @@ -138,7 +138,7 @@ func outputResult(p *print.Printer, model *inputModel, instanceLabel string, res
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
}
if model.HidePassword {
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
Expand Down
10 changes: 10 additions & 0 deletions internal/cmd/logme/credentials/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ func TestParseInput(t *testing.T) {
flagValues: map[string]string{},
isValid: false,
},
{
description: "show password",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[showPasswordFlag] = "true"
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.ShowPassword = true
}),
},
{
description: "project id missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/mariadb/credentials/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

const (
instanceIdFlag = "instance-id"
hidePasswordFlag = "hide-password"
showPasswordFlag = "show-password"
)

type inputModel struct {
*globalflags.GlobalFlagModel
InstanceId string
HidePassword bool
ShowPassword bool
}

func NewCmd(p *print.Printer) *cobra.Command {
Expand All @@ -40,8 +40,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Create credentials for a MariaDB instance`,
"$ stackit mariadb credentials create --instance-id xxx"),
examples.NewExample(
`Create credentials for a MariaDB instance and hide the password in the output`,
"$ stackit mariadb credentials create --instance-id xxx --hide-password"),
`Create credentials for a MariaDB instance and show the password in the output`,
"$ stackit mariadb credentials create --instance-id xxx --show-password"),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -86,7 +86,7 @@ func NewCmd(p *print.Printer) *cobra.Command {

func configureFlags(cmd *cobra.Command) {
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "Instance ID")
cmd.Flags().Bool(hidePasswordFlag, false, "Hide password in output")
cmd.Flags().Bool(showPasswordFlag, false, "Show password in output")

err := flags.MarkFlagsRequired(cmd, instanceIdFlag)
cobra.CheckErr(err)
Expand All @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
model := inputModel{
GlobalFlagModel: globalFlags,
InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag),
HidePassword: flags.FlagToBoolValue(p, cmd, hidePasswordFlag),
ShowPassword: flags.FlagToBoolValue(p, cmd, showPasswordFlag),
}

if p.IsVerbosityDebug() {
Expand Down Expand Up @@ -138,7 +138,7 @@ func outputResult(p *print.Printer, model *inputModel, instanceLabel string, res
if username != "" {
p.Outputf("Username: %s\n", *resp.Raw.Credentials.Username)
}
if model.HidePassword {
if !model.ShowPassword {
p.Outputf("Password: <hidden>\n")
} else {
p.Outputf("Password: %s\n", *resp.Raw.Credentials.Password)
Expand Down
10 changes: 10 additions & 0 deletions internal/cmd/mariadb/credentials/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ func TestParseInput(t *testing.T) {
flagValues: map[string]string{},
isValid: false,
},
{
description: "show password",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[showPasswordFlag] = "true"
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.ShowPassword = true
}),
},
{
description: "project id missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
Expand Down
Loading