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
3 changes: 2 additions & 1 deletion docs/stackit_git_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ stackit git instance [flags]
* [stackit git](./stackit_git.md) - Provides functionality for STACKIT Git
* [stackit git instance create](./stackit_git_instance_create.md) - Creates STACKIT Git instance
* [stackit git instance delete](./stackit_git_instance_delete.md) - Deletes STACKIT Git instance
* [stackit git instance describe](./stackit_git_instance_describe.md) - Describes STACKIT Git instance
* [stackit git instance describe](./stackit_git_instance_describe.md) - Shows details of a STACKIT Git instance
* [stackit git instance list](./stackit_git_instance_list.md) - Lists all instances of STACKIT Git
* [stackit git instance update](./stackit_git_instance_update.md) - Updates STACKIT Git instance

2 changes: 1 addition & 1 deletion docs/stackit_git_instance_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stackit git instance create [flags]
### Options

```
--acl strings Acl for the instance.
--acl strings List of IP networks in CIDR notation which are allowed to access this instance (default [])
--flavor string Flavor of the instance.
-h, --help Help for "stackit git instance create"
--name string The name of the instance.
Expand Down
11 changes: 7 additions & 4 deletions docs/stackit_git_instance_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## stackit git instance describe

Describes STACKIT Git instance
Shows details of a STACKIT Git instance

### Synopsis

Describes a STACKIT Git instance by its internal ID.
Shows details of a STACKIT Git instance.

```
stackit git instance describe INSTANCE_ID [flags]
Expand All @@ -13,8 +13,11 @@ stackit git instance describe INSTANCE_ID [flags]
### Examples

```
Describe instance "xxx"
$ stackit git describe xxx
Get details of a STACKIT Git instance with ID "xxx"
$ stackit git instance describe xxx

Get details of a STACKIT Git instance with ID "xxx" in JSON format
$ stackit git instance describe xxx --output-format json
```

### Options
Expand Down
44 changes: 44 additions & 0 deletions docs/stackit_git_instance_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## stackit git instance update

Updates STACKIT Git instance

### Synopsis

Updates a STACKIT Git instance.

```
stackit git instance update INSTANCE_ID [flags]
```

### Examples

```
Update the ACL of the instance with ID "xxx"
$ stackit git instance update xxx --acl 1.2.3.0/24

Update the ACL of the instance with ID "xxx" with multiple ranges
$ stackit git instance update xxx --acl 1.2.3.0/24,4.5.6.0/24
```

### Options

