Commit Graph

31 Commits

Author SHA1 Message Date
Chris Suszyński 671e679e71
Move the lib/ to public pkg/ packages 2024-06-20 19:04:08 +02:00
Chris Suszyński 51a0693a20
Skip kn subpackage 2024-06-20 18:39:01 +02:00
David Simansky b658574638
Context Sharing POC (#1855)
* WIP: Context Sharing POC

* More lazy init

* Fix imports
2023-10-20 14:37:21 +00:00
Scott Mason 8a2ed4cea3
Fixing errors related to Go 1.20 (#1779)
* 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
2023-02-17 11:07:52 +00:00
Murugappan Chetty af052088ca
remove hardcoded kn for usage and error (#1603)
* 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
2022-02-17 02:07:13 -08:00
Gunjan Vyas da6f164dbb
Remove lookup-plugins flag (#1506)
Co-authored-by: Roland Huß <roland@ro14nd.de>
2021-11-02 10:26:41 -07:00
Roland Huß 5a4496900b
Fix issue with Windows pathes not being escaped when applying a regexp. (#1395) 2021-07-21 09:22:39 -07:00
David Simansky a90595961f
Move warning handler from `main()` to `RestConfig()` (#1359)
* Move warning handler from main() to RestConfig()

* Add also original code comment
2021-06-30 07:10:10 -07:00
David Simansky ab537bc731
Improve test coverage of main package (#1357)
* Improve test coverage of main package

* Add test for internal plugin

* Rerurn codegen
2021-06-29 00:10:13 -07:00
Markus Thömmes 95dc71c631
Prettify printing of webhook warnings (#1353) 2021-06-24 07:04:46 -07:00
Markus Thömmes 9667e4551a
Enable errorlint and fix all issues (#1223)
* Correctly wrap errors everywhere

* Use errors.As and errors.Is for safe checks and casts

* Fix condition
2021-02-12 18:27:38 -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
Markus Thömmes 7d431366f5
Drop pkg/errors dependency and replace with stdlib usage (#1221) 2021-02-11 08:31:50 -08:00
Navid Shaikh 8ca5db3a37
fix: Parsing the kn commands from error message (#1175)
* 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
2021-01-14 07:29:20 -08:00
Markus Thömmes dca9561993
Fix a few more occurrences of divisive language (#1119) 2020-11-16 07:18:04 -08:00
Josh Soref 4939c5ede3
Fix various misspellings and linter items (#1057)
* spelling: additional

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: bindings

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: blocked

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: bootstrap

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: channel

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: channel

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: commands

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: comparison

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: configuration

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: controller

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: convert

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: desired

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dynamic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: entry

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: execute

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: explicit

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: hardcoded

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: information

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inject

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: item

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: kubectl

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: latest

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: message

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: namespace

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: namespaces

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: output

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overriding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameters

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: revision

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: separated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: separator

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: service

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specifies

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: splitting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subscription

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trigger

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unknown

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unstructured

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: workflow

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* chore: Address golinter complaint for (c *MockKnServingClient) GetBaseRevision

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* chore: update changelog for spelling fixes (#1057)
2020-10-12 21:24:30 -07:00
Markus Thömmes 8f7088f0c0
Add linting config and fix issues. (#1001) 2020-09-11 05:41:00 -07:00
Mike Petersen 4a3cf24550
Deprecates --max-scale/--min-scale for more consistent naming (#958)
* Depreciates --max-scale/--min-scale for more consistent naming

* Added back old flags and marked hidden
2020-08-03 16:58:27 -07:00
Navid Shaikh 8232c9d16b
Upgrade spf13/cobra dep to current master (#944)
* 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
2020-07-22 14:46:57 -07:00
Roland Huß 490fe574cc
feat: Add plugin listing to "kn --help" (#929)
* 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
2020-07-14 13:38:33 -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
Daniel Helfand 4b3b971ae5
remove use of os.Exit (#851) 2020-05-25 22:12:48 -07:00
Daniel Helfand a56afabc8a remove printing err when running root command (#615) 2020-01-21 09:58:05 -08:00
Naomi Seyfer 25c726453e Update serving dependency to 0.8; change all import paths (#368)
* 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
2019-08-15 18:09:08 -07:00
Naomi Seyfer ffe80b9f87 Specify names on service update and generate names client-side. (#282)
* 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.
2019-08-14 15:31:07 -07:00
dr.max 59b2855d04 Implements Kn plugins re-using some code from kubectl plugins. (#249)
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.
2019-07-26 13:29:48 -07:00
Kenjiro Nakayama 13ff277095 Set current namespace from kubeconfig by default (#172)
* 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
2019-06-24 11:23:05 -07:00
dr.max 0800d7c4d3 Regroups code to use subpackages. Finishes issue #66 (#145)
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.
2019-06-05 16:30:38 -07:00
Naomi Seyfer 7cc59481bb
Refactor to allow testing; write first tests. (#10)
* 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
2019-01-29 12:40:22 -08:00
Naomi Seyfer 38932b1d61
Get revision and service listing skeletons in. (#2)
* 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
2019-01-22 09:03:58 -08:00