Skip to content

fix(cmd/variable): preserve special characters in values#266

Closed
stantheman0128 wants to merge 1 commit into
zeabur:mainfrom
stantheman0128:fix/variable-special-values
Closed

fix(cmd/variable): preserve special characters in values#266
stantheman0128 wants to merge 1 commit into
zeabur:mainfrom
stantheman0128:fix/variable-special-values

Conversation

@stantheman0128

@stantheman0128 stantheman0128 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace Cobra StringToString flags with raw StringArray arguments for variable create and update
  • split each KEY=VALUE entry only on the first = so ${...}, commas, and embedded equals signs are preserved
  • validate malformed entries and add regression tests for both commands and the shared parser

Testing

  • go test ./...
  • go vet ./...

Closes #201


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Improvements

    • Variable creation and updates now support multiple --key/-k arguments in the same command.
    • Key/value values are preserved correctly, including commas, additional equals signs, variable references, and empty values.
    • Invalid key/value formats now produce clear errors.
    • When a key is provided more than once, the last value takes precedence.
  • Tests

    • Added coverage for repeated flags and key/value parsing scenarios.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c039431-df26-4682-ba3c-f6e2782d7838

📥 Commits

Reviewing files that changed from the base of the PR and between 8adcbc1 and 2c30994.

📒 Files selected for processing (6)
  • internal/cmd/variable/create/create.go
  • internal/cmd/variable/create/create_test.go
  • internal/cmd/variable/update/update.go
  • internal/cmd/variable/update/update_test.go
  • internal/cmdutil/keyvalue.go
  • internal/cmdutil/keyvalue_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@stantheman0128

Copy link
Copy Markdown
Contributor Author

Closing this PR because I missed the existing active PR #206, which addresses the same issue and already has maintainer feedback. The issue page did not surface it in comments, but I should have searched the repository PR history before opening another implementation. Sorry for the duplicate.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c039431-df26-4682-ba3c-f6e2782d7838

📥 Commits

Reviewing files that changed from the base of the PR and between 8adcbc1 and 2c30994.

📒 Files selected for processing (6)
  • internal/cmd/variable/create/create.go
  • internal/cmd/variable/create/create_test.go
  • internal/cmd/variable/update/update.go
  • internal/cmd/variable/update/update_test.go
  • internal/cmdutil/keyvalue.go
  • internal/cmdutil/keyvalue_test.go

@@ -0,0 +1,26 @@
package create

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Fix CI pipeline failure: testpackage linter error.

The golangci-lint pipeline is failing because these new test files use the internal package name instead of the _test suffix required by the testpackage linter. To resolve the CI failure, update the package declarations to use black-box testing and import the tested packages as needed.

  • internal/cmd/variable/create/create_test.go#L1-L1: Change package to create_test.
  • internal/cmd/variable/update/update_test.go#L1-L1: Change package to update_test.
  • internal/cmdutil/keyvalue_test.go#L1-L1: Change package to cmdutil_test.
🧰 Tools
🪛 GitHub Actions: golangci-lint / 0_lint.txt

[error] 1-9: golangci-lint: package should be create_test instead of create (testpackage)

🪛 GitHub Actions: golangci-lint / lint

[error] 1-1: golangci-lint: package should be create_test instead of create (testpackage)

🪛 GitHub Check: lint

[failure] 1-1:
package should be create_test instead of create (testpackage)

📍 Affects 3 files
  • internal/cmd/variable/create/create_test.go#L1-L1 (this comment)
  • internal/cmd/variable/update/update_test.go#L1-L1
  • internal/cmdutil/keyvalue_test.go#L1-L1

Sources: Linters/SAST tools, Pipeline failures

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.

variable create --key flag cannot handle values containing ${} (Cobra StringToStringVar limitation)

1 participant