-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(primary-ip): make set-rdns consistent with other commands (#686
) Since hetznercloud/hcloud-go@41a4c5a Primary IPs support the RDNSSupporter interface, so the `base.SetRdnsCmd` can be used for Primary IPs to make them consistent with other subcommands. Co-authored-by: pauhull <[email protected]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package primaryip | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/hetznercloud/cli/internal/cmd/base" | ||
"github.com/hetznercloud/cli/internal/hcapi2" | ||
"github.com/hetznercloud/cli/internal/state" | ||
"github.com/hetznercloud/hcloud-go/v2/hcloud" | ||
) | ||
|
||
var SetRDNSCmd = base.SetRdnsCmd{ | ||
ResourceNameSingular: "Primary IP", | ||
ShortDescription: "Change reverse DNS of a Primary IP", | ||
NameSuggestions: func(c hcapi2.Client) func() []string { return c.PrimaryIP().Names }, | ||
Fetch: func(s state.State, cmd *cobra.Command, idOrName string) (interface{}, *hcloud.Response, error) { | ||
return s.Client().PrimaryIP().Get(s, idOrName) | ||
}, | ||
GetDefaultIP: func(resource interface{}) net.IP { | ||
primaryIP := resource.(*hcloud.PrimaryIP) | ||
return primaryIP.IP | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters