1 changed files with 102 additions and 0 deletions
@ -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…
Reference in new issue