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

Rename list instances to get instances #258

Merged
merged 2 commits into from
May 23, 2019
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
12 changes: 6 additions & 6 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This document demonstrates how to use the CLI but also shows what happens in `KU
* [Install just the KUDO Package without Dependencies](#install-just-the-kudo-package-without-dependencies)
* [Install a KUDO Package with Dependencies](#install-a-kudo-package-with-dependencies)
* [Install a Package with InstanceName & Parameters](#install-a-package-with-instancename--parameters)
* [List Instances](#list-instances)
* [Get Instances](#get-instances)
* [Get the Status of an Instance](#get-the-status-of-an-instance)
* [Get the History to PlanExecutions](#get-the-history-to-planexecutions)

Expand All @@ -49,7 +49,7 @@ Install the plugin from your `$GOPATH/src/github.com/kudobuilder/kudo` root fold
| Syntax | Description |
|---|---|
| `kubectl kudo install <name> [flags]` | Installs a Framework from the official [KUDO repo](https://github.com/kudobuilder/frameworks). |
| `kubectl kudo list instances [flags]` | Show all available instances. |
| `kubectl kudo get instances [flags]` | Show all available instances. |
| `kubectl kudo plan status [flags]` | View all available plans. |
| `kubectl kudo plan history <name> [flags]` | View all available plans. |
| `kubectl kudo version` | Print the current KUDO package version. |
Expand Down Expand Up @@ -128,17 +128,17 @@ NAME AGE
my-kafka-name 6s
```

### List Instances
### Get Instances

In order to inspect instances deployed by `KUDO`, we can get an overview of all instances running by using the `list`
In order to inspect instances deployed by `KUDO`, we can get an overview of all instances running by using the `get`
command. This command has subcommands to filter its result:

`kubectl kudo list instances --namespace=<default> --kubeconfig=<$HOME/.kube/config>`
`kubectl kudo get instances --namespace=<default> --kubeconfig=<$HOME/.kube/config>`

Example:

```bash
$ kubectl kudo list instances
$ kubectl kudo get instances
List of current instances in namespace "default":
.
├── small
Expand Down
19 changes: 19 additions & 0 deletions pkg/kudoctl/cmd/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/kudobuilder/kudo/pkg/kudoctl/cmd/get"
"github.com/spf13/cobra"
)

// NewGetCmd creates a new command that lists instances
func NewGetCmd() *cobra.Command {
newCmd := &cobra.Command{
Use: "get",
Short: "-> Show all available instances.",
Long: `The get command has subcommands to show all available instances.`,
}

newCmd.AddCommand(get.NewGetInstancesCmd())

return newCmd
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package list
package get

import (
"encoding/json"
Expand Down Expand Up @@ -28,24 +28,24 @@ const (
defaultConfigPath = ".kube/config"
)

// NewListInstancesCmd creates a command that lists the instances in the cluster
func NewListInstancesCmd() *cobra.Command {
listCmd := &cobra.Command{
// NewGetInstancesCmd creates a command that lists the instances in the cluster
func NewGetInstancesCmd() *cobra.Command {
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand why there are two commands, one in pkg and one in cmd. Which one is actually run? What's the purpose of the other one. This all isn't necessary for this PR though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Intellij must have done this somehow during refactoring. I definitely did not move any code around by myself... let me retry once more :)

Copy link
Member

Choose a reason for hiding this comment

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

Think you're ok, the one under pkg/kudoctl/cmd has been there a while. We may want to move the functionality of listing instances out to it's own package and not have cobra details inside of pkg/kudoctl/cmd - but like @runyontr said, that's another PR.

getCmd := &cobra.Command{
Use: "instances",
Short: "Lists all available instances.",
Short: "Gets all available instances.",
Long: `
# List all available instances
kudoctl list instances`,
Run: instancesListCmd,
# Get all available instances
kudoctl get instances`,
Run: instancesGetCmd,
}

listCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "The file path to kubernetes configuration file; defaults to $HOME/.kube/config")
listCmd.Flags().StringVar(&namespace, "namespace", "default", "The namespace where the operator watches for changes.")
getCmd.Flags().StringVar(&kubeConfig, "kubeconfig", "", "The file path to kubernetes configuration file; defaults to $HOME/.kube/config")
getCmd.Flags().StringVar(&namespace, "namespace", "default", "The namespace where the operator watches for changes.")

return listCmd
return getCmd
}

func instancesListCmd(cmd *cobra.Command, args []string) {
func instancesGetCmd(cmd *cobra.Command, args []string) {

mustKubeConfig()

Expand All @@ -54,7 +54,7 @@ func instancesListCmd(cmd *cobra.Command, args []string) {
log.Printf("Flag Error: %v", err)
}

p, err := listInstances()
p, err := getInstances()
if err != nil {
log.Printf("Error: %v", err)
}
Expand All @@ -68,7 +68,7 @@ func instancesListCmd(cmd *cobra.Command, args []string) {

}

func listInstances() ([]string, error) {
func getInstances() ([]string, error) {

instanceList := make([]string, 0)

Expand Down
19 changes: 0 additions & 19 deletions pkg/kudoctl/cmd/list.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/kudoctl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ and serves as an API aggregation layer.
# View all plan history of a specific package
kubectl kudo plan history [flags]

# List instances
kubectl kudo list instances [flags]
# Get instances
kubectl kudo get instances [flags]

# View plan status
kubectl kudo plan status [flags]
Expand All @@ -39,7 +39,7 @@ and serves as an API aggregation layer.
}

cmd.AddCommand(NewInstallCmd())
cmd.AddCommand(NewListCmd())
cmd.AddCommand(NewGetCmd())
cmd.AddCommand(NewPlanCmd())
cmd.AddCommand(NewVersionCmd())

Expand Down