Skip to content

feat(secret flag) add reusable secret flag implementation, update guide#1366

Open
cgoetz-inovex wants to merge 6 commits intomainfrom
feat/STACKITCLI-318_secret-flags-2
Open

feat(secret flag) add reusable secret flag implementation, update guide#1366
cgoetz-inovex wants to merge 6 commits intomainfrom
feat/STACKITCLI-318_secret-flags-2

Conversation

@cgoetz-inovex
Copy link
Copy Markdown
Contributor

Had to split implementation into two parts: Set() and SecretFlagToSP. Set is only called when an argument is specified on the command line. So moving the PromptForPassword logic into Set does not work.

I'm not sure if the current solution with a specialized *ToStringPointer func is the way to go. So I've only refactored obs-credentials add as an example.

Description

relates to #1234

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

…n tests

`print.Printer` had a reference to a `cobra.Command` for using its IO
streams. Each Command also used a Printer, resulting in an awkward
circular dependency.
Refactored Printer to use IO streams directly. When using the application
these are set in `main`, when used in tests these can be set to
`bytes.Buffer`s.
Also replaced usages of `os.Args` with just a string slice. Also set
in `main`.
`cobra.Command`s `Args` and IO-streams are set in `NewRootCmd` with
`traverseCommands`.
`CmdParams` also has an `fs.FS`, currently unused but will allow using
the real FS during regular use and an in-memory-FS during tests.

This change prepares the application for integrative testing while keeping
good isolation. Generally speaking the goal is to move all things with
side effects into main (compare with https://grafana.com/blog/how-i-write-http-services-in-go-after-13-years/#func-main-only-calls-run)
Had to split implementation into two parts: `Set()` and `SecretFlagToSP`.
Set is only called when an argument is specified on the command line.
So moving the `PromptForPassword` logic into `Set` does not work.

I'm not sure if the current solution with a specialized `*ToStringPointer`
func is the way to go. So I've only refactored `obs-credentials add`
as an example.
@cgoetz-inovex cgoetz-inovex requested a review from a team as a code owner April 14, 2026 13:39
Base automatically changed from feat/STACKITCLI-318_secret-flags to main April 15, 2026 10:54
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.

1 participant