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` is the Knative command line interface (CLI).
|
||||
`kn` is the Knative command line interface (CLI).
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
@ -63,16 +63,16 @@ You can also list services from all namespaces or specific namespace using flags
|
|||
|
||||
### 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:
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
|
|
@ -22,5 +22,5 @@ Revision command group
|
|||
|
||||
* [kn](kn.md) - Knative client
|
||||
* [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
|
||||
|
||||
Get available revisions.
|
||||
List available revisions.
|
||||
|
||||
```
|
||||
kn revision get [flags]
|
||||
kn revision list [flags]
|
||||
```
|
||||
|
||||
### 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.
|
||||
--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].
|
|
@ -23,8 +23,8 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// RevisionGetHandlers adds print handlers for revision get command
|
||||
func RevisionGetHandlers(h hprinters.PrintHandler) {
|
||||
// RevisionListHandlers adds print handlers for revision list command
|
||||
func RevisionListHandlers(h hprinters.PrintHandler) {
|
||||
RevisionColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Service", Type: "string", Description: "Name of the knative service."},
|
||||
{Name: "Name", Type: "string", Description: "Name of the revision."},
|
||||
|
|
|
@ -24,7 +24,7 @@ func NewRevisionCommand(p *commands.KnParams) *cobra.Command {
|
|||
Use: "revision",
|
||||
Short: "Revision command group",
|
||||
}
|
||||
revisionCmd.AddCommand(NewRevisionGetCommand(p))
|
||||
revisionCmd.AddCommand(NewRevisionListCommand(p))
|
||||
revisionCmd.AddCommand(NewRevisionDescribeCommand(p))
|
||||
return revisionCmd
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// NewRevisionGetCommand represents 'kn revision get' command
|
||||
func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
||||
revisionGetFlags := NewRevisionGetFlags()
|
||||
// NewRevisionListCommand represents 'kn revision list' command
|
||||
func NewRevisionListCommand(p *commands.KnParams) *cobra.Command {
|
||||
revisionListFlags := NewRevisionListFlags()
|
||||
|
||||
revisionGetCommand := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get available revisions.",
|
||||
revisionListCommand := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List available revisions.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := p.ServingFactory()
|
||||
if err != nil {
|
||||
|
@ -51,7 +51,7 @@ func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
|||
Group: "knative.dev",
|
||||
Version: "v1alpha1",
|
||||
Kind: "revision"})
|
||||
printer, err := revisionGetFlags.ToPrinter()
|
||||
printer, err := revisionListFlags.ToPrinter()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func NewRevisionGetCommand(p *commands.KnParams) *cobra.Command {
|
|||
return nil
|
||||
},
|
||||
}
|
||||
commands.AddNamespaceFlags(revisionGetCommand.Flags(), true)
|
||||
revisionGetFlags.AddFlags(revisionGetCommand)
|
||||
return revisionGetCommand
|
||||
commands.AddNamespaceFlags(revisionListCommand.Flags(), true)
|
||||
revisionListFlags.AddFlags(revisionListCommand)
|
||||
return revisionListCommand
|
||||
}
|
|
@ -21,23 +21,23 @@ import (
|
|||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
)
|
||||
|
||||
// RevisionGetFlags composes common printer flag structs
|
||||
// used in the Get command.
|
||||
type RevisionGetFlags struct {
|
||||
// RevisionListFlags composes common printer flag structs
|
||||
// used in the List command.
|
||||
type RevisionListFlags struct {
|
||||
GenericPrintFlags *genericclioptions.PrintFlags
|
||||
HumanReadableFlags *commands.HumanPrintFlags
|
||||
}
|
||||
|
||||
// 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 = append(formats, f.HumanReadableFlags.AllowedFormats()...)
|
||||
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.
|
||||
func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
||||
func (f *RevisionListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
||||
// if there are flags specified for generic printing
|
||||
if f.GenericPrintFlags.OutputFlagSpecified() {
|
||||
p, err := f.GenericPrintFlags.ToPrinter()
|
||||
|
@ -47,7 +47,7 @@ func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
|||
return p, nil
|
||||
}
|
||||
// if no flags specified, use the table printing
|
||||
p, err := f.HumanReadableFlags.ToPrinter(RevisionGetHandlers)
|
||||
p, err := f.HumanReadableFlags.ToPrinter(RevisionListHandlers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -56,15 +56,15 @@ func (f *RevisionGetFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
|
|||
|
||||
// AddFlags receives a *cobra.Command reference and binds
|
||||
// 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.HumanReadableFlags.AddFlags(cmd)
|
||||
}
|
||||
|
||||
// NewGetPrintFlags returns flags associated with humanreadable,
|
||||
// NewRevisionListFlags returns flags associated with humanreadable,
|
||||
// template, and "name" printing, with default values set.
|
||||
func NewRevisionGetFlags() *RevisionGetFlags {
|
||||
return &RevisionGetFlags{
|
||||
func NewRevisionListFlags() *RevisionListFlags {
|
||||
return &RevisionListFlags{
|
||||
GenericPrintFlags: genericclioptions.NewPrintFlags(""),
|
||||
HumanReadableFlags: commands.NewHumanPrintFlags(),
|
||||
}
|
|
@ -26,7 +26,7 @@ import (
|
|||
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{}
|
||||
cmd, fakeServing, buf := commands.CreateTestKnCommand(NewRevisionCommand(knParams), knParams)
|
||||
fakeServing.AddReactor("*", "*",
|
||||
|
@ -43,8 +43,8 @@ func fakeRevisionGet(args []string, response *v1alpha1.RevisionList) (action cli
|
|||
return
|
||||
}
|
||||
|
||||
func TestRevisionGetEmpty(t *testing.T) {
|
||||
action, output, err := fakeRevisionGet([]string{"revision", "get"}, &v1alpha1.RevisionList{})
|
||||
func TestRevisionListEmpty(t *testing.T) {
|
||||
action, output, err := fakeRevisionList([]string{"revision", "list"}, &v1alpha1.RevisionList{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
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")
|
||||
revision2 := createMockRevisionWithParams("bar-wxyz", "bar")
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
Loading…
Reference in New Issue