Commit Graph

17 Commits

Author SHA1 Message Date
Amir Alavi 0382c171d7
cli options to enable user, uid, and group impersonation (#1745)
* cli options to enable kubernetes user and group impersonation

Signed-off-by: Amir Alavi <amiralavi7@gmail.com>

* cli option to enable uid impersonation

Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
2022-10-13 13:11:53 +00:00
David Simansky 671ee229f3
feat: Add `--context` flag to choose specific context from kubeconfig (#1234)
* feat: Add  flag to choose specific context from kubeconfig

* chore: Generate docs

* chore: Add changelog entry

* fix: Review feedback

Co-authored-by: Roland Huß <rhuss@redhat.com>

* chore: Add --cluster flag to specify cluster from kubeconfig

* chore: Generate docs

* chore: Update changelog

Co-authored-by: Roland Huß <rhuss@redhat.com>
2021-02-23 00:54:46 -08:00
Markus Thömmes d647e44938
Upgrade a few assorted dependencies (#1220)
* Update spf13 deps

* Upgrade gotest.tools and correctly use versioned module

* Regenerate docs
2021-02-12 05:55:50 -08:00
Ying Chun Guo 45162fb5d8
Add command group for ContainerSource (#1016)
* add container source create and delete

* add update and list commands

* add describe command

* add e2e test

* add more tests

* changes to address review comments
2020-12-02 05:56:51 -08:00
Daniel Helfand 9931c2d07a
add aliases to help command and remove aliases in short (#1055) 2020-10-09 00:09:21 -07:00
Arghya Sadhu 5025137f5a
add alias to commands (#1041) 2020-10-06 03:57:21 -07:00
Roland Huß b916a5b3ed
Add grouping for help message + streamlined help messages (#887)
* 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>
2020-06-18 00:06:25 -07:00
Roland Huß c7426459be
Refactor main flow and introduce explicit plugin and config handling (#877)
* 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>
2020-06-15 09:15:24 -07:00
Navid Shaikh ba7e14c807
feat(source): Add 'kn source list' (#666)
* feat(source): Add 'kn source list'

 Fixes #480
 - Add 'kn source list' listing the available sources COs
 - Use dynamic client to
       - find out available source types
       - find the COs in given namespace for each source type
 - Add --type flag to filter source list based on source type
 - Add unit tests
 - Add e2e tests
 - Add CHANGELOG entry

* Update group for ApiServerSource in tests

* Add kn duck source type for holding common eventing source fileds

 - Common infromation from sources are extracted into a struct
   for source list command output
 - Printer function picks the information from this struct object
   and doesn't know the details about extracting this info from multiple
   types of sources received
 - Group and Version for list is set to empty string and Kind to 'List',
   if printed a source list with multiple types of sources in machine readable
   format
 - Group, Version and Kind for list are kept intact if printed a source list
   with same type of source objects in machine readable format

* Update go.sum

* Add WithType builder for listing source

 - Separate the flags definition
 - WithType builder can be re-used to filter the source types
 - Add unit tests

* Update ApiServer source group to apiserversources.sources.knative.dev

* Fix typos and align

Co-authored-by: Roland Huß <roland@ro14nd.de>
2020-03-10 00:41:28 -07:00
Navid Shaikh 21ce981963
fix(docs): Revert markdown changes for cobra's auto-docs (#715)
Revert sub-set of changes from https://github.com/knative/client/pull/710 which
 are auto-generated by cobra.
2020-03-09 09:58:29 -07:00
Matt Moore f9ccf36518
Format markdown (#710)
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
/assign maximilien rhuss
/cc maximilien rhuss
2020-03-09 09:19:28 -07:00
Roland Huß 46d5e60e42
refactor(source): Update to Knative eventing 0.13.0 (#705)
* chore(e2e): Optimized tests

Smoke Tests now run before the E2E tests, but in the same cluster

* chore: Removed unneeded test

* fix

* fix

* fix

* fix

* chore: Update to serving & eventing v0.13.0

* refactor(source): Update to Knative eventing 0.13.0

* Moved to "sources.knative.dev" API group
* Replaced CronJobSource with PingSource (and removed unsupported options for service account, requests limits)
* Move to versions:
  - SinkBinding v1alpha2
  - PingSource v1alpha2
  - ApiServerSource v1alpha1

* update to eventing 0.13.1

* go.sum fix

* fixed test

* test updates

* try to enhance error output

* fix test.

* update tests infra to 0.13.1
2020-03-06 13:47:27 -08:00
David Simansky 034a9b387e
feat(XDG home): use XDG_CONFIG_HOME as default config location (#668)
* feat(XDG home): use XDG_CONFIG_HOME as default config location

* fix: typo in comment

* feat(XDG home): update readme and usage strings
2020-02-28 06:24:51 -08:00
Roland Huß 164cb5f362
feature(source binding): Support for Sink Binding as source (#625)
* feature(source binding): Support for Sink Binding as source

Sink bindings are managed like any other source. Sinks are specified as usual (with prefix and name),
'subjects' (the other end of the binding) is managed via a shortcut notation:

* with name: `<kind>:<apiVersion>:<name>`
* with label selector: `<kind>:<apiVersion>:key1=value1,key2=value2`

With `--subject-namespace` and additional namespace can be provided (shoudl be possible for a sink, too but is not yet)

The implementation already uses the new sink binding from the `sources.knative.dev` group
and hence is a bit inconsistent to the still old usage kf `sources.eventing.knative.dev` for apiserver source and cronjob.

However as we will move over to `sources.knative.dev` very soon (right after v0.12.0) release,
this is was more appropriates.

Still WIP, but eventually fixes #624

Task list:

- [X] create
- [] update
- [] delete
- [] describe
- [] list

* fix(source binding): Added missing commands

Also, it looks like that knative eventing 0.12.0 is still on the old api group.
So I need to move this code to use the legacyclient, too, for the sink binding
and only switch over to the new client for 0.13.0

* feature(source binding): Added missing subcommands

* update
* delete
* list
* describe

* fix(source binding): Removed --subject-namespace as this namespace cant b set.

Tuned describe output a bit.

* feat(source binding) add support for CeOverride

* fix: Worked on review comments

* fix: review comments

* fix: names in binding client
2020-01-29 12:08:27 -08:00
Roland Huß 0ca6f14d4a feature(source cronjobs): Implementation of CronJobSource management (#542)
* feature(source cronjobs): Implementation of CronJobSource management

Contains create/delete/update/describe but not tests yet.

Still todo:

* Think how to provide a namespace for the sink
* Support for more sinks
* Synchronous mode for create & update
* Add list (or implement "source list")

* chore: Add a mock test for cronjob source

* addd missing license headers

* cosmetic changes

* chore(cronjobsource): Add tests

* fixup

* chore(cronjob source): Improved test coverage

* chore(cronjob source): some review polishing
2019-12-13 01:27:53 -08:00
Navid Shaikh 7dbb5a5bb0 kn source list-types (builtin types) (#536)
* feat: kn source list-types (builtin types)

 - Only lists the builtin source types
 - Uses client-go dynamic client for listing CRDs
 - Adds DyanmicClient interface to KnParams
 - Adds printing options

* chore(lint): Address golint suggestions

* Rebase and update venodr/modules.txt

* Adds unit tests for DynamicClient in types.go

* Add kn source list-types command in smoke tests

* Constants for the CRD GVR and source identifier label key value

 GVR as:
   - Group: apiextensions.k8s.io
   - Version: v1beta1
   - Resource: customresourcedefinitions
 Label as:
   {"duck.knative.dev/source": "true"}

* Add tests for dynamic client

* Add description about SinkBinding source type

  as - "Binding Pattern for ContainerSource"

* Remove unused imports

* Adds unit tests for list-types command processing

* More unit tests for flags

* Adds e2e tests for kn source list-types

  - also test the YAML output

* Sort the source types while listing them

 - Update the unit tests accordingly

* Add examples

* Add unit tests for CreateDynamicTestKnCommand

* Fix typo in unit tests

* golint fixes

* Updates to vendor/modules.txt after rebase

* Remove the extra lines
2019-12-10 11:20:47 -08:00
Ying Chun Guo 003dba3616 Add creating ApiServerSource event source to Client (#415) 2019-12-10 03:52:46 -08:00