Commit Graph

15 Commits

Author SHA1 Message Date
Scott Nichols 9fd763e5dd migrate to the new eventing legacy client (#621)
* migrate to the new eventing legacy client

* ran go mod tidy

* found the ./hack/build.sh file and ran it.
2020-01-21 23:15:23 -08:00
dr.max b640219140 load config values from viper if present in config (#468)
* init config flags in root cmd's PersistentPreRunE

* change Cfg.LookupPlugins to pointer to bool

* simplified logic in setting initial config flags from viper config
2019-12-19 02:24:31 -08:00
Ying Chun Guo 7def9f49eb Add command for creation of a plain trigger (#541) 2019-12-16 07:41:01 -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
Navid Shaikh 5deba393cb Explicit name for serving client (#537)
* Explicit name for serving client

 - Renames NewClient to NewServingClient, since now we're adding more clients

* Add cover.html in gitignore
2019-12-08 23:42:44 -08:00
Ying Chun Guo 37d27782a5 add common codes for sources client (#514) 2019-11-27 00:50:21 -08:00
Roland Huß a2d1ef7d83 chore(service): Improvements for waiting on service readiness (#431)
* Increased default timeout to 600s. This timeout will be triggered
  only when the Ready condition stays in UNKNOWN for that long. If its
  True or False then the command will return anyway sooner.
  So it makes sense to go for a much longer timeout than 60s
* Enhanced output to indicate the progress

This change needs some updates to the API and introduces a 'MessageCallback'
type which is calle for each intermediate event with the "Ready" condition message.
2019-10-10 06:06:06 -07:00
dr.max d543b0e5a3 fixes(#414): change plugins config to use - instead of camel case (#428)
This solves 414 by adopting new format for config keys and thereby
bypassing the need for case sensitivity in Viper. Also changed
`lookupPluginsInPath` key to `lookup-plugins` and also same for the
persistent flag. The PATH part is implied and can be read from
help.
2019-10-04 00:48:08 -07:00
Roland Huß 6ffef8dd88 refactor(knclient): Moved KnClient -> KnServingClient (#420)
This is in preparation of introducting eventing and makes sense anyway.
Also, the GVK update handling has been moved to "util" so that it then
can be also reused by eventing.
2019-09-28 09:21:45 -07:00
Toshinori Sugita 43f8386b82 fix analyzer warnings (#412)
* remove unused codes (structcheck)(varcheck)

* add error handling (errcheck)

* add error handling (ineffassign)

* fix lint errors (golint)
2019-09-23 03:03:12 -07:00
Naomi Seyfer 0ff537ad98 By default, set `Image` to the image of the prev. revision by digest (#373)
* Option to freeze revision to digest

* Tests pass. Checkpoint.

* Tests for env now check pinning to digest

* Bool flag using convention. Tweak usage.

* Describing the image carefully using the annotation and digest

* lint

* Test matrix of locking to digest behaviors

* Expose both flags, and rewrite help text again

* Unit tests.

* Removed unsed method

* Add tests for getting base revision

* Make tests actually test stuff better

* Make tests actually test stuff better

* A mergeout killed a returning of error. Restore it

* Help text again
2019-08-27 11:42:40 -07: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
Roland Huß 71c39e822d feature(testing): Introduce a mock implementation for KnClient (#306)
* 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
2019-07-30 17:51:42 -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