Browse Source

WIP

Signed-off-by: Alejandro Mery <amery@jpi.io>
Alejandro Mery 1 year ago
parent
commit
eb9a44b142
  1. 102
      cmd/jpictl/gateway.go

102
cmd/jpictl/gateway.go

@ -0,0 +1,102 @@
package main
import (
"git.jpi.io/amery/jpictl/pkg/zones"
"github.com/spf13/cobra"
)
// Command
var gatewayCmd = &cobra.Command{
Use: "gateway",
Short: "gateway operates on ring0/ring1 gateways",
}
// gateway set
var gatewaySetCmd = &cobra.Command{
Use: "set",
Short: "gateway set sets machines as gateways",
RunE: func(_ *cobra.Command, args []string) error {
m, err := cfg.LoadZones(false)
if err != nil {
return err
}
for _, arg := range args {
err = gatewaySet(m, arg)
if err != nil {
return err
}
}
return nil
},
}
func gatewaySet(_ zones.ZoneIterator, _ string) error {
return nil
}
// gateway unset
var gatewayUnsetCmd = &cobra.Command{
Use: "unset",
Short: "gateway unset sets machines as non-gateways",
RunE: func(_ *cobra.Command, args []string) error {
m, err := cfg.LoadZones(false)
if err != nil {
return err
}
for _, arg := range args {
err = gatewayUnset(m, arg)
if err != nil {
return err
}
}
return nil
},
}
func gatewayUnset(_ zones.ZoneIterator, _ string) error {
return nil
}
// gateway list
var gatewayListCmd = &cobra.Command{
Use: "list",
Short: "gateway list lists gateways",
RunE: func(_ *cobra.Command, args []string) error {
m, err := cfg.LoadZones(false)
if err != nil {
return err
}
switch {
case len(args) == 0:
return gatewayListAll(m)
default:
for _, arg := range args {
err = gatewayList(m, arg)
if err != nil {
return err
}
}
return nil
}
},
}
func gatewayListAll(_ zones.ZoneIterator) error {
return nil
}
func gatewayList(_ zones.ZoneIterator, _ string) error {
return nil
}
func init() {
rootCmd.AddCommand(gatewayCmd)
gatewayCmd.AddCommand(gatewaySetCmd)
gatewayCmd.AddCommand(gatewayUnsetCmd)
gatewayCmd.AddCommand(gatewayListCmd)
}
Loading…
Cancel
Save