Skip to content

Commit 26c1083

Browse files
committed
Fix: Inconsistent naming of "Key Pair"
- fix: flag --public-key in `$ stackit beta key-pair describe` shows all data when a --output-format is defined - implement all suggested changes
1 parent 6a54091 commit 26c1083

18 files changed

+178
-163
lines changed

docs/stackit_beta.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ stackit beta [flags]
4040
### SEE ALSO
4141

4242
* [stackit](./stackit.md) - Manage STACKIT resources using the command line
43-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
43+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
4444
* [stackit beta network](./stackit_beta_network.md) - Provides functionality for networks
4545
* [stackit beta network-area](./stackit_beta_network-area.md) - Provides functionality for STACKIT Network Area (SNA)
4646
* [stackit beta network-interface](./stackit_beta_network-interface.md) - Provides functionality for network interfaces

docs/stackit_beta_key-pair.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair
22

3-
Provides functionality for Keypairs
3+
Provides functionality for SSH Key Pairs
44

55
### Synopsis
66

7-
Provides functionality for Keypairs
7+
Provides functionality for SSH Key Pairs
88

99
```
1010
stackit beta key-pair [flags]
@@ -29,9 +29,9 @@ stackit beta key-pair [flags]
2929
### SEE ALSO
3030

3131
* [stackit beta](./stackit_beta.md) - Contains beta STACKIT CLI commands
32-
* [stackit beta key-pair create](./stackit_beta_key-pair_create.md) - Create a keypair
33-
* [stackit beta key-pair delete](./stackit_beta_key-pair_delete.md) - Delete a keypair
34-
* [stackit beta key-pair describe](./stackit_beta_key-pair_describe.md) - Describe a keypair
35-
* [stackit beta key-pair list](./stackit_beta_key-pair_list.md) - Lists all SSH Keypairs
36-
* [stackit beta key-pair update](./stackit_beta_key-pair_update.md) - Update key pair
32+
* [stackit beta key-pair create](./stackit_beta_key-pair_create.md) - Create a Key Pair
33+
* [stackit beta key-pair delete](./stackit_beta_key-pair_delete.md) - Delete a Key Pair
34+
* [stackit beta key-pair describe](./stackit_beta_key-pair_describe.md) - Describe a Key Pair
35+
* [stackit beta key-pair list](./stackit_beta_key-pair_list.md) - Lists all Key Pairs
36+
* [stackit beta key-pair update](./stackit_beta_key-pair_update.md) - Update Key Pair
3737

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair create
22

3-
Create a keypair
3+
Create a Key Pair
44

55
### Synopsis
66

7-
Create a keypair.
7+
Create a Key Pair.
88

99
```
1010
stackit beta key-pair create [flags]
@@ -13,26 +13,26 @@ stackit beta key-pair create [flags]
1313
### Examples
1414

1515
```
16-
Create a new key-pair with public-key "ssh-rsa xxx"
17-
$ stackit beta key-pair create --public-key ssh-rsa xxx
16+
Create a new Key Pair with public-key "ssh-rsa xxx"
17+
$ stackit beta key-pair create --public-key `ssh-rsa xxx`
1818
19-
Create a new key-pair with public-key from file "/Users/username/.ssh/id_rsa.pub"
20-
$ stackit beta key-pair create --public-key @/Users/username/.ssh/id_rsa.pub
19+
Create a new Key Pair with public-key from file "/Users/username/.ssh/id_rsa.pub"
20+
$ stackit beta key-pair create --public-key `@/Users/username/.ssh/id_rsa.pub`
2121
22-
Create a new key-pair with name "KEYPAIR_NAME" and public-key "ssh-rsa yyy"
23-
$ stackit beta key-pair create --name KEYPAIR_NAME --public-key ssh-rsa yyy
22+
Create a new Key Pair with name "KEY_PAIR_NAME" and public-key "ssh-rsa yyy"
23+
$ stackit beta key-pair create --name KEY_PAIR_NAME --public-key `ssh-rsa yyy`
2424
25-
Create a new key-pair with public-key "ssh-rsa xxx" and labels "key=value,key1=value1"
26-
$ stackit beta key-pair create --public-key ssh-rsa xxx --labels key=value,key1=value1
25+
Create a new Key Pair with public-key "ssh-rsa xxx" and labels "key=value,key1=value1"
26+
$ stackit beta key-pair create --public-key `ssh-rsa xxx` --labels key=value,key1=value1
2727
```
2828

