Skip to content

Commit a17914a

Browse files
Merge pull request #1 from ctrlplanedev/release-channel-delete
fix: Delete release channel
2 parents 5f9777a + fa559d7 commit a17914a

File tree

3 files changed

+206
-0
lines changed

3 files changed

+206
-0
lines changed

cmd/ctrlc/root/api/delete/delete.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package delete
22

33
import (
44
"github.com/ctrlplanedev/cli/cmd/ctrlc/root/api/delete/environment"
5+
"github.com/ctrlplanedev/cli/cmd/ctrlc/root/api/delete/releasechannel"
56
"github.com/ctrlplanedev/cli/cmd/ctrlc/root/api/delete/resource"
67
"github.com/spf13/cobra"
78
)
@@ -18,6 +19,7 @@ func NewDeleteCmd() *cobra.Command {
1819

1920
cmd.AddCommand(resource.NewDeleteResourceCmd())
2021
cmd.AddCommand(environment.NewDeleteEnvironmentCmd())
22+
cmd.AddCommand(releasechannel.NewDeleteReleaseChannelCmd())
2123

2224
return cmd
2325
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package releasechannel
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/MakeNowJust/heredoc/v2"
7+
"github.com/ctrlplanedev/cli/internal/api"
8+
"github.com/ctrlplanedev/cli/internal/cliutil"
9+
"github.com/spf13/cobra"
10+
"github.com/spf13/viper"
11+
)
12+
13+
func NewDeleteReleaseChannelCmd() *cobra.Command {
14+
var deploymentId string
15+
var name string
16+
17+
cmd := &cobra.Command{
18+
Use: "release-channel [flags]",
19+
Short: "Delete a release channel",
20+
Long: `Delete a release channel by specifying a deployment ID and a name.`,
21+
Example: heredoc.Doc(`
22+
$ ctrlc delete release-channel --deployment 123e4567-e89b-12d3-a456-426614174000 --name mychannel
23+
`),
24+
RunE: func(cmd *cobra.Command, args []string) error {
25+
if deploymentId == "" || name == "" {
26+
return fmt.Errorf("deployment and name are required")
27+
}
28+
29+
apiURL := viper.GetString("url")
30+
apiKey := viper.GetString("api-key")
31+
client, err := api.NewAPIKeyClientWithResponses(apiURL, apiKey)
32+
if err != nil {
33+
return fmt.Errorf("failed to create API client: %w", err)
34+
}
35+
resp, err := client.DeleteReleaseChannel(cmd.Context(), deploymentId, name)
36+
if err != nil {
37+
return fmt.Errorf("failed to delete release channel: %w", err)
38+
}
39+
40+
return cliutil.HandleOutput(cmd, resp)
41+
},
42+
}
43+
44+
cmd.Flags().StringVar(&deploymentId, "deployment", "", "Deployment ID")
45+
cmd.Flags().StringVar(&name, "name", "", "Release channel name")
46+
47+
return cmd
48+
}

internal/api/client.gen.go

Lines changed: 156 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)