Namespace is now a flag for all the commands
This commit is contained in:
parent
7646bd8fd4
commit
b83318bfb3
5 changed files with 69 additions and 33 deletions
|
@ -8,20 +8,25 @@ import (
|
|||
)
|
||||
|
||||
var RegisterCmd = &cobra.Command{
|
||||
Use: "register machineID namespace",
|
||||
Use: "register machineID",
|
||||
Short: "Registers a machine to your network",
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) < 2 {
|
||||
if len(args) < 1 {
|
||||
return fmt.Errorf("Missing parameters")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
n, err := cmd.Flags().GetString("namespace")
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting namespace: %s", err)
|
||||
}
|
||||
|
||||
h, err := getHeadscaleApp()
|
||||
if err != nil {
|
||||
log.Fatalf("Error initializing: %s", err)
|
||||
}
|
||||
err = h.RegisterMachine(args[0], args[1])
|
||||
err = h.RegisterMachine(args[0], n)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %s", err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue