Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/base/const.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package base

const (
ENDPOINT = "https://api.servers.com/v1"
ENDPOINT = "https://api.servers.com/v1"
ErrNoContexts = "no contexts found, log in first: 'srvctl login <context-name>' or, if you don't want to create the context, you may pass SC_TOKEN every time you use srvctl"
)
3 changes: 2 additions & 1 deletion cmd/base/hooks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package base

import (
"errors"
"fmt"
"html/template"
"os"
Expand Down Expand Up @@ -131,7 +132,7 @@ func CheckEmptyContexts(cmdContext *CmdContext) func(cmd *cobra.Command, args []
manager := cmdContext.GetManager()

if len(manager.GetContexts()) == 0 {
return fmt.Errorf("no contexts found, log in first: 'srvctl login <context-name>'")
return errors.New(ErrNoContexts)
}
return nil
}
Expand Down
18 changes: 17 additions & 1 deletion cmd/entities/hosts/drive-slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ func newListDSDriveSlotsCmd(cmdContext *base.CmdContext) *cobra.Command {
return base.NewListCmd("list-drive-slots <id>", "Dedicated server drive slots", factory, cmdContext, opts)
}

// TODO add list drive slots for KBM after adding KBMDriveSlots in go client
func newListKBMDriveSlotsCmd(cmdContext *base.CmdContext) *cobra.Command {
factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.HostDriveSlot] {
scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient()
if len(args) == 0 {
log.Fatal("Missing KBM node ID")
}
id := args[0]
return scClient.Hosts.KubernetesBaremetalNodeDriveSlots(id)
}

opts := base.NewListOptions(
&base.BaseListOptions[serverscom.HostDriveSlot]{},
&base.SearchPatternOption[serverscom.HostDriveSlot]{},
)

return base.NewListCmd("list-drive-slots <id>", "KBM node drive slots", factory, cmdContext, opts...)
}
2 changes: 2 additions & 0 deletions cmd/entities/hosts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
extraCmds: []func(*base.CmdContext) *cobra.Command{
newUpdateKBMCmd,
newListKBMCmd,
newListKBMNetworksCmd,
newListKBMDriveSlotsCmd,
},
},
{
Expand Down
Loading
Loading