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

Renames service 'get' to 'list' #179

Merged
merged 3 commits into from
Jun 13, 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
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ See the [generated documentation.](cmd/kn.md)

A Knative service is the embodiment of a serverless workload. Generally in the form of a collection of containers running in a group of pods in the underlying Kubernetes cluster. Each Knative service associates with a collection of revisions which represents the evolution of that service.

With the Kn CLI a user can list/[`get`](cmd/kn_service_get.md), [`create`](cmd/kn_service_create.md), [`delete`](cmd/kn_service_delete.md), and [`update`](cmd/kn_service_update.md) Knative services. The [detail reference](cmd/kn_service.md) of each sub-command under the [`service` command](cmd/kn_service.md) shows the options and flags for this group of commands.
With the Kn CLI a user can [`list`](cmd/kn_service_list.md), [`create`](cmd/kn_service_create.md), [`delete`](cmd/kn_service_delete.md), and [`update`](cmd/kn_service_update.md) Knative services. The [detail reference](cmd/kn_service.md) of each sub-command under the [`service` command](cmd/kn_service.md) shows the options and flags for this group of commands.

Examples:

Expand All @@ -56,10 +56,10 @@ You are able to also specify the requests and limits of both CPU and memory when
```bash
# List existing services in the 'default' namespace of your cluster

kn service get
kn service list
```

You can also list services from all namespaces or specific namespace using flags: `--all-namespaces` and `--namespace mynamespace`. See [`service get` command](cmd/kn_service_get.md) reference for additional details.
You can also list services from all namespaces or specific namespace using flags: `--all-namespaces` and `--namespace mynamespace`. See [`service list` command](cmd/kn_service_list.md) reference for additional details.

### Revision Management

Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Service command group
* [kn service create](kn_service_create.md) - Create a service.
* [kn service delete](kn_service_delete.md) - Delete a service.
* [kn service describe](kn_service_describe.md) - Describe available services.
* [kn service get](kn_service_get.md) - Get available services.
* [kn service list](kn_service_list.md) - List available services.
* [kn service update](kn_service_update.md) - Update a service.

10 changes: 5 additions & 5 deletions docs/cmd/kn_service_get.md → docs/cmd/kn_service_list.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## kn service get
## kn service list

Get available services.
List available services.

### Synopsis

Get available services.
List available services.

```
kn service get [flags]
kn service list [flags]
```

### Options

```
--all-namespaces If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for get
-h, --help help for list
-n, --namespace string List the requested object(s) in given namespace.
-o, --output string Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
Expand Down
8 changes: 4 additions & 4 deletions docs/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ kn service create hello --image gcr.io/knative-samples/helloworld-go --env TARGE
Service 'hello' successfully created in namespace 'default'.
```

* **Get service**
* **List service**

