mirror of https://github.com/knative/client.git
Renames revision 'get' to 'list' (#180)
* Renames revision 'get' to 'list' As per title. * Renames revision get references to revision list in docs
This commit is contained in:
parent
d25ea5f1e7
commit
5d26faa4ff
|
|
@ -1,6 +1,6 @@
|
||||||
# kn
|
# kn
|
||||||
|
|
||||||
`kn` is the Knative command line interface (CLI).
|
`kn` is the Knative command line interface (CLI).
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
|
@ -63,16 +63,16 @@ You can also list services from all namespaces or specific namespace using flags
|
||||||
|
|
||||||
### Revision Management
|
### Revision Management
|
||||||
|
|
||||||
A Knative revision is a "snapshot" of the specification of a service. For instance, when a Knative service is created with environment variable `FOO=bar` a revision is added to the service. When later the environment variable is changed to `baz` or additional variables are added, a new revision is created. When the image the service is running is changed to a new digest, a new revision is created.
|
A Knative revision is a "snapshot" of the specification of a service. For instance, when a Knative service is created with environment variable `FOO=bar` a revision is added to the service. When later the environment variable is changed to `baz` or additional variables are added, a new revision is created. When the image the service is running is changed to a new digest, a new revision is created.
|
||||||
|
|
||||||
With the [`revision` command group](cmd/kn_revision.md) you can list/[get](cmd/kn_revision_get.md) and [describe](cmd/kn_revision_describe.md) the current revisions on a service.
|
With the [`revision` command group](cmd/kn_revision.md) you can [list](cmd/kn_revision_list.md) and [describe](cmd/kn_revision_describe.md) the current revisions on a service.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Listing a service's revision
|
# Listing a service's revision
|
||||||
|
|
||||||
kn revision get --service srvc # CHECK this since current command does not have --service flag
|
kn revision list --service srvc # CHECK this since current command does not have --service flag
|
||||||
```
|
```
|
||||||
|
|
||||||
### Utilities
|
### Utilities
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,5 @@ Revision command group
|
||||||
|
|
||||||
* [kn](kn.md) - Knative client
|
* [kn](kn.md) - Knative client
|
||||||
* [kn revision describe](kn_revision_describe.md) - Describe revisions.
|
* [kn revision describe](kn_revision_describe.md) - Describe revisions.
|
||||||
* [kn revision get](kn_revision_get.md) - Get available revisions.
|
* [kn revision list](kn_revision_list.md) - List available revisions.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
## kn revision get
|
## kn revision list
|
||||||
|
|
||||||
Get available revisions.
|
List available revisions.
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Get available revisions.
|
List available revisions.
|
||||||
|
|
||||||
```
|
```
|
||||||
kn revision get [flags]
|
kn revision list [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
@ -15,7 +15,7 @@ kn revision get [flags]
|
||||||
```
|
```
|
||||||
--all-namespaces If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
|
--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)
|
--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.
|
-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.
|
-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].
|
--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].
|
||||||
|
|
@ -23,8 +23,8 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RevisionGetHandlers adds print handlers for revision get command
|
// RevisionListHandlers adds print handlers for revision list command
|
||||||
func RevisionGetHandlers(h hprinters.PrintHandler) {
|
func RevisionListHandlers(h hprinters.PrintHandler) {
|
||||||
RevisionColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
RevisionColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||||
{Name: "Service", Type: "string", Description: "Name of the knative service."},
|
{Name: "Service", Type: "string", Description: "Name of the knative service."},
|
||||||
{Name: "Name", Type: "string", Description: "Name of the revision."},
|
{Name: "Name", Type: "string", Description: "Name of the revision."},
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func NewRevisionCommand(p *commands.KnParams) *cobra.Command {
|
||||||
Use: "revision",
|
Use: "revision",
|
||||||
Short: "Revision command group",
|
Short: "Revision command group",
|
||||||
}
|
}
|
||||||
revisionCmd.AddCommand(NewRevisionGetCommand(p))
|
revisionCmd.AddCommand(NewRevisionListCommand(p))
|
||||||
revisionCmd.AddCommand(NewRevisionDescribeCommand(p))
|
revisionCmd.AddCommand(NewRevisionDescribeCommand(p))
|
||||||
return revisionCmd
|
return revisionCmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewRevisionGetCommand represents 'kn revision get' command
|
// NewRevisionListCommand represents 'kn revision list' command
|
||||||
func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
func NewRevisionListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
revisionGetFlags := NewRevisionGetFlags()
|
revisionListFlags := NewRevisionListFlags()
|
||||||
|
|
||||||
revisionGetCommand := &cobra.Command{
|
revisionListCommand := &cobra.Command{
|
||||||
Use: "get",
|
Use: "list",
|
||||||
Short: "Get available revisions.",
|
Short: "List available revisions.",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client, err := p.ServingFactory()
|
client, err := p.ServingFactory()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -51,7 +51,7 @@ func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
||||||
Group: "knative.dev",
|
Group: "knative.dev",
|
||||||
Version: "v1alpha1",
|
Version: "v1alpha1",
|
||||||
Kind: "revision"})
|
Kind: "revision"})
|
||||||
printer, err := revisionGetFlags.ToPrinter()
|
printer, err := revisionListFlags.ToPrinter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
commands.AddNamespaceFlags(revisionGetCommand.Flags(), true)
|
commands.AddNamespaceFlags(revisionListCommand.Flags(), true)
|
||||||
revisionGetFlags.AddFlags(revisionGetCommand)
|
revisionListFlags.AddFlags(revisionListCommand)
|
||||||
return revisionGetCommand
|
return revisionListCommand
|
||||||
}
|
}
|
||||||
|
|
@ -21,23 +21,23 @@ import (
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RevisionGetFlags composes common printer flag structs
|
// RevisionListFlags composes common printer flag structs
|
||||||
// used in the Get command.
|
// used in the List command.
|
||||||
type RevisionGetFlags struct {
|
type RevisionListFlags struct {
|
||||||
GenericPrintFlags *genericclioptions.PrintFlags
|
GenericPrintFlags *genericclioptions.PrintFlags
|
||||||
HumanReadableFlags *commands.HumanPrintFlags
|
HumanReadableFlags *commands.HumanPrintFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllowedFormats is the list of formats in which data can be displayed
|
// AllowedFormats is the list of formats in which data can be displayed
|
||||||
func (f *RevisionGetFlags) AllowedFormats() []string {
|
func (f *RevisionListFlags) AllowedFormats() []string {
|
||||||
formats := f.GenericPrintFlags.AllowedFormats()
|
formats := f.GenericPrintFlags.AllowedFormats()
|
||||||
formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
|
formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
|
||||||
return formats
|
return formats
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToPrinter attempts to find a composed set of RevisionGetFlags suitable for
|
// ToPrinter attempts to find a composed set of RevisionListFlags suitable for
|
||||||
// returning a printer based on current flag values.
|
// returning a printer based on current flag values.
|
||||||
func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
func (f *RevisionListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
||||||
// if there are flags specified for generic printing
|
// if there are flags specified for generic printing
|
||||||
if f.GenericPrintFlags.OutputFlagSpecified() {
|
if f.GenericPrintFlags.OutputFlagSpecified() {
|
||||||
p, err := f.GenericPrintFlags.ToPrinter()
|
p, err := f.GenericPrintFlags.ToPrinter()
|
||||||
|
|
@ -47,7 +47,7 @@ func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
// if no flags specified, use the table printing
|
// if no flags specified, use the table printing
|
||||||
p, err := f.HumanReadableFlags.ToPrinter(RevisionGetHandlers)
|
p, err := f.HumanReadableFlags.ToPrinter(RevisionListHandlers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -56,15 +56,15 @@ func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
||||||
|
|
||||||
// AddFlags receives a *cobra.Command reference and binds
|
// AddFlags receives a *cobra.Command reference and binds
|
||||||
// flags related to humanreadable and template printing.
|
// flags related to humanreadable and template printing.
|
||||||
func (f *RevisionGetFlags) AddFlags(cmd *cobra.Command) {
|
func (f *RevisionListFlags) AddFlags(cmd *cobra.Command) {
|
||||||
f.GenericPrintFlags.AddFlags(cmd)
|
f.GenericPrintFlags.AddFlags(cmd)
|
||||||
f.HumanReadableFlags.AddFlags(cmd)
|
f.HumanReadableFlags.AddFlags(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGetPrintFlags returns flags associated with humanreadable,
|
// NewRevisionListFlags returns flags associated with humanreadable,
|
||||||
// template, and "name" printing, with default values set.
|
// template, and "name" printing, with default values set.
|
||||||
func NewRevisionGetFlags() *RevisionGetFlags {
|
func NewRevisionListFlags() *RevisionListFlags {
|
||||||
return &RevisionGetFlags{
|
return &RevisionListFlags{
|
||||||
GenericPrintFlags: genericclioptions.NewPrintFlags(""),
|
GenericPrintFlags: genericclioptions.NewPrintFlags(""),
|
||||||
HumanReadableFlags: commands.NewHumanPrintFlags(),
|
HumanReadableFlags: commands.NewHumanPrintFlags(),
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
client_testing "k8s.io/client-go/testing"
|
client_testing "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fakeRevisionGet(args []string, response *v1alpha1.RevisionList) (action client_testing.Action, output []string, err error) {
|
func fakeRevisionList(args []string, response *v1alpha1.RevisionList) (action client_testing.Action, output []string, err error) {
|
||||||
knParams := &commands.KnParams{}
|
knParams := &commands.KnParams{}
|
||||||
cmd, fakeServing, buf := commands.CreateTestKnCommand(NewRevisionCommand(knParams), knParams)
|
cmd, fakeServing, buf := commands.CreateTestKnCommand(NewRevisionCommand(knParams), knParams)
|
||||||
fakeServing.AddReactor("*", "*",
|
fakeServing.AddReactor("*", "*",
|
||||||
|
|
@ -43,8 +43,8 @@ func fakeRevisionGet(args []string, response *v1alpha1.RevisionList) (action cli
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRevisionGetEmpty(t *testing.T) {
|
func TestRevisionListEmpty(t *testing.T) {
|
||||||
action, output, err := fakeRevisionGet([]string{"revision", "get"}, &v1alpha1.RevisionList{})
|
action, output, err := fakeRevisionList([]string{"revision", "list"}, &v1alpha1.RevisionList{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
|
@ -58,11 +58,11 @@ func TestRevisionGetEmpty(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRevisionGetDefaultOutput(t *testing.T) {
|
func TestRevisionListDefaultOutput(t *testing.T) {
|
||||||
revision1 := createMockRevisionWithParams("foo-abcd", "foo")
|
revision1 := createMockRevisionWithParams("foo-abcd", "foo")
|
||||||
revision2 := createMockRevisionWithParams("bar-wxyz", "bar")
|
revision2 := createMockRevisionWithParams("bar-wxyz", "bar")
|
||||||
RevisionList := &v1alpha1.RevisionList{Items: []v1alpha1.Revision{*revision1, *revision2}}
|
RevisionList := &v1alpha1.RevisionList{Items: []v1alpha1.Revision{*revision1, *revision2}}
|
||||||
action, output, err := fakeRevisionGet([]string{"revision", "get"}, RevisionList)
|
action, output, err := fakeRevisionList([]string{"revision", "list"}, RevisionList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue