Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/stackit_beta_sfs_export-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stackit beta sfs export-policy [flags]
* [stackit beta sfs](./stackit_beta_sfs.md) - Provides functionality for SFS (stackit file storage)
* [stackit beta sfs export-policy create](./stackit_beta_sfs_export-policy_create.md) - Creates a export policy
* [stackit beta sfs export-policy delete](./stackit_beta_sfs_export-policy_delete.md) - Deletes a export policy
* [stackit beta sfs export-policy describe](./stackit_beta_sfs_export-policy_describe.md) - Shows details of a export policy
* [stackit beta sfs export-policy describe](./stackit_beta_sfs_export-policy_describe.md) - Shows details of an export policy
* [stackit beta sfs export-policy list](./stackit_beta_sfs_export-policy_list.md) - Lists all export policies of a project
* [stackit beta sfs export-policy update](./stackit_beta_sfs_export-policy_update.md) - Updates a export policy
* [stackit beta sfs export-policy update](./stackit_beta_sfs_export-policy_update.md) - Updates an export policy

2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_export-policy_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stackit beta sfs export-policy delete EXPORT_POLICY_ID [flags]
### Examples

```
Delete a export policy with ID "xxx"
Delete an export policy with ID "xxx"
$ stackit beta sfs export-policy delete xxx
```

Expand Down
6 changes: 3 additions & 3 deletions docs/stackit_beta_sfs_export-policy_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## stackit beta sfs export-policy describe

Shows details of a export policy
Shows details of an export policy

### Synopsis

Shows details of a export policy.
Shows details of an export policy.

```
stackit beta sfs export-policy describe EXPORT_POLICY_ID [flags]
Expand All @@ -13,7 +13,7 @@ stackit beta sfs export-policy describe EXPORT_POLICY_ID [flags]
### Examples

```
Describe a export policy with ID "xxx"
Describe an export policy with ID "xxx"
$ stackit beta sfs export-policy describe xxx
```

Expand Down
8 changes: 4 additions & 4 deletions docs/stackit_beta_sfs_export-policy_update.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## stackit beta sfs export-policy update

Updates a export policy
Updates an export policy

### Synopsis

Updates a export policy.
Updates an export policy.

```
stackit beta sfs export-policy update EXPORT_POLICY_ID [flags]
Expand All @@ -13,10 +13,10 @@ stackit beta sfs export-policy update EXPORT_POLICY_ID [flags]
### Examples

```
Update a export policy with ID "xxx" and with rules from file "./rules.json"
Update an export policy with ID "xxx" and with rules from file "./rules.json"
$ stackit beta sfs export-policy update xxx --rules @./rules.json

Update a export policy with ID "xxx" and remove the rules
Update an export policy with ID "xxx" and remove the rules
$ stackit beta sfs export-policy update XXX --remove-rules
```

Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_resource-pool_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stackit beta sfs resource-pool create [flags]
--ip-acl strings List of network addresses in the form <address/prefix>, e.g. 192.168.10.0/24 that can mount the resource pool readonly (default [])
--name string Name
--performance-class string Performance class
--size int Size of the pool in Gigabytes
--size int32 Size of the pool in Gigabytes
--snapshots-visible Set snapshots visible and accessible to users
```

Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_resource-pool_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ stackit beta sfs resource-pool update [flags]
-h, --help Help for "stackit beta sfs resource-pool update"
--ip-acl strings List of network addresses in the form <address/prefix>, e.g. 192.168.10.0/24 that can mount the resource pool readonly (default [])
--performance-class string Performance class
--size int Size of the pool in Gigabytes
--size int32 Size of the pool in Gigabytes
--snapshots-visible Set snapshots visible and accessible to users
```

Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_share_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stackit beta sfs share create [flags]

```
--export-policy-name string The export policy the share is assigned to
--hard-limit int The space hard limit for the share
--hard-limit int32 The space hard limit for the share
-h, --help Help for "stackit beta sfs share create"
--name string Share name
--resource-pool-id string The resource pool the share is assigned to
Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_share_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stackit beta sfs share describe SHARE_ID [flags]

```
Describe a shares with ID "xxx" from resource pool with ID "yyy"
$ stackit beta sfs export-policy describe xxx --resource-pool-id yyy
$ stackit beta sfs share describe xxx --resource-pool-id yyy
```

### Options
Expand Down
4 changes: 2 additions & 2 deletions docs/stackit_beta_sfs_share_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ stackit beta sfs share list [flags]

```
List all shares from resource pool with ID "xxx"
$ stackit beta sfs export-policy list --resource-pool-id xxx
$ stackit beta sfs share list --resource-pool-id xxx

