Skip to content

Commit

Permalink
feat(server): remove unsupported linux32 rescue type (#679)
Browse files Browse the repository at this point in the history
The `linux32` rescue type has been removed and is now unsupported ([See
docs](https://docs.hetzner.cloud/changelog#2024-01-08-server-action-enable-rescue-no-longer-supports-32bit)).
This PR removes it from suggestions and also checks for the passed type
to be valid before sending an API request (like how it's done with other
enums).

Co-authored-by: pauhull <22707808+pauhull@users.noreply.github.com>
  • Loading branch information
phm07 and phm07 authored Jan 24, 2024
1 parent c5e3f00 commit 5bb0350
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/cmd/server/enable_rescue.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var EnableRescueCmd = base.Cmd{
DisableFlagsInUseLine: true,
}
cmd.Flags().String("type", "linux64", "Rescue type")
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("linux64", "linux32"))
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("linux64"))

cmd.Flags().StringSlice("ssh-key", nil, "ID or name of SSH key to inject (can be specified multiple times)")
cmd.RegisterFlagCompletionFunc("ssh-key", cmpl.SuggestCandidatesF(client.SSHKey().Names))
Expand All @@ -43,7 +43,16 @@ var EnableRescueCmd = base.Cmd{
opts hcloud.ServerEnableRescueOpts
)
rescueType, _ := cmd.Flags().GetString("type")

opts.Type = hcloud.ServerRescueType(rescueType)
switch opts.Type {
case hcloud.ServerRescueTypeLinux64:
break
case hcloud.ServerRescueTypeLinux32:
return fmt.Errorf("rescue type not supported anymore: %s", opts.Type)
default:
return fmt.Errorf("invalid rescue type: %s", opts.Type)
}

sshKeys, _ := cmd.Flags().GetStringSlice("ssh-key")
for _, sshKeyIDOrName := range sshKeys {
Expand Down

0 comments on commit 5bb0350

Please sign in to comment.