```bash
kn service get hello
kn service list hello
NAME DOMAIN GENERATION AGE CONDITIONS READY REASON
hello hello.default.example.com 1 3m5s 3 OK / 3 True
```
Expand Down Expand Up @@ -98,9 +98,9 @@ kn service delete hello
Service 'hello' successfully deleted in namespace 'default'.
```

You can then verify that the 'hello' service is deleted by trying to `get` it again.
You can then verify that the 'hello' service is deleted by trying to `list` it again.

```bash
kn service get hello
kn service list hello
No resources found.
```
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ require (
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.3.1 // indirect
github.com/stretchr/objx v0.2.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/net v0.0.0-20190514140710-3ec191127204 // indirect
golang.org/x/oauth2 v0.0.0-20190517181255-950ef44c6e07 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
Expand All @@ -252,10 +253,14 @@ go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
4 changes: 2 additions & 2 deletions pkg/kn/commands/service/human_readable_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

// ServiceGetHandlers adds print handlers for service get command
func ServiceGetHandlers(h hprinters.PrintHandler) {
// ServiceListHandlers adds print handlers for service list command
func ServiceListHandlers(h hprinters.PrintHandler) {
kServiceColumnDefinitions := []metav1beta1.TableColumnDefinition{
{Name: "Name", Type: "string", Description: "Name of the knative service."},
{Name: "Domain", Type: "string", Description: "Domain name of the knative service."},
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewServiceCommand(p *commands.KnParams) *cobra.Command {
Use: "service",
Short: "Service command group",
}
serviceCmd.AddCommand(NewServiceGetCommand(p))
serviceCmd.AddCommand(NewServiceListCommand(p))
serviceCmd.AddCommand(NewServiceDescribeCommand(p))
serviceCmd.AddCommand(NewServiceCreateCommand(p))
serviceCmd.AddCommand(NewServiceDeleteCommand(p))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// NewServiceGetCommand represents 'kn service get' command
func NewServiceGetCommand(p *commands.KnParams) *cobra.Command {
serviceGetFlags := NewServiceGetFlags()
// NewServiceListCommand represents 'kn service list' command
func NewServiceListCommand(p *commands.KnParams) *cobra.Command {
serviceListFlags := NewServiceListFlags()

serviceGetCommand := &cobra.Command{
Use: "get",
Short: "Get available services.",
serviceListCommand := &cobra.Command{
Use: "list",
Short: "List available services.",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := p.ServingFactory()
if err != nil {
Expand All @@ -52,7 +52,7 @@ func NewServiceGetCommand(p *commands.KnParams) *cobra.Command {
Version: "v1alpha1",
Kind: "Service"})

printer, err := serviceGetFlags.ToPrinter()
printer, err := serviceListFlags.ToPrinter()
if err != nil {
return err
}
Expand All @@ -64,7 +64,7 @@ func NewServiceGetCommand(p *commands.KnParams) *cobra.Command {
return nil
},
}
commands.AddNamespaceFlags(serviceGetCommand.Flags(), true)
serviceGetFlags.AddFlags(serviceGetCommand)
return serviceGetCommand
commands.AddNamespaceFlags(serviceListCommand.Flags(), true)
serviceListFlags.AddFlags(serviceListCommand)
return serviceListCommand
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
)

// ServiceGetFlags composes common printer flag structs
// used in the Get command.
type ServiceGetFlags struct {
// ServiceListFlags composes common printer flag structs
// used in the 'kn service list' command.
type ServiceListFlags struct {
GenericPrintFlags *genericclioptions.PrintFlags
HumanReadableFlags *commands.HumanPrintFlags
}

// AllowedFormats is the list of formats in which data can be displayed
func (f *ServiceGetFlags) AllowedFormats() []string {
func (f *ServiceListFlags) AllowedFormats() []string {
formats := f.GenericPrintFlags.AllowedFormats()
formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
return formats
}

// ToPrinter attempts to find a composed set of ServiceGetFlags suitable for
// ToPrinter attempts to find a composed set of ServiceListFlags suitable for
// returning a printer based on current flag values.
func (f *ServiceGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
func (f *ServiceListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
// if there are flags specified for generic printing
if f.GenericPrintFlags.OutputFlagSpecified() {
p, err := f.GenericPrintFlags.ToPrinter()
Expand All @@ -47,7 +47,7 @@ func (f *ServiceGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
return p, nil
}
// if no flags specified, use the table printing
p, err := f.HumanReadableFlags.ToPrinter(ServiceGetHandlers)
p, err := f.HumanReadableFlags.ToPrinter(ServiceListHandlers)
if err != nil {
return nil, err
}
Expand All @@ -56,15 +56,15 @@ func (f *ServiceGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {

// AddFlags receives a *cobra.Command reference and binds
// flags related to humanreadable and template printing.
func (f *ServiceGetFlags) AddFlags(cmd *cobra.Command) {
func (f *ServiceListFlags) AddFlags(cmd *cobra.Command) {
f.GenericPrintFlags.AddFlags(cmd)
f.HumanReadableFlags.AddFlags(cmd)
}

// NewGetPrintFlags returns flags associated with humanreadable,
// NewServiceListFlags returns flags associated with humanreadable,
// template, and "name" printing, with default values set.
func NewServiceGetFlags() *ServiceGetFlags {
return &ServiceGetFlags{
func NewServiceListFlags() *ServiceListFlags {
return &ServiceListFlags{
GenericPrintFlags: genericclioptions.NewPrintFlags(""),
HumanReadableFlags: commands.NewHumanPrintFlags(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
client_testing "k8s.io/client-go/testing"
)

func fakeServiceGet(args []string, response *v1alpha1.ServiceList) (action client_testing.Action, output []string, err error) {
func fakeServiceList(args []string, response *v1alpha1.ServiceList) (action client_testing.Action, output []string, err error) {
knParams := &commands.KnParams{}
cmd, fakeServing, buf := commands.CreateTestKnCommand(NewServiceCommand(knParams), knParams)
fakeServing.AddReactor("*", "*",
Expand All @@ -43,8 +43,8 @@ func fakeServiceGet(args []string, response *v1alpha1.ServiceList) (action clien
return
}

func TestGetEmpty(t *testing.T) {
action, output, err := fakeServiceGet([]string{"service", "get"}, &v1alpha1.ServiceList{})
func TestListEmpty(t *testing.T) {
action, output, err := fakeServiceList([]string{"service", "list"}, &v1alpha1.ServiceList{})
if err != nil {
t.Error(err)
return
Expand All @@ -58,11 +58,11 @@ func TestGetEmpty(t *testing.T) {
}
}

func TestServiceGetDefaultOutput(t *testing.T) {
func TestServiceListDefaultOutput(t *testing.T) {
service1 := createMockServiceWithParams("foo", "foo.default.example.com", 1)
service2 := createMockServiceWithParams("bar", "bar.default.example.com", 2)
serviceList := &v1alpha1.ServiceList{Items: []v1alpha1.Service{*service1, *service2}}
action, output, err := fakeServiceGet([]string{"service", "get"}, serviceList)
action, output, err := fakeServiceList([]string{"service", "list"}, serviceList)
if err != nil {
t.Fatal(err)
}
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/basic_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ func TestBasicWorkflow(t *testing.T) {
teardown := Setup(t)
defer teardown(t)

testServiceGetEmpty(t, k)
testServiceListEmpty(t, k)
testServiceCreate(t, k, "hello")
testServiceGet(t, k, "hello")
testServiceList(t, k, "hello")
testServiceDescribe(t, k, "hello")
testServiceDelete(t, k, "hello")
testServiceGetEmpty(t, k)
testServiceListEmpty(t, k)
}

// Private test functions

func testServiceGetEmpty(t *testing.T, k kn) {
out, err := k.RunWithOpts([]string{"service", "get"}, runOpts{NoNamespace: false})
func testServiceListEmpty(t *testing.T, k kn) {
out, err := k.RunWithOpts([]string{"service", "list"}, runOpts{NoNamespace: false})
if err != nil {
t.Fatalf(fmt.Sprintf("Error executing 'kn service get' command. Error: %s", err.Error()))
t.Fatalf(fmt.Sprintf("Error executing 'kn service list' command. Error: %s", err.Error()))
}

if !strings.Contains(out, "No resources found.") {
Expand All @@ -80,10 +80,10 @@ func testServiceCreate(t *testing.T, k kn, serviceName string) {
}
}

func testServiceGet(t *testing.T, k kn, serviceName string) {
out, err := k.RunWithOpts([]string{"service", "get", serviceName}, runOpts{NoNamespace: false})
func testServiceList(t *testing.T, k kn, serviceName string) {
out, err := k.RunWithOpts([]string{"service", "list", serviceName}, runOpts{NoNamespace: false})
if err != nil {
t.Fatalf(fmt.Sprintf("Error executing 'kn service get %s' command. Error: %s", serviceName, err.Error()))
t.Fatalf(fmt.Sprintf("Error executing 'kn service list %s' command. Error: %s", serviceName, err.Error()))
}

expectedOutput := fmt.Sprintf("%s", serviceName)
Expand Down