For the sake of consistency with out own service commands and for kubectl,
`kn plugin list` should print:
```
No plugins found.
```
`kn service list` should print:
```
No services found.
```
and not `No resources found.` like it does now.
Same for `kn routes list`.
* Make `kn service list --all-namespace` print namespace column
`kn service list` should print NAMESPACE column when specifying `--all-namespace` option, which follows the kubectl convention.
* Put services in default namespace at the top of the list
* Switch output of column definitions by priority field
A priority field is handled as follows:
- priority 0: print namespace column
- priority 1: print default columns
- priority 2: print additional columns for wide option
* Don't use AddFlags to bind all namespaces flag
* Update CHANGELOG
* Remove commented codes
* Fix import path
* Clean up
* Remove unnecessary return
* Swap the order of records
- Use `./hack/build.sh -x` or `./hack/build.sh --build-cross`
- Doesn't touch any of the existing flow, providing these options will build binaries and exit
Fixes#369
- Replace `Dependencies:` with `Support:`
- Add list of supported Serving versions kn can work with
- Add list of supported Serving APIs kn can work with
```
✗ ./kn version
Version: v20190816-local-e36089f-dirty
Build Date: 2019-08-16 13:08:26
Git Revision: e36089f
Support:
- Serving: v0.8.0 v0.7.1
- API(s): v1alpha1
```
* 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
* Portable plugin executable check for Windows platform
builds Windows and non-Windows platform plugin verifier separately
* Removes redundant build tag and file suffix, uses file suffix
As we'll need either to mention, which file compiles for which
platform.
- Add e2e tests
- Use '=' for traffic and tag assignment instead of ':'
- Use --tag and --untag flags for tagging traffic targets
- Use --traffic flag for setting traffic portions
- Allow --traffic portion to either take revisionName or tagName
- Uses @latest identifier for referencing latest revision of service
- Dont throw error if requested revision=tag pair is same
- Support having multiple tags for a revision
- creates a new target in traffic block if revision present in traffic block with new tag requested
- creates N new targets in traffic block if revision absent in traffic block with Nxnew tags requested
- Ensure updating tag of @latest requires --untag flag
- streamline updating tag for latestReadyRevision
- adds respective tests
- adds tests for ensuring given traffic sum to 100 on CLI and fail fast
- Add note about preference of order in case where tagOfOneRevision == revisionOfAnother,
first tags are checked and assigned traffic if any, as tags are supposed to be
unique in traffic block and should be referenced in such scenario.
- Remove the examples from flag description, moves it to service update command example section
- Pass only traffic block to compute trffic, makes it better to consume.
- Cover more error cases for invalid value format for assignments, covers a=b=c, a=, =b, or variants of them
- Separate and improves the error messages
- Add unit tests for traffic computing
- Add sanity checks in dedicated function verifyInputSanity
- traffic perents should sum to 100
- individual percent should be in 0-100
- repetition of @latest or tagName or revisionRef is disallowed
- Verify traffic percents sum to 100 on client side and fail fast
- Add e2e tests for traffic splitting
- create and update service, assign tags and set traffic to make an existing state
- run the scenario on existing state of service
- form the desired state traffic block
- extract the traffic block and form the traffic block struct actual state
- assert.DeepEqual actual and desired traffic blocks
- Use logic to generate service name in the same way as namespace, use different service name per test case
- Run e2e test for traffic splitting in parallel
- Use timeout duration of 30m for e2e tests, use timeout parameter for go_test_e2e library function
- Use tagName in flag description of --untag, avoiding conflict with --tag flag
- Update CHANGELOG
* 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.
* Allow boolean flags in the matched `--foo` and `--no-foo` format.
* test for it
* Godoc for new functions
* Copyright date update
* Disallow user from setting either flag to false explicitly. Moar tests, for this & other cases
* Apply suggestions from code review
Co-Authored-By: Roland Huß <rhuss@redhat.com>
* Fixup
* Add support for service labels with --label or -l
* Add tests
* Fix typo
* Move MapToArray helper method to separate file
* Allow unsetting labels by passing empty value
* Fix test
* Add test case for label removal
* Wrap error message with flag
* Update docs to include --label
* Update labels on both services and revisions
* Add some test cases around weirder user input
* Change unset behavior and allow setting empty env and label
* Update docs for new unset behavior
* Make single keys to map to empty values
* Move helper to util
* Use assert.DeepEqual
* Use new mock test + check both service and revision
* Use new method and correct year
Fixed:
```
$ ./kn plugin list --lookup-plugins-in-path
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/knative/client/pkg/kn/core.extractKnPluginFlags(0xc00003c0c0, 0x4, 0x4, 0xc0002be280, 0xc000000180, 0xc0002ba180, 0xc0000de670, 0xc000117f68)
/root/go/src/knative.dev/client/pkg/kn/core/root.go:222 +0x666
github.com/knative/client/pkg/kn/core.NewDefaultKnCommand(0xc000000000)
/root/go/src/knative.dev/client/pkg/kn/core/root.go:46 +0x79
main.main()
/root/go/src/knative.dev/client/cmd/kn/main.go:33 +0x46
```
While in there I fixed it so that we only look for --flag at the start
of the arg, and handle the --flag, --flag=, and --flag=xxx cases.
If there's --flagX we skip it because it's some other flag and not one
of interest to us.
Also, fixed some error processing that seemed a bit off.
Signed-off-by: Doug Davis <dug@us.ibm.com>
* Add support for -A variant of --all-namespaces
-A is my newest favorite kubectl flag, it's so much easier/faster to type
than --all-namespaces. kn users should benefit from it too!
Signed-off-by: Doug Davis <dug@us.ibm.com>
* tweak tests
Signed-off-by: Doug Davis <dug@us.ibm.com>
* refactor(plugins): Improved and simplified verifier and plugin list
* Added proper executable check for current user
* Refactor plugin_list to make it more straightforward
* Seperate errors and warnings
* Don't return an error when no plugin is installed and `plugin list` is called
* Simplified tests
* Check assumption that a prefix is given in verify()
* fix(plugins): Fixed broken homedir expansion
* fix(plugin): Adapted to proper permission handling
E.g. if u-x, g+x and the user has the group of the file, but is also owner of the file then he is not allowed to execute the file.
* test(plugins): Added checks for the execution check for plugins
* chore(plugins): optimized tests to reflect the real unix behaviour
* chore(plugins): Moved plugin seenMap to top-level verify method.
Also, allow symlinks without warnings.
* refactor(plugins): Split up some methods in plugin_verifier to make them shorter
* fix: Tuned `plugin list` for better handling when no plugin directory exists
* feature(service describe): Output of service details
`kn service show` mimics `kubectl describe <sth>` as that it output detail information in human readable output.
A future extension should add machine readable output with `-o` to export
a single object in json/yaml (that is missing from `kn service list`)
This command shows information about the service itself, but also a summary about the associated revisions.
It also knows about scaling and concurrency options.
Options:
`--details` : Print more information. By default only are shorter summary is shown
* chore: Cleanup up and refreshed dependencies
* fix(service describe): Integration test fix (revert "show" to "describe")
* fix: go.sum
* fix go.sum
* feature(service describe): Add printing of resources (requests/limits) + machine readable output with -o
* chore(service describe): Simplified digest handling
* chore(service describe): Sort maps by key when printed
* chore: Adapt mock framework
* chore(service describe): Test fixes
* chore: Added some tests
* more tests
* test: Moar tests
* chore: Even moar tests
* more, more tests
* changelog update
* fix(service describe): golint fixes
* List revisions sorted by generation order
We use a configuration generation as a sort key, which is obtained from a label on configuration resource.
* Change column name from order to generation
* Fix revision sorting issue
* Fix revision e2e test
* Just sort by name if invalid type of generation found
* Update CHANGELOG
* Add --log-http option
* Oh yeah build it and change docs and stuff
* And some test
* Actually test the thing I meant to
* There was a way to remove the downcast
* Test for http transport
* Some deps
* Elide sensitive headers from logging
* Test for eliding errors
* Feedback from CL
```bash
➜ client git:(issue309) ✗ ./kn lol
Manage your Knative building blocks:
* Serving: Manage your services and release new software to them.
* Eventing: Manage event subscriptions and channels. Connect up event sources.
Usage:
...
Use "kn [command] --help" for more information about a command.
unknown sub-command or plugin "lol" for "kn"
```
* feature(testing): Introduce a Mock implementation for KnClient
Commands must only use the `KnClient` API and their unit tests should also
only use a mock implementation for this interface.
This commit introduces such a Mock implementation and works like in
the example below for creating a simple service in a synchronous
way
```
// New mock client
client := knclient.NewMockKnClient(t)
// Recording:
r := client.Recorder()
// Check for existing service --> no
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
// Create service (don't validate given service --> "Any()" arg is allowed)
r.CreateService(knclient.Any(), nil)
// Wait for service to become ready
r.WaitForService("foo", knclient.Any(), nil)
// Get for showing the URL
r.GetService("foo", getServiceWithUrl("foo", "http://foo.example.com"), nil)
// Testing:
output, err := executeCommand(client, "create", "foo", "--image", "gcr.io/foo/bar:baz")
assert.NilError(t, err)
assert.Assert(t, util.ContainsAll(output, "created", "foo", "http://foo.example.com", "Waiting"))
// Validate that all recorded API methods have been called
r.Validate()
```
Such tests have three phases:
* A recording phase where the mock client is prepared. In this phase a
recorder is called with the expected arguments and the return values
it can return. The arguments can be also functions with
signature `func (t *testing.T, actual interface{}, expected interface{})`
and will be called to verify a given argument. Such a function should
`t.Fail()` on its own if the validation fails.
A convenient `Any()` method is added to allow no validation on an argument
(see example below).
Method can be called multiple times, but the order needs to reflect
the actual calling order
* A playback phase where the test executed which in turn calls out to the
Mocks
* A validation phase to check the expected output. The recorder can be
also validated to verify that all recorded mock calls has been
used during the test.
See `service_create_mock_test.go` for a full example.
* chore: Test the mock client
* chore: Minor fixes
* chore: Cosmetic fixes
* Restructure E2E test suite
* move out more tests from the basic workflow and put them in separate
files, including tests for routes
* rename revision_workflow_test.go to revision_test.go
* Run all tests in parallel
When no current namespace is set in the config file, then using `kn` without -n fails:
```
invalid configuration: no configuration has been provided
```
Instead of failing in this case, assume the default namespace "namespace"
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.
* test(service): Add e2e tests for min, max scale options
add e2e tests for min, max scale options for `service create` and
`service update` operations.
* Provision in tests for jsonpath to lookup old and new fields
- updates the validation of concurrency limits/targets with upcoming change to `service describe` output
- validation commands now returns specific field in output than returning complete output
- Renames service name used from hello to svc1
- Provision in tests for jsonpath to lookup old and new fields
- Consolidate once used helper method into test itself, as its checking for very specific test-case
* Add E2E tests for Service, revision, route
* service, revision, route describe and describe with print flags
* route list with print flags
* service create for a duplicate service
* Test serviceDeleteNonexistent and fixes
* Validate invalid container concurrency options
* Use assert package
* Use FlagSet.Changed and don't care about default values
* Update dependency
* Follow e2e test changes
* Return error if invalid value is specified by users
* Fix broken e2e test
* Add more unit tests
* Fix error message
* Fix comment statement
* Revert back unrelated changes
* Fix typo
1. refactors basic workflow (move code to common)
2. use different namespace accross test runs to isolate
3. include wait logic in CreateNamespace to allow multiple runs
4. include wait logic in DeleteNamespace to allow multiple runs
This is important since we need more integration tests and some of
these changes should allow `./test/e2e-tests-local.sh` to run on
local clusters (minikube or something other than test-infra) and
correctly behave during mutiple runs.
* chore(revision): Remove bogus log message
This showed up in the test run as single log message so I removed that.
* chore(revision): Revert back to wrong API group in test as its unrelated to this PR