Skip to content

Feat/stackitcli 318 secret flags 3#1377

Merged
cgoetz-inovex merged 12 commits intomainfrom
feat/STACKITCLI-318_secret-flags-3
Apr 22, 2026
Merged

Feat/stackitcli 318 secret flags 3#1377
cgoetz-inovex merged 12 commits intomainfrom
feat/STACKITCLI-318_secret-flags-3

Conversation

@cgoetz-inovex
Copy link
Copy Markdown
Contributor

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.
- searched for 'password' and 'secret' to find usages
- checked usages of printer.PromptForPassword
@cgoetz-inovex cgoetz-inovex requested a review from a team as a code owner April 21, 2026 15:37
@github-actions
Copy link
Copy Markdown

Merging this branch changes the coverage (1 decrease, 7 increase)

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/alb/observability-credentials/update 43.48% (+1.26%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create 82.61% (+7.61%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update 85.07% (+6.66%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/intake/user/create 56.67% (+0.73%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/intake/user/update 65.45% (+0.64%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/load-balancer/observability-credentials/add 54.55% (+6.63%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/load-balancer/observability-credentials/update 49.06% (+5.20%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags 60.08% (-0.97%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/alb/observability-credentials/update/update.go 43.48% (+1.26%) 46 (+1) 20 (+1) 26 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create.go 82.61% (+7.61%) 115 (-5) 95 (+5) 20 (-10) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update.go 85.07% (+6.66%) 134 (-5) 114 (+5) 20 (-10) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/intake/user/create/create.go 56.67% (+0.73%) 60 (+1) 34 (+1) 26 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/intake/user/update/update.go 65.45% (+0.64%) 55 (+1) 36 (+1) 19 👍
github.com/stackitcloud/stackit-cli/internal/cmd/load-balancer/observability-credentials/add/add.go 54.55% (+6.63%) 44 (-4) 24 (+1) 20 (-5) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/load-balancer/observability-credentials/update/update.go 49.06% (+5.20%) 53 (-4) 26 (+1) 27 (-5) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags/secret.go 78.79% (-10.87%) 33 (+4) 26 7 (+4) 💀

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@cgoetz-inovex cgoetz-inovex merged commit 47f322d into main Apr 22, 2026
3 checks passed
@cgoetz-inovex cgoetz-inovex deleted the feat/STACKITCLI-318_secret-flags-3 branch April 22, 2026 07:59
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.

2 participants