Skip to content

feat(cdn): onboard missing functionality - #1774

Open
SerseusWasTaken wants to merge 2 commits into
mainfrom
feat/cdn-missing-features
Open

SerseusWasTaken wants to merge 2 commits into
mainfrom
feat/cdn-missing-features

Conversation

@SerseusWasTaken

Copy link
Copy Markdown
Contributor

Description

Adds the following flags:
Create and update

  • --cache-key-headers
  • --cache-query-string-vary
  • --cache-query-string-vary-parameters
  • --forward-host-header
  • --labels
  • --redirects
  • --strip-response-cookies
  • --tls-enable-1-0
  • --tls-enable-1-1
  • --waf
    Update only
  • --remove-cache-key-headers
  • --remove-cache-query-string-vary-parameters
  • --remove-default-cache-duration
  • --labels-to-remove
  • --remove-log-sink
  • --remove-monthly-limit-bytes
  • --remove-redirects

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)

Relates to STACKITCLI-1006
@SerseusWasTaken
SerseusWasTaken force-pushed the feat/cdn-missing-features branch from 330e8f6 to 245ded1 Compare December 4, 2026 06:48
@SerseusWasTaken
SerseusWasTaken marked this pull request as ready for review December 4, 2026 06:53
@SerseusWasTaken
SerseusWasTaken requested a review from a team as a code owner December 4, 2026 06:53
flagRemoveDefaultCacheDuration = "remove-default-cache-duration"
flagForwardHostHeader = "forward-host-header"
flagLabels = "labels"
flagLabelsToRemove = "labels-to-remove"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All the other "remove" flags starting with "remove...". This one is the other way around

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know, i initially had it as removeLabels but i thought it was confusing, since this flag does take an argument, while the other remove[...] flags do not. So i renamed it like this so since this --labelsToRemove key1,key2 looks more intuitive to me than this --removeLabels key1,key2. What do you think?


labels := flags.FlagToStringToStringPointerPointer(p, cmd, flagLabels)

removeLabels := flags.FlagToStringSliceValue(p, cmd, flagLabelsToRemove)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: Where is this logic coming from? I was working on another service with labels as well and I haven't seen this logic somewhere else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have needed such logic in the past. As far as i know, this is the first time we implement the option to remove labels with the update command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also want to note that we can skip the removal of labels, this was not the focus of the PR.

examples.NewExample(
`Create a CDN distribution passing the password via stdin`,
`$ cat secret.txt | stackit beta cdn distribution create -y --project-id xxx \
--bucket --bucket-url https://bucket.example.com --bucket-credentials-access-key-id yyyy --bucket-password - --bucket-region EU \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add at least some examples for the new flags here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an example showing the usage of the two new json flags

func buildRedirectsTable(redirects *cdn.RedirectConfig) tables.Table {
table := tables.NewTable()
table.SetTitle("Redirects")
table.SetHeader("TARGET URL", "STATUS CODE", "ENABLED", "DESCRIPTION", "MATCHERS")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add the match condition as well here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, which match condition do you mean? 😅

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create 87.78% (+3.72%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe 92.93% (+4.05%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update 90.98% (+4.65%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/telemetryrouter/instance/create 50.79% (+0.79%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/telemetryrouter/instance/describe 76.36% (+1.36%) 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/telemetryrouter/instance/update 52.94% (+1.43%) 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils 87.10% (+5.28%) 👍
Coverage details

Compared to commit bcd78df (run #47282267585)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/create/create.go 87.78% (+3.72%) 180 (+42) 158 (+42) 22 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/describe/describe.go 92.93% (+4.05%) 184 (+67) 171 (+67) 13 👍
github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update.go 90.98% (+4.65%) 244 (+83) 222 (+83) 22 👍
github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils.go 87.10% (+5.28%) 31 (+9) 27 (+9) 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.

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/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/cdn/distribution/update/update_test.go
  • github.com/stackitcloud/stackit-cli/internal/pkg/services/cdn/utils/utils_test.go

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