Skip to content

onboard sfs project lock command#1397

Open
GokceGK wants to merge 4 commits intomainfrom
gg/onboard-sfs-project-lock
Open

onboard sfs project lock command#1397
GokceGK wants to merge 4 commits intomainfrom
gg/onboard-sfs-project-lock

Conversation

@GokceGK
Copy link
Copy Markdown
Contributor

@GokceGK GokceGK commented May 4, 2026

Description

relates to STACKITCLI-381

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)

@GokceGK GokceGK requested a review from a team as a code owner May 4, 2026 07:09
Comment thread docs/stackit_beta_sfs.md
@@ -32,6 +32,7 @@ stackit beta sfs [flags]
* [stackit beta](./stackit_beta.md) - Contains beta STACKIT CLI commands
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.

I can't comment it here in the right line and it also doesn't relate directly to your PR, but can you change the description of the $ stackit beta sfs command?

Provides functionality for SFS (stackit file storage)
change it to
Provides functionality for SFS (STACKIT File Storage)

req := buildRequest(ctx, model, apiClient)
resp, err := req.Execute()
if err != nil {
oapiErr, _ := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
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.

You can actually use errors.As here and remove the nolint comment. We decided a few months ago to use errors.As, but there are probably still a lot of lines where we didn't changed it yet.

var oApiErr *oapierror.GenericOpenAPIError
if sysErrors.As(e.Err, &oApiErr) {

if err != nil {
oapiErr, _ := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
if oapiErr.StatusCode == http.StatusNotFound {
fmt.Printf("No active lock found for project %s\n", projectLabel)
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.

In case someone sets the output format yaml or json, it will be ignored in this output.
And avoid using fmt.Print and use instead our params.Printer

Comment thread internal/cmd/beta/sfs/project-lock/unlock/unlock.go Outdated
Comment thread internal/cmd/beta/sfs/project-lock/lock/lock.go Outdated
Comment on lines +66 to +67
if err != nil {
return fmt.Errorf("enable SFS project lock: %w", err)
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.

In case some executes this lock command on a project which has already a lock, the API responds with 409. I would suggest to catch it here, similar like you did it in the describe command with the 404

GokceGK and others added 2 commits May 5, 2026 15:48
Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com>
Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock 0.00% (ø)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/describe 45.24% (+45.24%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/lock 40.54% (+40.54%) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/unlock 31.25% (+31.25%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/describe/describe.go 45.24% (+45.24%) 42 (+42) 19 (+19) 23 (+23) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/lock/lock.go 40.54% (+40.54%) 37 (+37) 15 (+15) 22 (+22) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/project-lock.go 0.00% (ø) 6 (+6) 0 6 (+6)
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/unlock/unlock.go 31.25% (+31.25%) 32 (+32) 10 (+10) 22 (+22) 🌟
github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/sfs.go 0.00% (ø) 9 (+1) 0 9 (+1)

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/sfs/project-lock/describe/describe_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/lock/lock_test.go
  • github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs/project-lock/unlock/unlock_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