```
--acl strings List of IP networks in CIDR notation which are allowed to access this instance. Replaces the existing ACL. (default [])
-h, --help Help for "stackit git instance update"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit git instance](./stackit_git_instance.md) - Provides functionality for STACKIT Git instances

6 changes: 3 additions & 3 deletions internal/cmd/git/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

result, err := request.Execute()
if err != nil {
return fmt.Errorf("create stackit git instance: %w", err)
return fmt.Errorf("create STACKIT Git instance: %w", err)
}

// Wait for async operation, if async mode not enabled
Expand All @@ -88,7 +88,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
})
if err != nil {
return fmt.Errorf("wait for stackit git Instance creation: %w", err)
return fmt.Errorf("wait for STACKIT Git instance creation: %w", err)
}
}

Expand All @@ -103,7 +103,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(nameFlag, "", "The name of the instance.")
cmd.Flags().String(flavorFlag, "", "Flavor of the instance.")
cmd.Flags().StringSlice(aclFlag, []string{}, "Acl for the instance.")
cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "List of IP networks in CIDR notation which are allowed to access this instance")
if err := flags.MarkFlagsRequired(cmd, nameFlag); err != nil {
cobra.CheckErr(err)
}
Expand Down
17 changes: 17 additions & 0 deletions internal/cmd/git/instance/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ func TestParseInput(t *testing.T) {
}),
isValid: false,
},
{
description: "multiple acl entries",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[aclFlag] = "1.2.3.0/24,4.5.6.0/24"
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.Acl = []string{"1.2.3.0/24", "4.5.6.0/24"}
}),
},
{
description: "invalid acl",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[aclFlag] = "invalid-cidr"
}),
isValid: false,
},
}

for _, tt := range tests {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/git/instance/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

instanceName, err := gitUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get stackit git instance name: %v", err)
params.Printer.Debug(print.ErrorLevel, "get STACKIT Git instance name: %v", err)
instanceName = model.InstanceId
} else if instanceName == "" {
instanceName = model.InstanceId
}

prompt := fmt.Sprintf("Are you sure you want to delete the stackit git instance %q for %q?", instanceName, projectName)
prompt := fmt.Sprintf("Are you sure you want to delete the STACKIT Git instance %q for %q?", instanceName, projectName)
err = params.Printer.PromptForConfirmation(prompt)
if err != nil {
return err
Expand All @@ -87,15 +87,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
})
if err != nil {
return fmt.Errorf("wait for stackit git instance deletion: %w", err)
return fmt.Errorf("wait for STACKIT Git instance deletion: %w", err)
}
}

operationState := "Deleted"
if model.Async {
operationState = "Triggered deletion of"
}
params.Printer.Info("%s stackit git instance %s \n", operationState, model.InstanceId)
params.Printer.Info("%s STACKIT Git instance %s \n", operationState, model.InstanceId)

return nil
},
Expand Down
18 changes: 15 additions & 3 deletions internal/cmd/git/instance/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package describe
import (
"context"
"fmt"
"strings"

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

Expand All @@ -29,11 +30,16 @@ const instanceIdArg = "INSTANCE_ID"
func NewCmd(params *types.CmdParams) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("describe %s", instanceIdArg),
Short: "Describes STACKIT Git instance",
Long: "Describes a STACKIT Git instance by its internal ID.",
Short: "Shows details of a STACKIT Git instance",
Long: "Shows details of a STACKIT Git instance.",
Args: args.SingleArg(instanceIdArg, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(`Describe instance "xxx"`, `$ stackit git describe xxx`),
examples.NewExample(
`Get details of a STACKIT Git instance with ID "xxx"`,
`$ stackit git instance describe xxx`),
examples.NewExample(
`Get details of a STACKIT Git instance with ID "xxx" in JSON format`,
`$ stackit git instance describe xxx --output-format json`),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -102,10 +108,16 @@ func outputResult(p *print.Printer, outputFormat string, resp *git.Instance) err
table.AddSeparator()
table.AddRow("VERSION", resp.Version)
table.AddSeparator()
table.AddRow("FLAVOR", resp.Flavor)
table.AddSeparator()
table.AddRow("STATE", resp.State)
table.AddSeparator()
table.AddRow("CREATED", resp.Created)
table.AddSeparator()
if len(resp.Acl) > 0 {
table.AddRow("ACL", strings.Join(resp.Acl, ","))
table.AddSeparator()
}

if err := table.Display(p); err != nil {
return fmt.Errorf("render table: %w", err)
Expand Down
9 changes: 9 additions & 0 deletions internal/cmd/git/instance/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ func TestOutputResult(t *testing.T) {
},
wantErr: false,
},
{
name: "with acl",
args: args{
resp: &git.Instance{
Acl: []string{"1.2.3.0/24", "4.5.6.0/24"},
},
},
wantErr: false,
},
{
name: "nil",
args: args{},
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/git/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/delete"
"github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/describe"
"github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/list"
"github.com/stackitcloud/stackit-cli/internal/cmd/git/instance/update"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
Expand All @@ -30,5 +31,6 @@ func addSubcommands(cmd *cobra.Command, params *types.CmdParams) {
describe.NewCmd(params),
create.NewCmd(params),
delete.NewCmd(params),
update.NewCmd(params),
)
}
Loading
Loading