Skip to content

Keep the trailing equals sign out of parsed key names#2017

Open
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-keyvalue-trailing-equals
Open

Keep the trailing equals sign out of parsed key names#2017
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-keyvalue-trailing-equals

Conversation

@devops-thiago

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Fixes #2013.

Utility.parseKeyValuePairs splits each argument on the first equals sign. String.split omits empty subsequences by default, so an argument ending in = produces a single component:

"owner=".split(separator: "=", maxSplits: 1)
// ["owner"]

The count is 1 rather than 2, so the standalone-key branch runs and stores the whole unsplit argument as the key. --label owner= therefore creates the key owner= instead of owner with an empty value.

The doc comment on the function states that a standalone key is treated as key=, which implies owner and owner= should produce the same key. Keeping empty subsequences makes the two spellings agree.

This affects --label and --opt on container volume create and container network create.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

testKeyWithEmptyValue asserts that owner= yields the key owner and that the key owner= is absent. The existing parseKeyValuePairs tests for standalone keys, empty input, and mixed formats continue to pass, so the bare-key behaviour is unchanged.

String.split omits empty subsequences by default, so an argument ending in
"=" produced a single component. parseKeyValuePairs treated that as a
standalone key and stored the whole unsplit argument, leaving the equals
sign in the key name: "owner=" became the key "owner=" rather than "owner"
with an empty value.

The function's documentation states that a standalone key is treated as
"key=", so both spellings should produce the same key. Keeping empty
subsequences makes them agree.

This affects --label and --opt on `container volume create` and
`container network create`.

Fixes apple#2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: --label key= and --opt key= keep the trailing "=" in the key name

1 participant