Repository: knative/pkg
Pull request #2231 (2021-08-24 11:14:53)

Trim the space in configmap/registriesSkippingTagResolving's url.
# Changes
🎁 Trim the space in configmap/registriesSkippingTagResolving's url. Because many develpers do like "a.com, b.com", it's easy to have this mistake.

Related to https://github.com/knative/pkg/issues/2229
Related PR

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

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/2231#" title="Author self-approved">jwcesign</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **dprotaso** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @dprotaso` 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%2Fpkg).

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

- **[configmap/OWNERS](https://github.com/knative/pkg/blob/main/configmap/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":["dprotaso"]} -->
knative-prow-robot: Hi @jwcesign. Thanks for your PR.

I'm waiting for a [knative](https://github.com/orgs/knative/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/knative/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

markusthoemmes: /ok-to-test

Any reason to open another PR? Seems like the other one was fine as well.
jwcesign: > /ok-to-test
> 
> Any reason to open another PR? Seems like the other one was fine as well.

I scare use force pushing is wrong, So maybe use new PR better， should do new commit when new review issues.
julz: @jwcesign yeah, it's fine to just push extra commits to the PR branch - the robots will automatically squash them into a single commit when we merge the PR 👍.
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/2231#pullrequestreview-737144534" title="Approved">julz</a>*, *<a href="https://github.com/knative/pkg/pull/2231#" title="Author self-approved">jwcesign</a>*

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

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:

- ~~[configmap/OWNERS](https://github.com/knative/pkg/blob/main/configmap/OWNERS)~~ [julz]

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/configmap/parse.go b/configmap/parse.go
index 4c280757b..faeacab14 100644
--- a/configmap/parse.go
+++ b/configmap/parse.go
@@ -141,7 +141,11 @@ func AsDuration(key string, target *time.Duration) ParseFunc {
 func AsStringSet(key string, target *sets.String) ParseFunc {
 	return func(data map[string]string) error {
 		if raw, ok := data[key]; ok {
-			*target = sets.NewString(strings.Split(raw, ",")...)
+			splitted := strings.Split(raw, ",")
+			for i, v := range splitted {
+				splitted[i] = strings.TrimSpace(v)
+			}
+			*target = sets.NewString(splitted...)
 		}
 		return nil
 	}


Test patch:
diff --git a/configmap/parse_test.go b/configmap/parse_test.go
index 0f3878c7f..34bc2c3ef 100644
--- a/configmap/parse_test.go
+++ b/configmap/parse_test.go
@@ -61,7 +61,7 @@ func TestParse(t *testing.T) {
 			"test-int":      "4",
 			"test-float64":  "1.0",
 			"test-duration": "1m",
-			"test-set":      "a,b,c",
+			"test-set":      "a,b,c, d",
 			"test-quantity": "500m",
 
 			"test-namespaced-name":          "some-namespace/some-name",
@@ -76,7 +76,7 @@ func TestParse(t *testing.T) {
 			f64:    1.0,
 			i:      4,
 			dur:    time.Minute,
-			set:    sets.NewString("a", "b", "c"),
+			set:    sets.NewString("a", "b", "c", "d"),
 			qua:    &fiveHundredM,
 			nsn: types.NamespacedName{
 				Name:      "some-name",