* Fix the errors Go 1.20 introduced
* Didn't remove comments
* New version of service.go
* add linter directive to allow for use of math/rand
* Added to changelog
* fix issue with tablegenerator.go
* remove factory_test.go changes, already fixed in #1777
* Revert changelog changes
* remove hardcoded kn for usage and error
* remove hardcoded kn for usage and error
* remove hardcoded kn for usage and error
* remove hardcoded kn for usage and error
* docs change
* fix: Parsing the kn commands from error message
The error message contains pattern 'kn CMDs', thus send 'kn' string to match the pattern.
Sending `os.Args[0]` instead, may result in panics while compiling the regexp as it
may expand to the absolute path of the kn binary and the path may collide with regexp expressions.
Fixes#1172
* Add CHANGELOG
* Pin spf13/cobra dep at b95db644ed1c0e183a90d8509ef2f9a5d51cc29b
which includes the zsh completion fix for https://github.com/spf13/cobra/pull/899
and remove the fork of cobra with fix in `replace` section of go.mod
* Parse args without invoking a separate command
Do not define and execute extractCommand before running actual root
command to parse all the args without flags. This was creating issues
with completion utils to generate additional shell completion directive.
Now uses cobra's inbuilt utilities to parse the command args without flags.
* Return error from stripFlags if any
* Update unit tests
* feat: Add plugin listing to "kn --help"
This works on all levels. Test needs to be expanded still.
Fixes#266
* chore: Fix test
* Add test and ported #910 over.
* changelog update
* fix test
* Fix test
* fix integration tests
* fix test
* chore: Add some explanatory comments
* fix test
* Add grouping for help message + streamlined help messages
The top-level looks like
kn is the command line interface for managing Knative Serving and Eventing objects
Find more information about Knative at: https://knative.dev
Serving Commands:
service Manage Knative services
revision Manage service revisions
route List and show service routes
Eventing Commands:
source Manage event sources
trigger Manage event triggers
Other Commands:
plugin Manage kn plugins
completion Output shell completion code
version Show the version of this client
Use "kn <command> --help" for more information about a given command.
Use "kn options" for a list of global command-line options (applies to all commands).
The following changes have been applied:
* Add CommandGroups for grouping commands together
* Add flexible templating for the help messages
* Moved global options to an own command ('kn options', much like 'kubectl options')
* Aligned wording and typography of help messages
These features has been highly inspired by kubectl grouping & help templating but has been considerably been stripped down to the needs of kn.
Signed-off-by: Roland Huß <roland@ro14nd.de>
* chore: Add missing file
* Update pkg/templates/command_groups.go
Co-authored-by: Matt Moore <mattmoor@vmware.com>
* chore: Add some test for error messages
* fix formatting
* chore: Add test
* moar tests
* Update pkg/kn/commands/completion/completion.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/source/apiserver/delete.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/service/list.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/route/route.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/revision/delete.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/plugin/plugin.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/service/delete.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/revision/delete.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/commands/service/delete.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* regen docs
* chore: Update conventions doc
* Move some direct configuration of rootcmd to NewRootCommand()
* Moved CaptureOutput to "test" package for reuse
Co-authored-by: Matt Moore <mattmoor@vmware.com>
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Refactor main flow, plugin and configuration handling
* The plugin handling has been moved out of the `KnDefaultCommand` constructor where it was executed as a side-effect. The original code from `kubectl` suffers from the same issue that plugin handling is not a top-level concern but was very likely introduced as an after-thought. Instead, the plugin handling is done now by a `PluginManager` which is explicitly called in `main()`.
* Configuration and bootstrap option handling is centralized in the package `option`. After the bootstrap happened, the content of the configuration file, as well as any other global configuration, can be obtained from methods on `config.GlobalConfig`. Also, all flag handling is delegated to cobra so that no own parsing is needed.
* Many of the logic in `pkg/kn/commands/plugin` for plugin management has been moved up to `pkg/kn/plugin` as this code is not only relevant for `plugin list` but also for the bootstrap process.
* fix: invalid subcommands will lead to a proper error message
* Update pkg/kn/config/types.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update pkg/kn/plugin/manager.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update hack/generate-docs.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update hack/generate-docs.go
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* chore: Add missing links
* chore: recert to shas in links in developer guide for now.
Co-authored-by: Navid Shaikh <nshaikh@redhat.com>
* Update serving to 0.8. Try building.
* Find the right serving version
* Change our own import path to knative.dev to match
* Remove dependency on old version of client
* Update yaml template
* Add sleep to test to deal with race
* fix merge conflict
* Update vendor modules
* Groundwork for naming revisions automatically and deliberately
* Tests for name updates
* Add godoc comments
* Changelog entry for naming flags
* Error when trying to BYO revision name to an old-format service
* fix tests again
* Template the names
* Polsh, remove unused flags, generate helptext, add better helptext
* Decapitalize error msg
* Respond to Roland comments
* Forgot to add test file
* Be a good citizen, add more tests, try to get coverage happy.
* true dat
* Re-add implicit service prefix if one was not added.
This version contains the following:
1. wraps the main root Kn command to support plugin
2. plugins are any executable in kn's config new pluginDir
variable which defaults to $PATH
3. plugins must have name kn-*
4. 'kn plugin list' sub-command to list found kn plugins
5. skips any kn plugins found with name that match core
commands, e.g., kn-service would be ignored
6. can execute any valid kn plugins found, e.g.,
`kn valid` where the plugin file `kn-valid` is in path
specified in 2.
7. unit tests (using gotest.tools)
And is missing:
1. integration tests
2. plugin install command
3. plugin repository command
4. plugin / Knative server version negotiation
5. anything else we agree on in plugin req doc
I plan to create issues for the things missing so we don't
end up with an even bigger PR. It's already big as is but is a
good MVP as per plugins requirement doc.
* Set current namespace from kubeconfig by default
Currently kn command does not pick up namespace from kubeconfig but
hardcorded default namespace.
This patch fixes to get namespace from kubeconfig.
Fixes https://github.com/knative/client/issues/7
* Use NamespaceFactory to get current namespace
* Update unit tests
* Add nil check for ClientConfig
Creates four subpackages for now:
1. kn/commands - inludes types.go for common
struct and other common files and misc commands
2. kn/commands/service - all 'kn service *' commands
3. kn/commands/revision - all 'kn revision *' commands
4. kn/core - contains the root.go and other top level
for code and testing
5. refactors:
a. split .../commons/human_readable_flags.go into three
b. modifies the HumanReadableFlags.ToPrinter to get pass
a function that sets the columns and fields
Had to refactor all tests to avoid cycles.
* Refactor commands to allow insertion of fakes for testing
* Pin client-go to version that matches signatures other libs use
* Add tests for service list
* actually add test file
* Review comments: Fatal instead of Error/return, Split instead of read to newline
* Get revision and service listing skeletons in.
This adds the kn program, with basic commands for service and revision listing
in.
kn service list
kn revision list
They use the genericclioptions library from kubernetes to support jsonpath,
yaml, and json output. The default is to just list the names of the objects, for
now, until we add in some of the kubectl-based libraries for creating tables in
another commit.
This is deliberately bare-bones; I am looking to get the basic skeletons of how
this repository is laid out down.
No tests yet. Soon.
* Move commands to pkg, so cmd only contains minimalist main.go
* RunE instead of Run. The defaults on Cobra command generation are weird.
* Oops forgot to change types of stuff
* Do not panic on bad config file
* Make commands no longer global
* Make configuration initialization not static in the module, but rather triggered by main.go init