Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
delete project
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric Kienzler committed Mar 9, 2021
1 parent c6c11da commit 16c1b94
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"mode": "debug",
"program": "${workspaceFolder}/main.go",
"args": [
//"add", "project", "kkpctltest", "--labels", "stage=dev",
"describe", "project", "vhkbdlstlt",
"-o", "text"
"get", "project", "--all"
//"add", "project", "kkpctltest", "--labels", "stage=dev"
//"describe", "project", "vhkbdlstlt"
//"delete", "project", "r64pgz4cbw"
]
}
]
Expand Down
16 changes: 16 additions & 0 deletions cmd/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cmd

import (
"github.com/spf13/cobra"
)

// getCmd represents the get command
var deleteCmd = &cobra.Command{
Use: "delete",
Aliases: []string{"del"},
Short: "Get lets you fetch a list or a specific named object.",
}

func init() {
rootCmd.AddCommand(deleteCmd)
}
34 changes: 34 additions & 0 deletions cmd/delete_project.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd

import (
"fmt"

"github.com/cedi/kkpctl/pkg/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

// delProjectsCmd represents the projects command
var delProjectsCmd = &cobra.Command{
Use: "project [projectid]",
Short: "Delete a project.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
kkp, err := client.NewClient(baseURL, apiToken)
if err != nil {
return errors.New("Could not initialize Kubermatic API client")
}

err = kkp.DeleteProject(args[0])
if err != nil {
return errors.Wrap(err, "Error fetching project")
}

fmt.Printf("Successfully deleted Project %s", args[0])
return nil
},
}

func init() {
deleteCmd.AddCommand(delProjectsCmd)
}
File renamed without changes.

0 comments on commit 16c1b94

Please sign in to comment.