Repository: knative/client
Pull request #1132 (2020-11-23 09:58:34)

[release-0.18] Backport of #1117
Backport PR for release-v0.18.3 with
 - #1117 
 - Updated CHANGELOG

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1132#" title="Author self-approved">navidshaikh</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/release-0.18/OWNERS)~~ [navidshaikh]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
knative-metrics-robot: The following is the coverage report on the affected files.
Say `/test pull-knative-client-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/kn/commands/channel/describe.go](https://storage.cloud.google.com/knative-prow/pr-logs/pull/knative_client/1132/pull-knative-client-go-coverage/1330813006052855808/artifacts/line-cov.html#file2) | 79.5% | 76.9% | -2.6

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1132#pullrequestreview-536964343" title="Approved">maximilien</a>*, *<a href="https://github.com/knative/client/pull/1132#" title="Author self-approved">navidshaikh</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/release-0.18/OWNERS)~~ [maximilien,navidshaikh]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1132#pullrequestreview-536964343" title="Approved">maximilien</a>*, *<a href="https://github.com/knative/client/pull/1132#" title="Author self-approved">navidshaikh</a>*, *<a href="https://github.com/knative/client/pull/1132#pullrequestreview-537173173" title="Approved">rhuss</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/release-0.18/OWNERS)~~ [maximilien,navidshaikh,rhuss]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 04bc9bce..381b58fe 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -12,6 +12,18 @@
 | https://github.com/knative/client/pull/[#]
 ////
 
+## v0.18.3 (2020-11-24)
+
+[cols="1,10,3", options="header", width="100%"]
+|===
+| | Description | PR
+
+| 🐛
+| Embed the namespace in request body while creating channels
+| https://github.com/knative/client/pull/1117[#1117]
+
+|===
+
 ## v0.18.2 (2020-11-10)
 
 [cols="1,10,3", options="header", width="100%"]
diff --git a/pkg/kn/commands/channel/create.go b/pkg/kn/commands/channel/create.go
index 8f5e2251..f952b507 100644
--- a/pkg/kn/commands/channel/create.go
+++ b/pkg/kn/commands/channel/create.go
@@ -60,7 +60,7 @@ func NewChannelCreateCommand(p *commands.KnParams) *cobra.Command {
 				return err
 			}
 
-			cb := knmessagingv1beta1.NewChannelBuilder(name)
+			cb := knmessagingv1beta1.NewChannelBuilder(name, namespace)
 
 			if cmd.Flag("type").Changed {
 				gvk, err := ctypeFlags.Parse()
diff --git a/pkg/messaging/v1beta1/channels_client.go b/pkg/messaging/v1beta1/channels_client.go
index 2c93e5cb..a247b8b2 100644
--- a/pkg/messaging/v1beta1/channels_client.go
+++ b/pkg/messaging/v1beta1/channels_client.go
@@ -122,10 +122,11 @@ type ChannelBuilder struct {
 }
 
 // NewChannelBuilder for building Channel object
-func NewChannelBuilder(name string) *ChannelBuilder {
+func NewChannelBuilder(name, namespace string) *ChannelBuilder {
 	return &ChannelBuilder{channel: &v1beta1.Channel{
 		ObjectMeta: metav1.ObjectMeta{
-			Name: name,
+			Name:      name,
+			Namespace: namespace,
 		},
 	}}
 }


Test patch:
diff --git a/pkg/kn/commands/channel/channel_test.go b/pkg/kn/commands/channel/channel_test.go
index 861c1d9e..f015f7c3 100644
--- a/pkg/kn/commands/channel/channel_test.go
+++ b/pkg/kn/commands/channel/channel_test.go
@@ -76,6 +76,6 @@ func cleanupChannelMockClient() {
 	channelClientFactory = nil
 }
 
-func createChannel(name string, gvk *schema.GroupVersionKind) *v1beta1.Channel {
-	return clientv1beta1.NewChannelBuilder(name).Type(gvk).Build()
+func createChannel(name, namespace string, gvk *schema.GroupVersionKind) *v1beta1.Channel {
+	return clientv1beta1.NewChannelBuilder(name, namespace).Type(gvk).Build()
 }
diff --git a/pkg/kn/commands/channel/create_test.go b/pkg/kn/commands/channel/create_test.go
index b8649793..45b35088 100644
--- a/pkg/kn/commands/channel/create_test.go
+++ b/pkg/kn/commands/channel/create_test.go
@@ -43,7 +43,7 @@ func TestCreateChannelErrorCaseTypeFormat(t *testing.T) {
 func TestCreateChannelDefaultChannel(t *testing.T) {
 	cClient := v1beta1.NewMockKnChannelsClient(t)
 	cRecorder := cClient.Recorder()
-	cRecorder.CreateChannel(createChannel("pipe", nil), nil)
+	cRecorder.CreateChannel(createChannel("pipe", "default", nil), nil)
 	out, err := executeChannelCommand(cClient, "create", "pipe")
 	assert.NilError(t, err, "channel should be created")
 	assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))
@@ -53,7 +53,7 @@ func TestCreateChannelDefaultChannel(t *testing.T) {
 func TestCreateChannelWithTypeFlagInMemoryChannel(t *testing.T) {
 	cClient := v1beta1.NewMockKnChannelsClient(t)
 	cRecorder := cClient.Recorder()
-	cRecorder.CreateChannel(createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
+	cRecorder.CreateChannel(createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
 	out, err := executeChannelCommand(cClient, "create", "pipe", "--type", "imcv1beta1")
 	assert.NilError(t, err, "channel should be created")
 	assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))
diff --git a/pkg/kn/commands/channel/describe_test.go b/pkg/kn/commands/channel/describe_test.go
index dc153a65..70154cda 100644
--- a/pkg/kn/commands/channel/describe_test.go
+++ b/pkg/kn/commands/channel/describe_test.go
@@ -45,7 +45,7 @@ func TestDescribeChannelErrorCaseNotFound(t *testing.T) {
 func TestDescribeChannel(t *testing.T) {
 	cClient := v1beta1.NewMockKnChannelsClient(t)
 	cRecorder := cClient.Recorder()
-	cRecorder.GetChannel("pipe", createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
+	cRecorder.GetChannel("pipe", createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
 	out, err := executeChannelCommand(cClient, "describe", "pipe")
 	assert.NilError(t, err, "channel should be described")
 	assert.Assert(t, util.ContainsAll(out, "messaging.knative.dev", "v1beta1", "InMemoryChannel", "pipe"))
diff --git a/pkg/kn/commands/channel/list_test.go b/pkg/kn/commands/channel/list_test.go
index c9116338..13293968 100644
--- a/pkg/kn/commands/channel/list_test.go
+++ b/pkg/kn/commands/channel/list_test.go
@@ -41,8 +41,8 @@ func TestChannelList(t *testing.T) {
 	cRecorder := cClient.Recorder()
 	clist := &messagingv1beta1.ChannelList{}
 	clist.Items = []messagingv1beta1.Channel{
-		*createChannel("c0", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
-		*createChannel("c1", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
+		*createChannel("c0", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
+		*createChannel("c1", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
 	}
 	cRecorder.ListChannel(clist, nil)
 	out, err := executeChannelCommand(cClient, "list")