mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-05 14:31:27 +02:00
Always require a client for running a worker (#52)
* Always require a client for running a worker * Actually validate roles * Delete worker Fixes #46 * Update internal/worker/worker.go Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com> --------- Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
This commit is contained in:
co-authored by
Nikolay Edigaryev
parent
af074f499d
commit
362ea85b4f
@@ -10,7 +10,7 @@ func NewCommand() *cobra.Command {
|
||||
Short: "Delete resources from the controller",
|
||||
}
|
||||
|
||||
command.AddCommand(newDeleteVMCommand(), newDeleteServiceComandCommand())
|
||||
command.AddCommand(newDeleteVMCommand(), newDeleteServiceComandCommand(), newDeleteWorkerCommand())
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package deletecmd
|
||||
|
||||
import (
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newDeleteWorkerCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "worker NAME",
|
||||
Short: "Delete a worker",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: runDeleteWorker,
|
||||
}
|
||||
}
|
||||
|
||||
func runDeleteWorker(cmd *cobra.Command, args []string) error {
|
||||
name := args[0]
|
||||
|
||||
client, err := client.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return client.Workers().Delete(cmd.Context(), name)
|
||||
}
|
||||
Reference in New Issue
Block a user