List up to 10 shares from resource pool with ID "xxx"
$ stackit beta sfs export-policy list --resource-pool-id xxx --limit 10
$ stackit beta sfs share list --resource-pool-id xxx --limit 10
```

### Options
Expand Down
2 changes: 1 addition & 1 deletion docs/stackit_beta_sfs_share_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stackit beta sfs share update SHARE_ID [flags]

```
--export-policy-name string The export policy the share is assigned to
--hard-limit int The space hard limit for the share
--hard-limit int32 The space hard limit for the share
-h, --help Help for "stackit beta sfs share update"
--resource-pool-id string The resource pool the share is assigned to
```
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stackitcloud/stackit-sdk-go/core v0.23.0
github.com/stackitcloud/stackit-sdk-go/core v0.26.0
github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.10.0
Expand Down Expand Up @@ -272,7 +272,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/sys v0.43.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0=
github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
github.com/stackitcloud/stackit-sdk-go/core v0.23.0 h1:zPrOhf3Xe47rKRs1fg/AqKYUiJJRYjdcv+3qsS50mEs=
github.com/stackitcloud/stackit-sdk-go/core v0.23.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA=
github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA=
github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0 h1:V9+885qkSv621rZZatg1YE5ENM1ElALxQDJsh+hDIUg=
github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0/go.mod h1:V6+MolxM/M2FWyWZA+FRFKEzzUe10MU9eEVfMvxHGi8=
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu04j5tj6nfZ2r0l6v4VXC0/tYOGe4sA5Addra8=
Expand Down Expand Up @@ -650,8 +650,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIl
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0/go.mod h1:EXq8/J7t9p8zPmdIq+atuxyAbnQwxrQT18fI+Qpv98k=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 h1:M2PYLF8k3zmAwYWSKfUiCTNTXr7ROGuJganVVEQA3YI=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7/go.mod h1:jitkQuP2K/SH63Qor0C4pcqz1GDCy/lK2H4t8/VDse4=
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0 h1:ofdGO2dGH6ywKbIVxaxRVal3jWX9WlcHSm5BTud5bC4=
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0/go.mod h1:r5lBwzJpJe2xBIYctkVIIpaZ41Y6vUEpkmsWR2VoQJs=
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZcAMCC+p5hyTEkAyxqFwy39jFA=
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0/go.mod h1:jMlBoXqrPNX5nXbo6oT7exalqilw1jiLPoIp4Cn0CdI=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 h1:QoKyQPe8FqDqJLNgE5uRlZ/y1c1GUxjV1DDLu5QEBD8=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0/go.mod h1:KhVYCR58wETqdI7Quwhe3OR3BhB2T/b7DzaMsfDnr8g=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.4.3 h1:AQrcr+qeIuZob+3TT2q1L4WOPtpsu5SEpkTnOUHDqfE=
Expand Down
18 changes: 9 additions & 9 deletions internal/cmd/beta/sfs/export-policy/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/sfs"
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand All @@ -28,7 +28,7 @@ const (
type inputModel struct {
*globalflags.GlobalFlagModel
Name string
Rules *[]sfs.CreateShareExportPolicyRequestRule
Rules []sfs.CreateShareExportPolicyRequestRule
}

func NewCmd(params *types.CmdParams) *cobra.Command {
Expand Down Expand Up @@ -102,15 +102,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
return nil, &errors.ProjectIdError{}
}

rulesString := flags.FlagToStringPointer(p, cmd, rulesFlag)
var rules *[]sfs.CreateShareExportPolicyRequestRule
if rulesString != nil && *rulesString != "" {
rulesString := flags.FlagToStringValue(p, cmd, rulesFlag)
var rules []sfs.CreateShareExportPolicyRequestRule
if rulesString != "" {
var r []sfs.CreateShareExportPolicyRequestRule
err := json.Unmarshal([]byte(*rulesString), &r)
err := json.Unmarshal([]byte(rulesString), &r)
if err != nil {
return nil, fmt.Errorf("could not parse rules: %w", err)
}
rules = &r
rules = r
}

model := inputModel{
Expand All @@ -124,10 +124,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiCreateShareExportPolicyRequest {
req := apiClient.CreateShareExportPolicy(ctx, model.ProjectId, model.Region)
req := apiClient.DefaultAPI.CreateShareExportPolicy(ctx, model.ProjectId, model.Region)
req = req.CreateShareExportPolicyPayload(
sfs.CreateShareExportPolicyPayload{
Name: utils.Ptr(model.Name),
Name: model.Name,
Rules: model.Rules,
},
)
Expand Down
40 changes: 20 additions & 20 deletions internal/cmd/beta/sfs/export-policy/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/sfs"
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
Expand All @@ -21,13 +21,13 @@ var regionFlag = globalflags.RegionFlag
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &sfs.APIClient{}
var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}}

var testProjectId = uuid.NewString()
var testRegion = "eu01"
var testName = "test-name"
var testRulesString = "[]"
var testRules = &[]sfs.CreateShareExportPolicyRequestRule{}
var testRules = []sfs.CreateShareExportPolicyRequestRule{}

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
Expand Down Expand Up @@ -59,18 +59,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
return model
}

func fixtureRequest(mods ...func(request *sfs.ApiCreateShareExportPolicyRequest)) sfs.ApiCreateShareExportPolicyRequest {
request := testClient.CreateShareExportPolicy(testCtx, testProjectId, testRegion)
func fixtureRequest(mods ...func(request sfs.ApiCreateShareExportPolicyRequest)) sfs.ApiCreateShareExportPolicyRequest {
request := testClient.DefaultAPI.CreateShareExportPolicy(testCtx, testProjectId, testRegion)
request = request.CreateShareExportPolicyPayload(fixturePayload())
for _, mod := range mods {
mod(&request)
mod(request)
}
return request
}

func fixturePayload(mods ...func(payload *sfs.CreateShareExportPolicyPayload)) sfs.CreateShareExportPolicyPayload {
payload := sfs.CreateShareExportPolicyPayload{
Name: utils.Ptr(testName),
Name: testName,
Rules: testRules,
}
for _, mod := range mods {
Expand Down Expand Up @@ -110,20 +110,20 @@ func TestParseInput(t *testing.T) {
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.Rules = &[]sfs.CreateShareExportPolicyRequestRule{
model.Rules = []sfs.CreateShareExportPolicyRequestRule{
{
Description: sfs.NewNullableString(
utils.Ptr("first rule"),
),
IpAcl: utils.Ptr([]string{"192.168.2.0/24"}),
Order: utils.Ptr(int64(1)),
SetUuid: utils.Ptr(true),
SuperUser: utils.Ptr(false),
Description: *sfs.NewNullableString(utils.Ptr("first rule")),
IpAcl: []string{"192.168.2.0/24"},
Order: utils.Ptr(int32(1)),
SetUuid: utils.Ptr(true),
SuperUser: utils.Ptr(false),
AdditionalProperties: map[string]any{},
},
{
IpAcl: utils.Ptr([]string{"192.168.2.0/24", "127.0.0.1/32"}),
Order: utils.Ptr(int64(2)),
ReadOnly: utils.Ptr(true),
IpAcl: []string{"192.168.2.0/24", "127.0.0.1/32"},
Order: utils.Ptr(int32(2)),
ReadOnly: utils.Ptr(true),
AdditionalProperties: map[string]any{"readonly": true},
},
}
}),
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestBuildRequest(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestOutputResult(t *testing.T) {
name: "set empty export policy",
args: args{
exportPolicy: &sfs.CreateShareExportPolicyResponse{
ShareExportPolicy: &sfs.CreateShareExportPolicyResponseShareExportPolicy{},
ShareExportPolicy: &sfs.ShareExportPolicy{},
},
},
wantErr: false,
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/export-policy/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/sfs"
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand Down Expand Up @@ -33,7 +33,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
Args: args.SingleArg(exportPolicyIdArg, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(
`Delete a export policy with ID "xxx"`,
`Delete an export policy with ID "xxx"`,
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.

nice catch!

"$ stackit beta sfs export-policy delete xxx",
),
),
Expand All @@ -49,7 +49,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient, model.ProjectId, model.Region, model.ExportPolicyId)
exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ExportPolicyId)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get export policy name: %v", err)
exportPolicyLabel = model.ExportPolicyId
Expand Down Expand Up @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiDeleteShareExportPolicyRequest {
return apiClient.DeleteShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId)
return apiClient.DefaultAPI.DeleteShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId)
}

func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/export-policy/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/sfs"
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
Expand All @@ -19,7 +19,7 @@ var regionFlag = globalflags.RegionFlag
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &sfs.APIClient{}
var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}}

var testProjectId = uuid.NewString()
var testRegion = "eu01"
Expand Down Expand Up @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *sfs.ApiDeleteShareExportPolicyRequest)) sfs.ApiDeleteShareExportPolicyRequest {
request := testClient.DeleteShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId)
request := testClient.DefaultAPI.DeleteShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestBuildRequest(t *testing.T) {
request := buildRequest(testCtx, tt.model, testClient)

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}),
cmpopts.EquateComparable(testCtx),
)
if diff != "" {
Expand Down
Loading
Loading