2929
### Options
3030

3131
```
3232
-h, --help Help for "stackit beta key-pair create"
33-
--labels stringToString Labels are key-value string pairs which can be attached to a server. E.g. '--labels key1=value1,key2=value2,...' (default [])
34-
--name string Name of the key which will be created
35-
--public-key string Public key which should be add (format: ssh-rsa|sha-ed25519)
33+
--labels stringToString Labels are key-value string pairs which can be attached to a Key Pair. E.g. '--labels key1=value1,key2=value2,...' (default [])
34+
--name string Key Pair name
35+
--public-key string Public key to be imported (format: ssh-rsa|ssh-ed25519)
3636
```
3737

3838
### Options inherited from parent commands
@@ -47,5 +47,5 @@ stackit beta key-pair create [flags]
4747

4848
### SEE ALSO
4949

50-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
50+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
5151

docs/stackit_beta_key-pair_delete.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair delete
22

3-
Delete a keypair
3+
Delete a Key Pair
44

55
### Synopsis
66

7-
Delete a keypair.
7+
Delete a Key Pair.
88

99
```
1010
stackit beta key-pair delete [flags]
@@ -13,8 +13,8 @@ stackit beta key-pair delete [flags]
1313
### Examples
1414

1515
```
16-
Delete keypair with name "XXX"
17-
$ stackit beta keypair delete XXX
16+
Delete Key Pair with name "KEY_PAIR_NAME"
17+
$ stackit beta key-pair delete KEY_PAIR_NAME
1818
```
1919

2020
### Options
@@ -35,5 +35,5 @@ stackit beta key-pair delete [flags]
3535

3636
### SEE ALSO
3737

38-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
38+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
3939

docs/stackit_beta_key-pair_describe.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair describe
22

3-
Describe a keypair
3+
Describe a Key Pair
44

55
### Synopsis
66

7-
Describe a keypair.
7+
Describe a Key Pair.
88

99
```
1010
stackit beta key-pair describe [flags]
@@ -13,11 +13,11 @@ stackit beta key-pair describe [flags]
1313
### Examples
1414

1515
```
16-
Get details about a keypair named "KEYPAIR_NAME"
17-
$ stackit beta keypair describe KEYPAIR_NAME
16+
Get details about a Key Pair with name "KEY_PAIR_NAME"
17+
$ stackit beta key-pair describe KEY_PAIR_NAME
1818
19-
Get only the SSH public key of a keypair with the name "KEYPAIR_NAME"
20-
$ stackit beta keypair describe KEYPAIR_NAME --public-key
19+
Get only the SSH public key of a Key Pair with name "KEY_PAIR_NAME"
20+
$ stackit beta key-pair describe KEY_PAIR_NAME --public-key
2121
```
2222

2323
### Options
@@ -39,5 +39,5 @@ stackit beta key-pair describe [flags]
3939

4040
### SEE ALSO
4141

42-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
42+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
4343

docs/stackit_beta_key-pair_list.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair list
22

3-
Lists all SSH Keypairs
3+
Lists all Key Pairs
44

55
### Synopsis
66

7-
Lists all SSH Keypairs.
7+
Lists all Key Pairs.
88

99
```
1010
stackit beta key-pair list [flags]
@@ -13,16 +13,16 @@ stackit beta key-pair list [flags]
1313
### Examples
1414

1515
```
16-
Lists all ssh keypairs
16+
Lists all Key Pairs
1717
$ stackit beta key-pair list
1818
19-
Lists all ssh keypairs which contains the label xxx
19+
Lists all Key Pairs which contains the label xxx
2020
$ stackit beta key-pair list --label-selector xxx
2121
22-
Lists all ssh keypairs in JSON format
22+
Lists all Key Pairs in JSON format
2323
$ stackit beta key-pair list --output-format json
2424
25-
Lists up to 10 ssh keypairs
25+
Lists up to 10 Key Pairs
2626
$ stackit beta key-pair list --limit 10
2727
```
2828

@@ -31,7 +31,7 @@ stackit beta key-pair list [flags]
3131
```
3232
-h, --help Help for "stackit beta key-pair list"
3333
--label-selector string Filter by label
34-
--limit int Number of SSH keypairs to list
34+
--limit int Number of Key Pairs to list
3535
```
3636

3737
### Options inherited from parent commands
@@ -46,5 +46,5 @@ stackit beta key-pair list [flags]
4646

4747
### SEE ALSO
4848

49-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
49+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
5050

docs/stackit_beta_key-pair_update.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit beta key-pair update
22

3-
Update key pair
3+
Update Key Pair
44

55
### Synopsis
66

7-
Update key pair.
7+
Update Key Pair.
88

99
```
1010
stackit beta key-pair update [flags]
@@ -13,8 +13,8 @@ stackit beta key-pair update [flags]
1313
### Examples
1414

