-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kn source apiserver list command
- Loading branch information
1 parent
3a6b05d
commit 6ae5812
Showing
11 changed files
with
355 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## kn source apiserver list | ||
|
||
List ApiServer sources. | ||
|
||
### Synopsis | ||
|
||
List ApiServer sources. | ||
|
||
``` | ||
kn source apiserver list [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# List all ApiServer sources in YAML format | ||
kn source apiserver list -o yaml | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-A, --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 list | ||
-n, --namespace string Specify the namespace to operate in. | ||
--no-headers When using the default output format, don't print headers (default: print headers). | ||
-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]. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string kn config file (default is $HOME/.kn/config.yaml) | ||
--kubeconfig string kubectl config file (default is $HOME/.kube/config) | ||
--log-http log http traffic | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn source apiserver](kn_source_apiserver.md) - Kubernetes API Server Event Source command group | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright © 2019 The Knative Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package apiserver | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"knative.dev/client/pkg/kn/commands" | ||
"knative.dev/client/pkg/kn/commands/flags" | ||
) | ||
|
||
// NewAPIServerListCommand is for listing ApiServer source COs | ||
func NewAPIServerListCommand(p *commands.KnParams) *cobra.Command { | ||
listFlags := flags.NewListFlags(APIServerSourceListHandlers) | ||
|
||
listCommand := &cobra.Command{ | ||
Use: "list", | ||
Short: "List ApiServer sources.", | ||
Example: ` | ||
# List all ApiServer sources in YAML format | ||
kn source apiserver list -o yaml`, | ||
|
||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
// TODO: filter list by given source name | ||
|
||
apiSourceClient, err := newAPIServerSourceClient(p, cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sourceList, err := apiSourceClient.ListAPIServerSource() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(sourceList.Items) == 0 { | ||
fmt.Fprintf(cmd.OutOrStdout(), "No ApiServer source found.\n") | ||
return nil | ||
} | ||
|
||
if apiSourceClient.Namespace() == "" { | ||
listFlags.EnsureWithNamespace() | ||
} | ||
|
||
printer, err := listFlags.ToPrinter() | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
err = printer.PrintObj(sourceList, cmd.OutOrStdout()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
commands.AddNamespaceFlags(listCommand.Flags(), true) | ||
listFlags.AddFlags(listCommand) | ||
return listCommand | ||
} |
Oops, something went wrong.