Skip to content

Commit d98e51a

Browse files
committed
feat(git): Add update command for ACLs
Extend describe command to show ACLs. STACKITCLI-555 Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
1 parent 06d6e5b commit d98e51a

13 files changed

Lines changed: 504 additions & 7 deletions

‎docs/stackit_git_instance.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ stackit git instance [flags]
3434
* [stackit git instance delete](./stackit_git_instance_delete.md) - Deletes STACKIT Git instance
3535
* [stackit git instance describe](./stackit_git_instance_describe.md) - Describes STACKIT Git instance
3636
* [stackit git instance list](./stackit_git_instance_list.md) - Lists all instances of STACKIT Git
37+
* [stackit git instance update](./stackit_git_instance_update.md) - Updates STACKIT Git instance
3738

‎docs/stackit_git_instance_create.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ stackit git instance create [flags]
2626
### Options
2727

2828
```
29-
--acl strings Acl for the instance.
29+
--acl strings List of IP networks in CIDR notation which are allowed to access this instance (default [])
3030
--flavor string Flavor of the instance.
3131
-h, --help Help for "stackit git instance create"
3232
--name string The name of the instance.

‎docs/stackit_git_instance_describe.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ stackit git instance describe INSTANCE_ID [flags]
1414

1515
```
1616
Describe instance "xxx"
17-
$ stackit git describe xxx
17+
$ stackit git instance describe xxx
1818
```
1919

2020
### Options
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## stackit git instance update
2+
3+
Updates STACKIT Git instance
4+
5+
### Synopsis
6+
7+
Updates a STACKIT Git instance.
8+
9+
```
10+
stackit git instance update INSTANCE_ID [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Update the ACL of the instance with ID "xxx"
17+
$ stackit git instance update xxx --acl 1.2.3.0/24
18+
19+
Update the ACL of the instance with ID "xxx" with multiple ranges
20+
$ stackit git instance update xxx --acl 1.2.3.0/24,4.5.6.0/24
21+
```
22+
23+
### Options
24+
25+
```
26+
--acl strings List of IP networks in CIDR notation which are allowed to access this instance. Replaces the existing ACL. (default [])
27+
-h, --help Help for "stackit git instance update"
28+
```
29+
30+
### Options inherited from parent commands
31+
32+
```
33+
-y, --assume-yes If set, skips all confirmation prompts
34+
--async If set, runs the command asynchronously
35+
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
36+
-p, --project-id string Project ID
37+
--region string Target region for region-specific requests
38+
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
39+
```
40+
41+
### SEE ALSO
42+
43+
* [stackit git instance](./stackit_git_instance.md) - Provides functionality for STACKIT Git instances
44+

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.22.0
2424
github.com/stackitcloud/stackit-sdk-go/services/dns v0.25.0
2525
github.com/stackitcloud/stackit-sdk-go/services/edge v0.14.0
26-
github.com/stackitcloud/stackit-sdk-go/services/git v0.15.0
26+
github.com/stackitcloud/stackit-sdk-go/services/git v0.16.0
2727
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.1
2828
github.com/stackitcloud/stackit-sdk-go/services/intake v0.12.0
2929
github.com/stackitcloud/stackit-sdk-go/services/logs v0.12.0

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ github.com/stackitcloud/stackit-sdk-go/services/dns v0.25.0 h1:Yn4etadrdEEPU8Ycb
624624
github.com/stackitcloud/stackit-sdk-go/services/dns v0.25.0/go.mod h1:D0iv6XBYkaEwTjbBeom0VTZnwQMfwb48FC8R2jRg80c=
625625
github.com/stackitcloud/stackit-sdk-go/services/edge v0.14.0 h1:TTwlI34FUb0AisiApxKs5brGNP3Ma9cTvdmbxzNxs40=
626626
github.com/stackitcloud/stackit-sdk-go/services/edge v0.14.0/go.mod h1:FBBnDsQns6SjJYQrox3YSY7ydOa4T8FR3sXNwFRTsPc=
627-
github.com/stackitcloud/stackit-sdk-go/services/git v0.15.0 h1:yQq0J3nhfQ2V9yLhkYFLQ7sH02WoZvwWnBsILpwinzI=
628-
github.com/stackitcloud/stackit-sdk-go/services/git v0.15.0/go.mod h1:om68OYj0xYfMuSLEP4v/bg/kgqcFS6xDVApZXHlWr5E=
627+
github.com/stackitcloud/stackit-sdk-go/services/git v0.16.0 h1:M75DCyPbTzTx4mPdIkBvOVE3/6Eda0rp8xLm40d02qc=
628+
github.com/stackitcloud/stackit-sdk-go/services/git v0.16.0/go.mod h1:om68OYj0xYfMuSLEP4v/bg/kgqcFS6xDVApZXHlWr5E=
629629
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.1 h1:5D0ABveu3SZyB7DBkVJcCSS4fr1TiMmfdJA98TgDn/o=
630630
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.15.1/go.mod h1:o6Mt/ZUB/3qvIwtu4B57m9IlyaUxAFS2Tu5XImiZxCE=
631631
github.com/stackitcloud/stackit-sdk-go/services/intake v0.12.0 h1:1RDIGabA3U/kWrV0vkbkTof075liEHMdn39BsNwDI4k=

‎internal/cmd/git/instance/create/create.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
103103
func configureFlags(cmd *cobra.Command) {
104104
cmd.Flags().String(nameFlag, "", "The name of the instance.")
105105
cmd.Flags().String(flavorFlag, "", "Flavor of the instance.")
106-
cmd.Flags().StringSlice(aclFlag, []string{}, "Acl for the instance.")
106+
cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "List of IP networks in CIDR notation which are allowed to access this instance")
107107
if err := flags.MarkFlagsRequired(cmd, nameFlag); err != nil {
108108
cobra.CheckErr(err)
109109
}

‎internal/cmd/git/instance/create/create_test.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ func TestParseInput(t *testing.T) {
125125
}),
126126
isValid: false,
127127
},
128+
{
129+
description: "multiple acl entries",
130+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
131+
flagValues[aclFlag] = "1.2.3.0/24,4.5.6.0/24"
132+
}),
133+
isValid: true,
134+
expectedModel: fixtureInputModel(func(model *inputModel) {
135+
model.Acl = []string{"1.2.3.0/24", "4.5.6.0/24"}
136+
}),
137+
},
138+
{
139+
description: "invalid acl",
140+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
141+
flagValues[aclFlag] = "invalid-cidr"
142+
}),
143+
isValid: false,
144+
},
128145
}
129146

130147
for _, tt := range tests {

‎internal/cmd/git/instance/describe/describe.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package describe
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
89

@@ -33,7 +34,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
3334
Long: "Describes a STACKIT Git instance by its internal ID.",
3435
Args: args.SingleArg(instanceIdArg, utils.ValidateUUID),
3536
Example: examples.Build(
36-
examples.NewExample(`Describe instance "xxx"`, `$ stackit git describe xxx`),
37+
examples.NewExample(`Describe instance "xxx"`, `$ stackit git instance describe xxx`),
3738
),
3839
RunE: func(cmd *cobra.Command, args []string) error {
3940
ctx := context.Background()
@@ -102,10 +103,16 @@ func outputResult(p *print.Printer, outputFormat string, resp *git.Instance) err
102103
table.AddSeparator()
103104
table.AddRow("VERSION", resp.Version)
104105
table.AddSeparator()
106+
table.AddRow("FLAVOR", resp.Flavor)
107+
table.AddSeparator()
105108
table.AddRow("STATE", resp.State)
106109
table.AddSeparator()
107110
table.AddRow("CREATED", resp.Created)
108111
table.AddSeparator()
112+
if len(resp.Acl) > 0 {
113+
table.AddRow("ACL", strings.Join(resp.Acl, ","))
114+
table.AddSeparator()
115+
}
109116

110117
if err := table.Display(p); err != nil {
111118
return fmt.Errorf("render table: %w", err)

‎internal/cmd/git/instance/describe/describe_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ func TestOutputResult(t *testing.T) {
210210
},
211211
wantErr: false,
212212
},
213+
{
214+
name: "with acl",
215+
args: args{
216+
resp: &git.Instance{
217+
Acl: []string{"1.2.3.0/24", "4.5.6.0/24"},
218+
},
219+
},
220+
wantErr: false,
221+
},
213222
{
214223
name: "nil",
215224
args: args{},

0 commit comments

Comments
 (0)