Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added eventtype support #1598

Merged
merged 17 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/cmd/kn.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Find more information about Knative at: https://knative.dev
* [kn completion](kn_completion.md) - Output shell completion code
* [kn container](kn_container.md) - Manage service's containers (experimental)
* [kn domain](kn_domain.md) - Manage domain mappings
* [kn eventtype](kn_eventtype.md) - Manage eventtypes
* [kn options](kn_options.md) - Print the list of flags inherited by all commands
* [kn plugin](kn_plugin.md) - Manage kn plugins
* [kn revision](kn_revision.md) - Manage service revisions
Expand Down
32 changes: 32 additions & 0 deletions docs/cmd/kn_eventtype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## kn eventtype

Manage eventtypes

```
kn eventtype
```

### Options

```
-h, --help help for eventtype
```

### Options inherited from parent commands

```
--cluster string name of the kubeconfig cluster to use
--config string kn configuration file (default: ~/.config/kn/config.yaml)
--context string name of the kubeconfig context to use
--kubeconfig string kubectl configuration file (default: ~/.kube/config)
--log-http log http traffic
```

### SEE ALSO

* [kn](kn.md) - kn manages Knative Serving and Eventing resources
* [kn eventtype create](kn_eventtype_create.md) - Create eventtype
* [kn eventtype delete](kn_eventtype_delete.md) - Delete eventtype
* [kn eventtype describe](kn_eventtype_describe.md) - Describe eventtype
* [kn eventtype list](kn_eventtype_list.md) - List eventtypes

44 changes: 44 additions & 0 deletions docs/cmd/kn_eventtype_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## kn eventtype create

Create eventtype

```
kn eventtype create
```

### Examples

```

# Create eventtype 'myeventtype' of type example.type in the current namespace
kn eventtype create myeventtype --type example.type

# Create eventtype 'myeventtype' of type example.type in the 'myproject' namespace
kn eventtype create myeventtype --namespace myproject -t example.type

```

### Options

```
-b, --broker string Cloud Event broker
-h, --help help for create
-n, --namespace string Specify the namespace to operate in.
--source string Cloud Event source
-t, --type string Cloud Event type
```

### Options inherited from parent commands

```
--cluster string name of the kubeconfig cluster to use
--config string kn configuration file (default: ~/.config/kn/config.yaml)
--context string name of the kubeconfig context to use
--kubeconfig string kubectl configuration file (default: ~/.kube/config)
--log-http log http traffic
```

### SEE ALSO

* [kn eventtype](kn_eventtype.md) - Manage eventtypes

41 changes: 41 additions & 0 deletions docs/cmd/kn_eventtype_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## kn eventtype delete

Delete eventtype

```
kn eventtype delete
```

### Examples

```

# Delete eventtype 'myeventtype' in the current namespace
kn eventtype delete myeventtype

# Delete eventtype 'myeventtype' in the 'myproject' namespace
kn eventtype delete myeventtype --namespace myproject

```

### Options

```
-h, --help help for delete
-n, --namespace string Specify the namespace to operate in.
```

### Options inherited from parent commands

```
--cluster string name of the kubeconfig cluster to use
--config string kn configuration file (default: ~/.config/kn/config.yaml)
--context string name of the kubeconfig context to use
--kubeconfig string kubectl configuration file (default: ~/.kube/config)
--log-http log http traffic
```

### SEE ALSO

* [kn eventtype](kn_eventtype.md) - Manage eventtypes

47 changes: 47 additions & 0 deletions docs/cmd/kn_eventtype_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## kn eventtype describe

Describe eventtype

```
kn eventtype describe
```

### Examples

```

# Describe eventtype 'myeventtype' in the current namespace
kn eventtype describe myeventtype

# Describe eventtype 'myeventtype' in the 'myproject' namespace
kn eventtype describe myeventtype --namespace myproject

# Describe eventtype 'myeventtype' in YAML format
kn eventtype describe myeventtype -o yaml
```

### Options

```
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for describe
-n, --namespace string Specify the namespace to operate in.
-o, --output string Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.
--show-managed-fields If true, keep the managedFields when printing objects in JSON or YAML format.
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
```

### Options inherited from parent commands

```
--cluster string name of the kubeconfig cluster to use
--config string kn configuration file (default: ~/.config/kn/config.yaml)
--context string name of the kubeconfig context to use
--kubeconfig string kubectl configuration file (default: ~/.kube/config)
--log-http log http traffic
```

### SEE ALSO

* [kn eventtype](kn_eventtype.md) - Manage eventtypes

46 changes: 46 additions & 0 deletions docs/cmd/kn_eventtype_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## kn eventtype list

List eventtypes

```
kn eventtype list
```

### Examples

```

# List all eventtypes
kn eventtype list

# List all eventtypes in JSON output format
kn eventtype list -o json
```

### Options

```
-A, --all-namespaces If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for list
-n, --namespace string Specify the namespace to operate in.
--no-headers When using the default output format, don't print headers (default: print headers).
-o, --output string Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.
--show-managed-fields If true, keep the managedFields when printing objects in JSON or YAML format.
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
```

### Options inherited from parent commands

```
--cluster string name of the kubeconfig cluster to use
--config string kn configuration file (default: ~/.config/kn/config.yaml)
--context string name of the kubeconfig context to use
--kubeconfig string kubectl configuration file (default: ~/.kube/config)
--log-http log http traffic
```

### SEE ALSO

* [kn eventtype](kn_eventtype.md) - Manage eventtypes

60 changes: 60 additions & 0 deletions lib/test/eventtype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2021 The Knative Authors

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package test

import (
"gotest.tools/v3/assert"
"knative.dev/client/pkg/util"
)

// EventtypeCreate creates an eventtype with the given name.
func EventtypeCreate(r *KnRunResultCollector, name, cetype string) {
out := r.KnTest().Kn().Run("eventtype", "create", name, "--type", cetype)
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "Eventtype", name, "created", "namespace", r.KnTest().Kn().Namespace()))
}

// EventtypeDelete deletes an eventtype with the given name.
func EventtypeDelete(r *KnRunResultCollector, name string) {
out := r.KnTest().Kn().Run("eventtype", "delete", name)
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "Eventtype", name, "deleted", "namespace", r.KnTest().Kn().Namespace()))
}

// EventtypeList verifies listing eventtypes in the given namespace
func EventtypeList(r *KnRunResultCollector, eventtypes ...string) {
out := r.KnTest().Kn().Run("eventtype", "list")
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, eventtypes...))
}

// EventtypeDescribe describes an eventtype with the given name.
func EventtypeDescribe(r *KnRunResultCollector, name string) {
out := r.KnTest().Kn().Run("eventtype", "describe", name)
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAll(out.Stdout, name, r.KnTest().Kn().Namespace(), "Ready", "BrokerReady"))
}

func EventtypeCreateWithBrokerSource(r *KnRunResultCollector, name, cetype, broker, source string) {
out := r.KnTest().Kn().Run("eventtype", "create", name, "--type", cetype, "--broker", broker, "--source", source)
r.AssertNoError(out)
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "Eventtype", name, "created", "namespace", r.KnTest().Kn().Namespace()))
}

func EventtypeCreateWithSourceError(r *KnRunResultCollector, name, cetype, source string) {
out := r.KnTest().Kn().Run("eventtype", "create", name, "--type", cetype, "--source", source)
r.AssertError(out)
assert.Check(r.T(), util.ContainsAll(out.Stderr, name, "invalid", "control character"))
}
Loading