Skip to content

Commit 3a244d9

Browse files
committed
feat: delete k8s integration
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
1 parent 8520920 commit 3a244d9

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

pkg/cli/integrations_kubernetes.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ var integrationsKubernetesCmd = &cobra.Command{
1414
}
1515

1616
var integrationsKubernetesList = &cobra.Command{
17-
Use: "list",
18-
Short: "List integrations",
17+
Use: "list",
18+
Aliases: []string{"ls"},
19+
Args: cobra.ExactArgs(0),
20+
Short: "List integrations",
1921
RunE: func(cmd *cobra.Command, args []string) error {
2022
client, err := api.NewAPIClient()
2123
if err != nil {
@@ -40,3 +42,35 @@ var integrationsKubernetesList = &cobra.Command{
4042
return nil
4143
},
4244
}
45+
46+
var integrationsKubernetesDelete = &cobra.Command{
47+
Use: "delete",
48+
Aliases: []string{"del"},
49+
Args: cobra.ExactArgs(1),
50+
Short: "Delete integration given an id",
51+
RunE: func(cmd *cobra.Command, args []string) error {
52+
id := args[0]
53+
client, err := api.NewAPIClient()
54+
if err != nil {
55+
return err
56+
}
57+
res, err := client.DeleteV1IntegrationsKubernetesIdWithResponse(context.Background(), id)
58+
if err != nil {
59+
return err
60+
}
61+
if res.JSON200 != nil {
62+
print(res.JSON200, func() {
63+
fmt.Println("Integration deleted")
64+
})
65+
} else if res.JSON404 != nil {
66+
print(res.JSON404, func() {
67+
fmt.Println("Integration not found")
68+
})
69+
} else if res.JSON500 != nil {
70+
print(res.JSON500, func() {
71+
fmt.Println("Error deleting integration", res.JSON500.Message)
72+
})
73+
}
74+
return nil
75+
},
76+
}

pkg/cli/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func Run() error {
7878
integrationsAkamaiCmd.AddCommand(integrationsAkamaiList)
7979
integrationsCmd.AddCommand(integrationsKubernetesCmd)
8080
integrationsKubernetesCmd.AddCommand(integrationsKubernetesList)
81+
integrationsKubernetesCmd.AddCommand(integrationsKubernetesDelete)
8182

8283
return rootCmd.Execute()
8384
}

0 commit comments

Comments
 (0)