Repository: knative/client
Pull request #1119 (2020-11-12 14:57:59)

Fix a few more occurrences of divisive language
As per title.

- Flagging all whitespace occurrences with a TODO.
- Removing "dummy" and "sanity check".

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

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1119#" title="Author self-approved">markusthoemmes</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **rhuss** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @rhuss` in a comment when ready.

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

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

- **[OWNERS](https://github.com/knative/client/blob/master/OWNERS)**

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":["rhuss"]} -->
markusthoemmes: /assign @rhuss 

Patch:
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 08ce674a..dbbbed9c 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -12,6 +12,16 @@
 | https://github.com/knative/client/pull/[#]
 ////
 
+### Unreleased
+[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.19.0 (2020-11-11)
 [cols="1,10,3", options="header", width="100%"]
 |===
diff --git a/cmd/kn/main.go b/cmd/kn/main.go
index 5a62f590..5d4809eb 100644
--- a/cmd/kn/main.go
+++ b/cmd/kn/main.go
@@ -73,14 +73,14 @@ func run(args []string) error {
 	}
 
 	// temporary setting to parse all flags
-	rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: true}
+	rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: true} // wokeignore:rule=whitelist // TODO(#1031)
 	// Strip of all flags to get the non-flag commands only
 	commands, err := stripFlags(rootCmd, args)
 	if err != nil {
 		return err
 	}
 	// reset the temporary setting
