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:
Fedor Korotkov
2023-03-24 17:44:20 +04:00
committed by GitHub
co-authored by Nikolay Edigaryev
parent af074f499d
commit 362ea85b4f
7 changed files with 51 additions and 31 deletions
+1 -1
View File
@@ -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
}
+26
View File
@@ -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)
}