Skip to content

Conversation

@cgoetz-inovex
Copy link
Contributor

@cgoetz-inovex cgoetz-inovex commented Nov 19, 2025

Description

Issue: STACKITCLI-70

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)

@cgoetz-inovex cgoetz-inovex requested a review from a team as a code owner November 19, 2025 16:39
@rubenhoenle
Copy link
Member

Btw, please always add the Jira issue ID to your PR description if possible :)

cgoetz-inovex and others added 2 commits December 5, 2025 15:44
- replace single char names with more descriptive ones
- remove predefined mod functions
- deduplicate ParseOriginRequestHeaders and test it
- deduplicate ParseGeofencing and test it
- add test FlagTo* funcs
@github-actions
Copy link

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions
Copy link

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

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create 74.38% (+74.38%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete 26.67% (+26.67%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe 88.79% (+88.79%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list 80.60% (+80.60%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update 77.86% (+77.86%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/config/set 90.08% (+0.23%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset 35.34% (-0.05%) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config 71.48% (+0.11%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags 59.15% (+0.86%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils 81.82% (+81.82%) 🌟
github.com/stackitcloud/stackit-cli/internal/pkg/testutils 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/utils 59.79% (+2.65%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/beta.go 0.00% (ø) 8 (+1) 0 8 (+1)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/cdn.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create.go 74.38% (+74.38%) 121 (+121) 90 (+90) 31 (+31) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete/delete.go 26.67% (+26.67%) 30 (+30) 8 (+8) 22 (+22) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe/describe.go 88.79% (+88.79%) 116 (+116) 103 (+103) 13 (+13) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/distribution.go 0.00% (ø) 8 (+8) 0 8 (+8)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list/list.go 80.60% (+80.60%) 67 (+67) 54 (+54) 13 (+13) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update.go 77.86% (+77.86%) 140 (+140) 109 (+109) 31 (+31) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/config/set/set.go 90.08% (+0.23%) 131 (+3) 118 (+3) 13 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset.go 35.34% (-0.05%) 116 (+3) 41 (+1) 75 (+2) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config/config.go 90.48% (+0.15%) 63 (+1) 57 (+1) 6 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags/flag_to_value.go 25.81% (+8.08%) 93 (+14) 24 (+10) 69 (+4) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/client/client.go 0.00% (ø) 1 (+1) 0 1 (+1)
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils.go 81.82% (+81.82%) 22 (+22) 18 (+18) 4 (+4) 🌟
github.com/stackitcloud/stackit-cli/internal/pkg/testutils/testutils.go 0.00% (ø) 54 (+10) 0 54 (+10)
github.com/stackitcloud/stackit-cli/internal/pkg/utils/strings.go 58.62% (+10.79%) 29 (+6) 17 (+6) 12 🎉

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.

Changed unit test files

  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/flags/flag_to_value_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/utils/strings_test.go

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

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

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create 74.38% (+74.38%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete 26.67% (+26.67%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe 88.89% (+88.89%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list 80.60% (+80.60%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update 77.86% (+77.86%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/config/set 90.30% (+0.22%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset 35.29% (-0.05%) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config 71.48% (+0.11%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags 59.15% (+0.86%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/client 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils 81.82% (+81.82%) 🌟
github.com/stackitcloud/stackit-cli/internal/pkg/testutils 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/pkg/utils 61.39% (+4.24%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/beta.go 0.00% (ø) 9 (+1) 0 9 (+1)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/cdn.go 0.00% (ø) 4 (+4) 0 4 (+4)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create.go 74.38% (+74.38%) 121 (+121) 90 (+90) 31 (+31) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete/delete.go 26.67% (+26.67%) 30 (+30) 8 (+8) 22 (+22) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe/describe.go 88.89% (+88.89%) 117 (+117) 104 (+104) 13 (+13) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/distribution.go 0.00% (ø) 8 (+8) 0 8 (+8)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list/list.go 80.60% (+80.60%) 67 (+67) 54 (+54) 13 (+13) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update.go 77.86% (+77.86%) 140 (+140) 109 (+109) 31 (+31) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/config/set/set.go 90.30% (+0.22%) 134 (+3) 121 (+3) 13 👍
github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset.go 35.29% (-0.05%) 119 (+3) 42 (+1) 77 (+2) 👎
github.com/stackitcloud/stackit-cli/internal/pkg/config/config.go 90.48% (+0.15%) 63 (+1) 57 (+1) 6 👍
github.com/stackitcloud/stackit-cli/internal/pkg/flags/flag_to_value.go 25.81% (+8.08%) 93 (+14) 24 (+10) 69 (+4) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/client/client.go 0.00% (ø) 1 (+1) 0 1 (+1)
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils.go 81.82% (+81.82%) 22 (+22) 18 (+18) 4 (+4) 🌟
github.com/stackitcloud/stackit-cli/internal/pkg/testutils/testutils.go 0.00% (ø) 60 (+9) 0 60 (+9)
github.com/stackitcloud/stackit-cli/internal/pkg/utils/strings.go 63.64% (+15.81%) 33 (+10) 21 (+10) 12 🎉

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.

Changed unit test files

  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/delete/delete_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/list/list_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/config/unset/unset_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/flags/flag_to_value_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/utils/strings_test.go

rubenhoenle
rubenhoenle previously approved these changes Jan 8, 2026
return err
}
if model.Bucket != nil {
pw, err := params.Printer.PromptForPassword("enter your secret access key for the object storage bucket: ")
Copy link
Member

Choose a reason for hiding this comment

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

How does this work with scripts? Could you add an example please which shows this use-case? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch, Print.PromptForPassword would need some changes:

@@ -172,11 +172,16 @@ func (p *Printer) PromptForEnter(prompt string) error {
 func (p *Printer) PromptForPassword(prompt string) (string, error) {
        p.Cmd.PrintErr(prompt)
        defer p.Outputln("")
-       bytePassword, err := term.ReadPassword(int(syscall.Stdin))
-       if err != nil {
-               return "", fmt.Errorf("read password: %w", err)
+       if term.IsTerminal(syscall.Stdin) {
+               bytePassword, err := term.ReadPassword(int(syscall.Stdin))
+               if err != nil {
+                       return "", fmt.Errorf("read password: %w", err)
+               }
+               return string(bytePassword), nil
        }
-       return string(bytePassword), nil
+       // Fallback for non-terminal environments
+       reader := bufio.NewReader(p.Cmd.InOrStdin())
+       return reader.ReadString('\n')
 }

With this a script like:

#!/usr/bin/env bash

cat secret | bin/stackit beta cdn distribution create -y --project-id xxx --bucket --bucket-url https://bucket.example.com \
 --bucket-credentials-access-key-id yyyy --bucket-region EU \
 --regions AF,EU

works.

Should we change Print.PromptForPassword accordingly?

Other commands (observability-credentials/update; loadbalancer/add) read passwords as command line arguments, which can be read by other processes.

Imo we should use env vars and/or stdin.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer stdin, else we have a mess with hundreds of env variables some day 😅

Copy link
Member

Choose a reason for hiding this comment

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

Should we change Print.PromptForPassword accordingly?

yes, please. If you're confident to do that do it within this PR. If not please create a Jira issue for it and bring it up in the refinement @cgoetz-inovex 😅

Copy link
Member

Choose a reason for hiding this comment

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

Other commands (observability-credentials/update; loadbalancer/add) read passwords as command line arguments, which can be read by other processes.

Also please feel free to open Jira issues for these args so we can deprecate them in the future and replace them with appropriate input methods. 😉

- fix `ID` spelling
- add missing new line at end of output
- rm TODO comment
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.

7 participants