-
Notifications
You must be signed in to change notification settings - Fork 263
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
feat(channel): Manage knative eventing channels #967
Merged
+2,523
−11
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## kn channel | ||
|
||
Manage event channels | ||
|
||
### Synopsis | ||
|
||
Manage event channels | ||
|
||
``` | ||
kn channel COMMAND | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for channel | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string kn configuration file (default: ~/.config/kn/config.yaml) | ||
--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 channel create](kn_channel_create.md) - Create an event channel | ||
* [kn channel delete](kn_channel_delete.md) - Delete a channel | ||
* [kn channel describe](kn_channel_describe.md) - Show details of a channel | ||
* [kn channel list](kn_channel_list.md) - List channels | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## kn channel create | ||
|
||
Create an event channel | ||
|
||
### Synopsis | ||
|
||
Create an event channel | ||
|
||
``` | ||
kn channel create NAME | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
|
||
# Create a channel 'pipe' with default setting for channel configuration | ||
kn channel create pipe | ||
|
||
# Create a channel 'imc1' of type InMemoryChannel using inbuilt alias 'imc' | ||
kn channel create imc1 --type imc | ||
# same as above without using inbuilt alias but providing explicit GVK | ||
kn channel create imc1 --type messaging.knative.dev:v1beta1:InMemoryChannel | ||
navidshaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Create a channel 'k1' of type KafkaChannel | ||
kn channel create k1 --type messaging.knative.dev:v1alpha1:KafkaChannel | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for create | ||
-n, --namespace string Specify the namespace to operate in. | ||
--type string Override channel type to create, in the format '--type Group:Version:Kind'. If flag is not specified, it uses default messaging layer settings for channel type, cluster wide or specific namespace. You can configure aliases for channel types in kn config and refer the aliases with this flag. You can also refer inbuilt channel type InMemoryChannel using an alias 'imc' like '--type imc'. Examples: '--type messaging.knative.dev:v1alpha1:KafkaChannel' for specifying explicit Group:Version:Kind. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string kn configuration file (default: ~/.config/kn/config.yaml) | ||
--kubeconfig string kubectl configuration file (default: ~/.kube/config) | ||
--log-http log http traffic | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn channel](kn_channel.md) - Manage event channels | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## kn channel delete | ||
|
||
Delete a channel | ||
|
||
### Synopsis | ||
|
||
Delete a channel | ||
|
||
``` | ||
kn channel delete NAME | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
|
||
navidshaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Delete a channel 'pipe' | ||
kn channel delete pipe | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for delete | ||
-n, --namespace string Specify the namespace to operate in. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string kn configuration file (default: ~/.config/kn/config.yaml) | ||
--kubeconfig string kubectl configuration file (default: ~/.kube/config) | ||
--log-http log http traffic | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn channel](kn_channel.md) - Manage event channels | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## kn channel describe | ||
|
||
Show details of a channel | ||
|
||
### Synopsis | ||
|
||
Show details of a channel | ||
|
||
``` | ||
kn channel describe NAME | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
navidshaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Describe a channel 'pipe' | ||
kn channel describe pipe | ||
``` | ||
|
||
### 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-file. | ||
--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]. | ||
-v, --verbose More output. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string kn configuration file (default: ~/.config/kn/config.yaml) | ||
--kubeconfig string kubectl configuration file (default: ~/.kube/config) | ||
--log-http log http traffic | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn channel](kn_channel.md) - Manage event channels | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## kn channel list | ||
|
||
List channels | ||
|
||
### Synopsis | ||
|
||
List channels | ||
|
||
``` | ||
kn channel list | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# List all channels | ||
kn channel list | ||
# List channels in YAML format | ||
kn channel ping list -o yaml | ||
``` | ||
|
||
### 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-file. | ||
--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 | ||
|
||
``` | ||
--config string kn configuration file (default: ~/.config/kn/config.yaml) | ||
--kubeconfig string kubectl configuration file (default: ~/.kube/config) | ||
--log-http log http traffic | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn channel](kn_channel.md) - Manage event channels | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2020 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 im | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package test | ||
|
||
import ( | ||
"time" | ||
|
||
"gotest.tools/assert" | ||
|
||
"knative.dev/client/pkg/util" | ||
) | ||
|
||
func ChannelCreate(r *KnRunResultCollector, cname string, args ...string) { | ||
cmd := []string{"channel", "create", cname} | ||
cmd = append(cmd, args...) | ||
out := r.KnTest().Kn().Run(cmd...) | ||
r.AssertNoError(out) | ||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "channel", cname, "created")) | ||
// let channel reconcile TODO: fix the wait for channel to become ready | ||
time.Sleep(5 * time.Second) | ||
} | ||
|
||
func ChannelList(r *KnRunResultCollector, args ...string) string { | ||
cmd := []string{"channel", "list"} | ||
cmd = append(cmd, args...) | ||
out := r.KnTest().Kn().Run(cmd...) | ||
r.AssertNoError(out) | ||
return out.Stdout | ||
} | ||
|
||
func ChannelDescribe(r *KnRunResultCollector, cname string, args ...string) string { | ||
cmd := []string{"channel", "describe", cname} | ||
cmd = append(cmd, args...) | ||
out := r.KnTest().Kn().Run(cmd...) | ||
r.AssertNoError(out) | ||
return out.Stdout | ||
} | ||
|
||
func ChannelDelete(r *KnRunResultCollector, cname string) { | ||
out := r.KnTest().Kn().Run("channel", "delete", cname) | ||
r.AssertNoError(out) | ||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "channel", cname, "deleted")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright © 2020 The Knative Authors | ||
navidshaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
// 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 channel | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"k8s.io/client-go/tools/clientcmd" | ||
clientv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1beta1" | ||
|
||
"knative.dev/client/pkg/kn/commands" | ||
messagingv1beta1 "knative.dev/client/pkg/messaging/v1beta1" | ||
) | ||
|
||
// NewChannelCommand to manage event channels | ||
func NewChannelCommand(p *commands.KnParams) *cobra.Command { | ||
navidshaikh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
channelCmd := &cobra.Command{ | ||
Use: "channel COMMAND", | ||
Short: "Manage event channels", | ||
} | ||
channelCmd.AddCommand(NewChannelCreateCommand(p)) | ||
channelCmd.AddCommand(NewChannelListCommand(p)) | ||
channelCmd.AddCommand(NewChannelDeleteCommand(p)) | ||
channelCmd.AddCommand(NewChannelDescribeCommand(p)) | ||
return channelCmd | ||
} | ||
|
||
var channelClientFactory func(config clientcmd.ClientConfig, namespace string) (messagingv1beta1.KnChannelsClient, error) | ||
|
||
func newChannelClient(p *commands.KnParams, cmd *cobra.Command) (messagingv1beta1.KnChannelsClient, error) { | ||
namespace, err := p.GetNamespace(cmd) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if channelClientFactory != nil { | ||
config, err := p.GetClientConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return channelClientFactory(config, namespace) | ||
} | ||
|
||
clientConfig, err := p.RestConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := clientv1beta1.NewForConfig(clientConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return messagingv1beta1.NewKnMessagingClient(client, namespace).ChannelsClient(), nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other way to explain this without using acronyms or simpler terms. thinking of users not familiar with the jargons.. :)