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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

### Bug fixes


- compute: allow instance and instance pool operations to use template IDs omitted from template lists (#888)
- compute: honor the selected template's minimum disk size when creating instances and instance pools (#882)
- instance create: apply delete protection in the instance's zone, fixing a wrong-zone "Not Found" error when creating protected instances outside the default zone (#879)
- instance show: correctly show multiple ssh keys
- sks cluster update: fix oidc config drop (#881)

### Improvements⏎
Expand Down
13 changes: 6 additions & 7 deletions cmd/compute/instance/instance_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type InstanceShowOutput struct {
PublicIPAssignment v3.PublicIPAssignment `json:"public-ip" outputLabel:"Public IP"`
IPAddress string `json:"ip_address"`
IPv6Address string `json:"ipv6_address" outputLabel:"IPv6 Address"`
SSHKey string `json:"ssh_key"`
SSHKeys []string `json:"ssh_keys"`
DiskSize string `json:"disk_size"`
State v3.InstanceState `json:"state"`
Labels map[string]string `json:"labels"`
Expand Down Expand Up @@ -115,11 +115,6 @@ func (c *instanceShowCmd) CmdRun(cmd *cobra.Command, _ []string) error {
ipV6 = &parsed // only assign pointer if it's a valid IP
}

var sshKeyName *string
if instance.SSHKey != nil {
sshKeyName = &instance.SSHKey.Name
}

out := InstanceShowOutput{
AntiAffinityGroups: make([]string, 0),
CreationDate: instance.CreatedAT.String(),
Expand All @@ -137,7 +132,7 @@ func (c *instanceShowCmd) CmdRun(cmd *cobra.Command, _ []string) error {
}(),
Name: instance.Name,
PrivateNetworks: make([]string, 0),
SSHKey: utils.DefaultString(sshKeyName, "-"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: you can directly allocate InstanceShowOutput.SSHKeys with the size of instance.SSHKeys

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that for consistency with over zero-initialized arrays in the rest of the codebase

SSHKeys: make([]string, 0),
SecurityGroups: make([]string, 0),
SecureBoot: *instance.SecurebootEnabled,
Tpm: *instance.TpmEnabled,
Expand Down Expand Up @@ -215,6 +210,10 @@ func (c *instanceShowCmd) CmdRun(cmd *cobra.Command, _ []string) error {
}
}

for _, k := range instance.SSHKeys {
out.SSHKeys = append(out.SSHKeys, k.Name)
}

if instance.SecurityGroups != nil {
for _, sg := range instance.SecurityGroups {
resp, err := client.ListSecurityGroups(ctx)
Expand Down