Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new vke calls #181

Merged
merged 3 commits into from
Aug 31, 2021
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Available Commands:
firewall firewall is used to access firewall commands
help Help about any command
iso iso is used to access iso commands
kubernetes kubernetes is used to access kubernetes commands
load-balancer load balancer commands
network network interacts with network actions
object-storage object storage commands
Expand Down
56 changes: 55 additions & 1 deletion cmd/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ var (
vultr-cli k d ffd31f18-5f77-454c-9065-212f942c3c35'
`

deleteWithResourcesLong = `Delete a specific kubernetes cluster and all linked load balancers and block storages off your Vultr Account`
deleteWithResourcesExample = `
# Full example
vultr-cli kubernetes delete-with-resources ffd31f18-5f77-454c-9065-212f942c3c35
`

getConfigLong = `Returns a base64 encoded config of a specified kubernetes cluster on your Vultr Account`
getConfigExample = `
# Full example
Expand All @@ -91,6 +97,15 @@ var (
vultr-cli k config ffd31f18-5f77-454c-9065-212f942c3c35'
`

getVersionsLong = `Returns a list of supported kubernetes versions you can deploy`
getVersionsExample = `
# Full example
vultr-cli kubernetes versions

# Shortened with alias commands
vultr-cli k v'
`

nodepoolLong = `Get all available commands for Kubernetes node pools`
nodepoolExample = `
# Full example
Expand Down Expand Up @@ -185,7 +200,7 @@ func Kubernetes() *cobra.Command {
Example: kubernetesExample,
}

kubernetesCmd.AddCommand(k8Create, k8Get, k8List, k8GetConfig, k8Update, k8Delete)
kubernetesCmd.AddCommand(k8Create, k8Get, k8List, k8GetConfig, k8Update, k8Delete, k8DeleteWithResources, k8GetVersions)
k8Create.Flags().StringP("label", "l", "", "label for your kubernetes cluster")
k8Create.Flags().StringP("region", "r", "", "region you want your kubernetes cluster to be located in")
k8Create.Flags().StringP("version", "v", "", "the kubernetes version you want for your cluster")
Expand Down Expand Up @@ -371,6 +386,28 @@ var k8Delete = &cobra.Command{
},
}

var k8DeleteWithResources = &cobra.Command{
Use: "delete-with-resources <clusterID>",
Short: "delete a kubernetes cluster and related resources",
Long: deleteWithResourcesLong,
Example: deleteWithResourcesExample,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("please provide a clusterID")
}
return nil
},
Run: func(cmd *cobra.Command, args []string) {
id := args[0]
if err := client.Kubernetes.DeleteClusterWithResources(context.Background(), id); err != nil {
fmt.Printf("error deleting kubernetes cluster : %v\n", err)
os.Exit(1)
}

fmt.Println("kubernetes cluster and related resources have been deleted")
},
}

var k8GetConfig = &cobra.Command{
Use: "config <clusterID>",
Short: "gets a kubernetes cluster's config",
Expand All @@ -394,6 +431,23 @@ var k8GetConfig = &cobra.Command{
},
}

var k8GetVersions = &cobra.Command{
Use: "versions",
Short: "gets supported kubernetes versions",
Long: getVersionsLong,
Example: getVersionsExample,
Aliases: []string{"v"},
Run: func(cmd *cobra.Command, args []string) {
versions, err := client.Kubernetes.GetVersions(context.Background())
if err != nil {
fmt.Printf("error retrieving supported versions : %v\n", err)
os.Exit(1)
}

printer.K8Versions(versions)
},
}

var npCreate = &cobra.Command{
Use: "create <clusterID>",
Short: "creates a node pool in a kubernetes cluster",
Expand Down
9 changes: 9 additions & 0 deletions cmd/printer/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,12 @@ func NodePool(np *govultr.NodePool) {

flush()
}

func K8Versions(versions *govultr.Versions) {
display(columns{"VERSIONS"})
for _, v := range versions.Versions {
display(columns{v})
}

flush()
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1
github.com/vultr/govultr/v2 v2.8.0
github.com/vultr/govultr/v2 v2.8.1
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/vultr/govultr/v2 v2.8.0 h1:7wYAjmhkoP8svMVrv6L6VXwzGAdBj8tZv+4293FF/W4=
github.com/vultr/govultr/v2 v2.8.0/go.mod h1:BvOhVe6/ZpjwcoL6/unkdQshmbS9VGbowI4QT+3DGVU=
github.com/vultr/govultr/v2 v2.8.1 h1:AjRcJWfTfb4DidRNCeojUIgLVC5XShuc5IAW99K3wHU=
github.com/vultr/govultr/v2 v2.8.1/go.mod h1:JjUljQdSZx+MELCAJvZ/JH32bJotmflnsyS0NOjb8Jg=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/vultr/govultr/v2/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/vultr/govultr/v2/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/vultr/govultr/v2/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions vendor/github.com/vultr/govultr/v2/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/vultr/govultr/v2/govultr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions vendor/github.com/vultr/govultr/v2/kubernetes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ github.com/spf13/pflag
github.com/spf13/viper
# github.com/subosito/gotenv v1.2.0
github.com/subosito/gotenv
# github.com/vultr/govultr/v2 v2.8.0
# github.com/vultr/govultr/v2 v2.8.1
## explicit
github.com/vultr/govultr/v2
# golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
Expand Down