-	rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: false}
+	rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: false} // wokeignore:rule=whitelist // TODO(#1031)
 
 	// Find plugin with the commands arguments
 	plugin, err := pluginManager.FindPlugin(commands)
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/kn/commands/options/options.go b/pkg/kn/commands/options/options.go
index c62ce7a3..b5551e8e 100644
--- a/pkg/kn/commands/options/options.go
+++ b/pkg/kn/commands/options/options.go
@@ -37,7 +37,7 @@ kn options`,
 		SilenceErrors: true,
 		SilenceUsage:  true,
 		// Allow all options
-		FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
+		FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, // wokeignore:rule=whitelist // TODO(#1031)
 	}
 	cmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error {
 		return errors.Errorf("%s for '%s'", err.Error(), c.CommandPath())
diff --git a/pkg/kn/config/config.go b/pkg/kn/config/config.go
index b17bd4cf..27d2787a 100644
--- a/pkg/kn/config/config.go
+++ b/pkg/kn/config/config.go
@@ -104,7 +104,7 @@ func BootstrapConfig() error {
 	// initialize the config file to use (obtained via GlobalConfig.ConfigFile())
 	bootstrapFlagSet := flag.NewFlagSet("kn", flag.ContinueOnError)
 	AddBootstrapFlags(bootstrapFlagSet)
-	bootstrapFlagSet.ParseErrorsWhitelist = flag.ParseErrorsWhitelist{UnknownFlags: true}
+	bootstrapFlagSet.ParseErrorsWhitelist = flag.ParseErrorsWhitelist{UnknownFlags: true} // wokeignore:rule=whitelist // TODO(#1031)
 	bootstrapFlagSet.Usage = func() {}
 	err := bootstrapFlagSet.Parse(os.Args)
 	if err != nil && err != flag.ErrHelp {
diff --git a/pkg/kn/traffic/compute.go b/pkg/kn/traffic/compute.go
index 470cbe70..94ee9aaa 100644
--- a/pkg/kn/traffic/compute.go
+++ b/pkg/kn/traffic/compute.go
@@ -213,10 +213,10 @@ func errorRepeatingRevision(forFlag string, name string) error {
 }
 
 // verifies if user has repeated @latest field in --tag or --traffic flags
-// verifyInputSanity checks:
+// verifyInput checks:
 // - if user has repeated @latest field in --tag or --traffic flags
 // - if provided traffic portion are integers
-func verifyInputSanity(trafficFlags *flags.Traffic) error {
+func verifyInput(trafficFlags *flags.Traffic) error {
 	var latestRevisionTag = false
 	var sum = 0
 
@@ -271,7 +271,7 @@ func verifyInputSanity(trafficFlags *flags.Traffic) error {
 // Compute takes service traffic targets and updates per given traffic flags
 func Compute(cmd *cobra.Command, targets []servingv1.TrafficTarget,
 	trafficFlags *flags.Traffic, serviceName string) ([]servingv1.TrafficTarget, error) {
-	err := verifyInputSanity(trafficFlags)
+	err := verifyInput(trafficFlags)
 	if err != nil {
 		return nil, err
 	}
@@ -293,7 +293,7 @@ func Compute(cmd *cobra.Command, targets []servingv1.TrafficTarget,
 	}
 
 	for _, each := range trafficFlags.RevisionsTags {
-		revision, tag, _ := splitByEqualSign(each) // err is checked in verifyInputSanity
+		revision, tag, _ := splitByEqualSign(each) // err is checked in verifyInput
 
 		// Second precedence: Tag latestRevision
 		if revision == latestRevisionRef {
@@ -338,8 +338,8 @@ func Compute(cmd *cobra.Command, targets []servingv1.TrafficTarget,
 
 		for _, each := range trafficFlags.RevisionsPercentages {
 			// revisionRef works here as either revision or tag as either can be specified on CLI
-			revisionRef, percent, _ := splitByEqualSign(each)  // err is verified in verifyInputSanity
-			percentInt, _ := strconv.ParseInt(percent, 10, 64) // percentInt (for int) is verified in verifyInputSanity
+			revisionRef, percent, _ := splitByEqualSign(each)  // err is verified in verifyInput
+			percentInt, _ := strconv.ParseInt(percent, 10, 64) // percentInt (for int) is verified in verifyInput
 
 			// fourth precedence: set traffic for latest revision
 			if revisionRef == latestRevisionRef {
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/cmd/kn/main_test.go b/cmd/kn/main_test.go
index d2151d4c..3bf61de8 100644
--- a/cmd/kn/main_test.go
+++ b/cmd/kn/main_test.go
@@ -160,7 +160,7 @@ func TestUnknownCommands(t *testing.T) {
 	for _, d := range data {
 		args := append([]string{"kn"}, d.givenCmdArgs...)
 		rootCmd, err := root.NewRootCommand(nil)
-		rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: true}
+		rootCmd.FParseErrWhitelist = cobra.FParseErrWhitelist{UnknownFlags: true} // wokeignore:rule=whitelist // TODO(#1031)
 		os.Args = args
 		assert.NilError(t, err)
 		err = validateRootCommand(rootCmd)
@@ -220,7 +220,7 @@ func TestStripFlags(t *testing.T) {
 
 	for i, f := range data {
 		step := fmt.Sprintf("Check %d", i)
-		cmd := &cobra.Command{FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}}
+		cmd := &cobra.Command{FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}} // wokeignore:rule=whitelist // TODO(#1031)
 		config.AddBootstrapFlags(cmd.Flags())
 		commands, err := stripFlags(cmd, f.givenArgs)
 		assert.DeepEqual(t, commands, f.expectedCommands)
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")
diff --git a/pkg/kn/config/testing_test.go b/pkg/kn/config/testing_test.go
index d18441ae..ded8021c 100644
--- a/pkg/kn/config/testing_test.go
+++ b/pkg/kn/config/testing_test.go
@@ -20,7 +20,7 @@ import (
 	"gotest.tools/assert"
 )
 
-// Dummy test to keep code coverage quality gate happy.
+// Test to keep code coverage quality gate happy.
 //
 func TestTestConfig(t *testing.T) {
 	cfg := TestConfig{
diff --git a/pkg/serving/v1/client_test.go b/pkg/serving/v1/client_test.go
index 37edf62d..6720eec4 100644
--- a/pkg/serving/v1/client_test.go
+++ b/pkg/serving/v1/client_test.go
@@ -56,7 +56,7 @@ func TestGetService(t *testing.T) {
 		func(a clienttesting.Action) (bool, runtime.Object, error) {
 			service := newService(serviceName)
 			name := a.(clienttesting.GetAction).GetName()
-			// Sanity check
+
 			assert.Assert(t, name != "")
 			assert.Equal(t, testNamespace, a.GetNamespace())
 			if name == serviceName {
@@ -192,7 +192,7 @@ func TestDeleteService(t *testing.T) {
 	serving.AddReactor("delete", "services",
 		func(a clienttesting.Action) (bool, runtime.Object, error) {
 			name := a.(clienttesting.DeleteAction).GetName()
-			// Sanity check
+
 			assert.Assert(t, name != "")
 			assert.Equal(t, testNamespace, a.GetNamespace())
 			if name == serviceName {
@@ -244,7 +244,7 @@ func TestGetRevision(t *testing.T) {
 		func(a clienttesting.Action) (bool, runtime.Object, error) {
 			revision := newRevision(revisionName)
 			name := a.(clienttesting.GetAction).GetName()
-			// Sanity check
+
 			assert.Assert(t, name != "")
 			assert.Equal(t, testNamespace, a.GetNamespace())
 			if name == revisionName {
@@ -334,7 +334,7 @@ func TestGetRoute(t *testing.T) {
 		func(a clienttesting.Action) (bool, runtime.Object, error) {
 			route := newRoute(routeName)
 			name := a.(clienttesting.GetAction).GetName()
-			// Sanity check
+
 			assert.Assert(t, name != "")
 			assert.Equal(t, testNamespace, a.GetNamespace())
 			if name == routeName {
@@ -497,7 +497,7 @@ func TestGetConfiguration(t *testing.T) {
 		func(a clienttesting.Action) (bool, runtime.Object, error) {
 			configuration := &servingv1.Configuration{ObjectMeta: metav1.ObjectMeta{Name: configName, Namespace: testNamespace}}
 			name := a.(clienttesting.GetAction).GetName()
-			// Sanity check
+
 			assert.Assert(t, name != "")
 			assert.Equal(t, testNamespace, a.GetNamespace())
 			if name == configName {
diff --git a/pkg/util/logging_http_transport_test.go b/pkg/util/logging_http_transport_test.go
index 719ec5ba..5e515e56 100644
--- a/pkg/util/logging_http_transport_test.go
+++ b/pkg/util/logging_http_transport_test.go
@@ -27,11 +27,11 @@ import (
 	"gotest.tools/assert"
 )
 
-type dummyTransport struct {
+type fakeTransport struct {
 	requestDump string
 }
 
-func (d *dummyTransport) RoundTrip(r *http.Request) (*http.Response, error) {
+func (d *fakeTransport) RoundTrip(r *http.Request) (*http.Response, error) {
 	dump, err := httputil.DumpRequest(r, true)
 	if err != nil {
 		return nil, fmt.Errorf("dumping request: %v", err)
@@ -53,7 +53,7 @@ func (d *errorTransport) RoundTrip(r *http.Request) (*http.Response, error) {
 
 func TestWritesRequestResponse(t *testing.T) {
 	out := &bytes.Buffer{}
-	dt := &dummyTransport{}
+	dt := &fakeTransport{}
 	transport := NewLoggingTransportWithStream(dt, out)
 
 	body := "{this: is, the: body, of: [the, request]}"
@@ -79,7 +79,7 @@ func TestWritesRequestResponse(t *testing.T) {
 
 func TestElideAuthorizationHeader(t *testing.T) {
 	out := &bytes.Buffer{}
-	transport := NewLoggingTransportWithStream(&dummyTransport{}, out)
+	transport := NewLoggingTransportWithStream(&fakeTransport{}, out)
 	req, _ := http.NewRequest("GET", "http://example.com", nil)
 	req.Header.Set("X-Normal-Header", "la la normal text")
 	req.Header.Set("Authorization", "Bearer: SECRET")