Skip to content

Commit

Permalink
remove old function
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichSchreiner committed May 8, 2024
1 parent 4126267 commit 9b6f781
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions cmd/completion/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package completion

import (
"github.com/metal-stack/metal-go/api/client/switch_operations"
"github.com/metal-stack/metal-go/api/models"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -95,52 +94,3 @@ func (c *Completion) SwitchListPorts(cmd *cobra.Command, args []string, toComple
}
return names, cobra.ShellCompDirectiveNoFileComp
}

func (c *Completion) xSwitchListCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var names []string
if len(args) == 0 {
resp, err := c.client.SwitchOperations().ListSwitches(switch_operations.NewListSwitchesParams(), nil)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

for _, s := range resp.Payload {
if s.ID == nil {
continue
}
names = append(names, *s.ID)
}
return names, cobra.ShellCompDirectiveNoFileComp
}
if len(args) < 3 {
resp, err := c.client.SwitchOperations().FindSwitch(switch_operations.NewFindSwitchParams().WithID(args[0]), nil)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
if len(args) == 1 {
for _, n := range resp.Payload.Nics {
if n != nil {
names = append(names, *n.Name)
}
}
return names, cobra.ShellCompDirectiveNoFileComp
}

for _, n := range resp.Payload.Nics {
if n != nil && *n.Name == args[1] {
if n.Actual == nil {
names = append(names, models.V1SwitchNicActualUP, models.V1SwitchNicActualDOWN)
} else {
if *n.Actual == models.V1SwitchNicActualUP {
names = append(names, models.V1SwitchNicActualDOWN)
}
if *n.Actual == models.V1SwitchNicActualDOWN {
names = append(names, models.V1SwitchNicActualUP)
}
}
break
}
}
}
return names, cobra.ShellCompDirectiveNoFileComp
}

0 comments on commit 9b6f781

Please sign in to comment.