Introduce service accounts and bootstrap tokens (#22)

This commit is contained in:
Nikolay Edigaryev
2023-02-21 11:34:12 -05:00
committed by GitHub
parent edb9b3d693
commit 8df31f7c2d
37 changed files with 1245 additions and 40 deletions
+2 -2
View File
@@ -9,10 +9,10 @@ var quiet bool
func NewCommand() *cobra.Command {
command := &cobra.Command{
Use: "list",
Short: "List resources on the controller (workers, VMs)",
Short: "List resources on the controller",
}
command.AddCommand(newListWorkersCommand(), newListVMsCommand())
command.AddCommand(newListWorkersCommand(), newListVMsCommand(), newListServiceAccountsCommand())
command.PersistentFlags().BoolVarP(&quiet, "", "q", false, "only show resource names")
+57
View File
@@ -0,0 +1,57 @@
package list
import (
"fmt"
"github.com/cirruslabs/orchard/pkg/client"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"strings"
)
func newListServiceAccountsCommand() *cobra.Command {
command := &cobra.Command{
Use: "service-accounts",
Short: "List service accounts",
RunE: runListServiceAccounts,
}
return command
}
func runListServiceAccounts(cmd *cobra.Command, args []string) error {
client, err := client.New()
if err != nil {
return err
}
serviceAccounts, err := client.ServiceAccounts().List(cmd.Context())
if err != nil {
return err
}
if quiet {
for _, serviceAccount := range serviceAccounts {
fmt.Println(serviceAccount.Name)
}
return nil
}
table := uitable.New()
table.AddRow("Name", "Roles")
for _, serviceAccount := range serviceAccounts {
var scopeList []string
for _, scope := range serviceAccount.Roles {
scopeList = append(scopeList, string(scope))
}
table.AddRow(serviceAccount.Name, strings.Join(scopeList, ", "))
}
fmt.Println(table)
return nil
}
+3 -2
View File
@@ -9,8 +9,9 @@ import (
func newListVMsCommand() *cobra.Command {
command := &cobra.Command{
Use: "vms",
RunE: runListVMs,
Use: "vms",
Short: "List VMs",
RunE: runListVMs,
}
return command