Skip to content

Commit 5aa1caa

Browse files
committed
feat(server): create security-group attach and detach command scaffolds
1 parent d7b130e commit 5aa1caa

6 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package attach
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
6+
)
7+
8+
func NewCmd(params *types.CmdParams) *cobra.Command {
9+
cmd := &cobra.Command{
10+
Use: "attach",
11+
Short: "Attach a security group to a server",
12+
Long: "Attach a security group to a server.",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
params.Printer.Info("Attaching security group to server...")
15+
},
16+
}
17+
return cmd
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package attach
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package detach
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
6+
)
7+
8+
func NewCmd(params *types.CmdParams) *cobra.Command {
9+
cmd := &cobra.Command{
10+
Use: "detach",
11+
Short: "Detach a security group from a server",
12+
Long: "Detach a security group from a server.",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
params.Printer.Info("Detaching security group from server...")
15+
},
16+
}
17+
return cmd
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package detach
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package securitygroup
2+
3+
import (
4+
"github.com/stackitcloud/stackit-cli/internal/cmd/server/security-group/attach"
5+
"github.com/stackitcloud/stackit-cli/internal/cmd/server/security-group/detach"
6+
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
7+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
8+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
9+
10+
"github.com/spf13/cobra"
11+
)
12+
13+
func NewCmd(params *types.CmdParams) *cobra.Command {
14+
cmd := &cobra.Command{
15+
Use: "security-group",
16+
Short: "Allows attaching/detaching security groups to servers",
17+
Long: "Allows attaching/detaching security groups to servers.",
18+
Args: args.NoArgs,
19+
Run: utils.CmdHelp,
20+
}
21+
addSubcommands(cmd, params)
22+
return cmd
23+
}
24+
25+
func addSubcommands(cmd *cobra.Command, params *types.CmdParams) {
26+
cmd.AddCommand(attach.NewCmd(params))
27+
cmd.AddCommand(detach.NewCmd(params))
28+
}

internal/cmd/server/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/stackitcloud/stackit-cli/internal/cmd/server/reboot"
1818
"github.com/stackitcloud/stackit-cli/internal/cmd/server/rescue"
1919
"github.com/stackitcloud/stackit-cli/internal/cmd/server/resize"
20+
securitygroup "github.com/stackitcloud/stackit-cli/internal/cmd/server/security-group"
2021
serviceaccount "github.com/stackitcloud/stackit-cli/internal/cmd/server/service-account"
2122
"github.com/stackitcloud/stackit-cli/internal/cmd/server/start"
2223
"github.com/stackitcloud/stackit-cli/internal/cmd/server/stop"
@@ -51,6 +52,7 @@ func addSubcommands(cmd *cobra.Command, params *types.CmdParams) {
5152
cmd.AddCommand(describe.NewCmd(params))
5253
cmd.AddCommand(list.NewCmd(params))
5354
cmd.AddCommand(publicip.NewCmd(params))
55+
cmd.AddCommand(securitygroup.NewCmd(params))
5456
cmd.AddCommand(serviceaccount.NewCmd(params))
5557
cmd.AddCommand(update.NewCmd(params))
5658
cmd.AddCommand(volume.NewCmd(params))

0 commit comments

Comments
 (0)