1515
```
16-
Update the labels of a keypair KEYPAIR_NAME with "key=value,key1=value1"
17-
$ stackit beta key-pair update --labels key=value,key1=value1
16+
Update the labels of a Key Pair KEY_PAIR_NAME with "key=value,key1=value1"
17+
$ stackit beta key-pair update KEY_PAIR_NAME --labels key=value,key1=value1
1818
```
1919

2020
### Options
@@ -36,5 +36,5 @@ stackit beta key-pair update [flags]
3636

3737
### SEE ALSO
3838

39-
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for Keypairs
39+
* [stackit beta key-pair](./stackit_beta_key-pair.md) - Provides functionality for SSH Key Pairs
4040

internal/cmd/beta/key-pair/create/create.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ type inputModel struct {
3333
func NewCmd(p *print.Printer) *cobra.Command {
3434
cmd := &cobra.Command{
3535
Use: "create",
36-
Short: "Create a keypair",
37-
Long: "Create a keypair.",
36+
Short: "Create a Key Pair",
37+
Long: "Create a Key Pair.",
3838
Args: cobra.NoArgs,
3939
Example: examples.Build(
4040
examples.NewExample(
41-
`Create a new key-pair with public-key "ssh-rsa xxx"`,
42-
"$ stackit beta key-pair create --public-key ssh-rsa xxx",
41+
`Create a new Key Pair with public-key "ssh-rsa xxx"`,
42+
"$ stackit beta key-pair create --public-key `ssh-rsa xxx`",
4343
),
4444
examples.NewExample(
45-
`Create a new key-pair with public-key from file "/Users/username/.ssh/id_rsa.pub"`,
46-
"$ stackit beta key-pair create --public-key @/Users/username/.ssh/id_rsa.pub",
45+
`Create a new Key Pair with public-key from file "/Users/username/.ssh/id_rsa.pub"`,
46+
"$ stackit beta key-pair create --public-key `@/Users/username/.ssh/id_rsa.pub`",
4747
),
4848
examples.NewExample(
49-
`Create a new key-pair with name "KEYPAIR_NAME" and public-key "ssh-rsa yyy"`,
50-
"$ stackit beta key-pair create --name KEYPAIR_NAME --public-key ssh-rsa yyy",
49+
`Create a new Key Pair with name "KEY_PAIR_NAME" and public-key "ssh-rsa yyy"`,
50+
"$ stackit beta key-pair create --name KEY_PAIR_NAME --public-key `ssh-rsa yyy`",
5151
),
5252
examples.NewExample(
53-
`Create a new key-pair with public-key "ssh-rsa xxx" and labels "key=value,key1=value1"`,
54-
"$ stackit beta key-pair create --public-key ssh-rsa xxx --labels key=value,key1=value1",
53+
`Create a new Key Pair with public-key "ssh-rsa xxx" and labels "key=value,key1=value1"`,
54+
"$ stackit beta key-pair create --public-key `ssh-rsa xxx` --labels key=value,key1=value1",
5555
),
5656
),
5757
RunE: func(cmd *cobra.Command, _ []string) error {
@@ -68,7 +68,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
6868
}
6969

7070
if !model.AssumeYes {
71-
prompt := "Are your sure you want to create a keypair"
71+
prompt := "Are your sure you want to create a Key Pair?"
7272
err = p.PromptForConfirmation(prompt)
7373
if err != nil {
7474
return err
@@ -79,7 +79,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
7979
req := buildRequest(ctx, model, apiClient)
8080
resp, err := req.Execute()
8181
if err != nil {
82-
return fmt.Errorf("create keypair: %w", err)
82+
return fmt.Errorf("create Key Pair: %w", err)
8383
}
8484

8585
return outputResult(p, model, resp)
@@ -90,9 +90,9 @@ func NewCmd(p *print.Printer) *cobra.Command {
9090
}
9191

9292
func configureFlags(cmd *cobra.Command) {
93-
cmd.Flags().String(nameFlag, "", "Name of the key which will be created")
94-
cmd.Flags().Var(flags.ReadFromFileFlag(), publicKeyFlag, "Public key which should be add (format: ssh-rsa|sha-ed25519)")
95-
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a server. E.g. '--labels key1=value1,key2=value2,...'")
93+
cmd.Flags().String(nameFlag, "", "Key Pair name")
94+
cmd.Flags().Var(flags.ReadFromFileFlag(), publicKeyFlag, "Public key to be imported (format: ssh-rsa|ssh-ed25519)")
95+
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a Key Pair. E.g. '--labels key1=value1,key2=value2,...'")
9696

9797
err := cmd.MarkFlagRequired(publicKeyFlag)
9898
cobra.CheckErr(err)
@@ -146,17 +146,17 @@ func outputResult(p *print.Printer, model *inputModel, item *iaas.Keypair) error
146146
case print.JSONOutputFormat:
147147
details, err := json.MarshalIndent(item, "", " ")
148148
if err != nil {
149-
return fmt.Errorf("marshal keypair: %w", err)
149+
return fmt.Errorf("marshal Key Pair: %w", err)
150150
}
151151
p.Outputln(string(details))
152152
case print.YAMLOutputFormat:
153153
details, err := yaml.MarshalWithOptions(item, yaml.IndentSequence(true))
154154
if err != nil {
155-
return fmt.Errorf("marshal keypair: %w", err)
155+
return fmt.Errorf("marshal Key Pair: %w", err)
156156
}
157157
p.Outputln(string(details))
158158
default:
159-
p.Outputf("Created keypair %q.\nKeypair Fingerprint: %q\n", *item.Name, *item.Fingerprint)
159+
p.Outputf("Created Key Pair %q.\nKey Pair Fingerprint: %q\n", *item.Name, *item.Fingerprint)
160160
}
161161
return nil
162162
}

internal/cmd/beta/key-pair/create/create_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2020
var testClient = &iaas.APIClient{}
2121

2222
var testPublicKey = "ssh-rsa <key>"
23-
var testKeypairName = "foobar_key"
23+
var testKeyPairName = "foobar_key"
2424

2525
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2626
flagValues := map[string]string{
2727
publicKeyFlag: testPublicKey,
2828
labelFlag: "foo=bar",
29-
nameFlag: testKeypairName,
29+
nameFlag: testKeyPairName,
3030
}
3131
for _, mod := range mods {
3232
mod(flagValues)
@@ -43,7 +43,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4343
"foo": "bar",
4444
}),
4545
PublicKey: utils.Ptr(testPublicKey),
46-
Name: utils.Ptr(testKeypairName),
46+
Name: utils.Ptr(testKeyPairName),
4747
}
4848
for _, mod := range mods {
4949
mod(model)
@@ -66,7 +66,7 @@ func fixturePayload(mods ...func(payload *iaas.CreateKeyPairPayload)) iaas.Creat
6666
"foo": "bar",
6767
}),
6868
PublicKey: utils.Ptr(testPublicKey),
69-
Name: utils.Ptr(testKeypairName),
69+
Name: utils.Ptr(testKeyPairName),
7070
}
7171
for _, mod := range mods {
7272
mod(&payload)
@@ -102,11 +102,11 @@ func TestParseInput(t *testing.T) {
102102
{
103103
description: "read public key from file",
104104
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
105-
flagValues[publicKeyFlag] = "@./create_test.go"
105+
flagValues[publicKeyFlag] = "@/template/id_ed25519.pub"
106106
}),
107107
isValid: true,
108108
expectedModel: fixtureInputModel(func(model *inputModel) {
109-
file, err := os.ReadFile("./create_test.go")
109+
file, err := os.ReadFile("./template/id_ed25519.pub")
110110
if err != nil {
111111
t.Fatal("could not create expected Model", err)
112112
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFG1ogKtJ5SElBm3mxhFhdvXxXiz+FxYoOvcdWSW2/ZI

0 commit comments

Comments
 (0)