Skip to content
Snippets Groups Projects
Commit ef09a549 authored by Malte Bauch's avatar Malte Bauch
Browse files

Resolve "Device creation in prompt mode stores some old values"


See merge request !319

Co-authored-by: default avatarMalte Bauch <malte.bauch@extern.h-da.de>
parent 79a9fe57
No related branches found
No related tags found
2 merge requests!333WIP: Develop,!319Resolve "Device creation in prompt mode stores some old values"
Pipeline #109999 passed
...@@ -87,8 +87,14 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`, ...@@ -87,8 +87,14 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`,
for _, r := range resp.GetResponses() { for _, r := range resp.GetResponses() {
spinner.Success("Device has been created with ID: ", r.GetId()) spinner.Success("Device has been created with ID: ", r.GetId())
} }
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
deviceName, opcode, address, username, password = "", "", "", "", ""
},
} }
var deviceName string var deviceName string
...@@ -100,6 +106,6 @@ func init() { ...@@ -100,6 +106,6 @@ func init() {
deviceCreateCmd.Flags().StringVar(&deviceName, "name", "", "add a device name (optional)") deviceCreateCmd.Flags().StringVar(&deviceName, "name", "", "add a device name (optional)")
deviceCreateCmd.Flags().StringVar(&opcode, "type", "", "generation target (csbi or plugin)") deviceCreateCmd.Flags().StringVar(&opcode, "type", "", "generation target (csbi or plugin)")
deviceCreateCmd.Flags().StringVarP(&address, "address", "a", "", "address of a gnmi target, e.g. 192.168.1.1:6030") deviceCreateCmd.Flags().StringVarP(&address, "address", "a", "", "address of a gnmi target, e.g. 192.168.1.1:6030")
deviceCreateCmd.Flags().StringVarP(&username, "username", "u", "admin", "username for a gnmi resource") deviceCreateCmd.Flags().StringVarP(&username, "username", "u", "", "username for a gnmi resource")
deviceCreateCmd.Flags().StringVarP(&password, "password", "p", "arista", "password for a gnmi resource") deviceCreateCmd.Flags().StringVarP(&password, "password", "p", "", "password for a gnmi resource")
} }
...@@ -105,6 +105,11 @@ To enable replacing behaviour (destructive!), set the --replace flag."`, ...@@ -105,6 +105,11 @@ To enable replacing behaviour (destructive!), set the --replace flag."`,
} }
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
replace, forcePush, file = false, false, ""
},
} }
func fileContentToString(path string) (string, error) { func fileContentToString(path string) (string, error) {
......
...@@ -88,6 +88,11 @@ var loginCmd = &cobra.Command{ ...@@ -88,6 +88,11 @@ var loginCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserName, nbUserPwd, controllerAPIEndpoint = "", "", viper.GetString("controllerAPIEndpoint")
},
} }
func init() { func init() {
......
...@@ -68,6 +68,11 @@ var logoutCmd = &cobra.Command{ ...@@ -68,6 +68,11 @@ var logoutCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserName = ""
},
} }
func init() { func init() {
......
...@@ -66,6 +66,11 @@ passed using parameters.`, ...@@ -66,6 +66,11 @@ passed using parameters.`,
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
pndName, pndDescription, pndDefaultSbi = "", "", "openconfig"
},
} }
var pndName string var pndName string
......
...@@ -70,6 +70,11 @@ var userCreateCmd = &cobra.Command{ ...@@ -70,6 +70,11 @@ var userCreateCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserName, nbUserPwd, nbUserRole = "", "", ""
},
} }
var nbUserRole string var nbUserRole string
......
...@@ -58,6 +58,11 @@ var userDeleteCmd = &cobra.Command{ ...@@ -58,6 +58,11 @@ var userDeleteCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserName = ""
},
} }
func init() { func init() {
......
...@@ -63,6 +63,11 @@ var userGetCmd = &cobra.Command{ ...@@ -63,6 +63,11 @@ var userGetCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserName = ""
},
} }
func init() { func init() {
......
...@@ -71,6 +71,11 @@ var userUpdateCmd = &cobra.Command{ ...@@ -71,6 +71,11 @@ var userUpdateCmd = &cobra.Command{
return nil return nil
}, },
PostRun: func(cmd *cobra.Command, args []string) {
// Necessary for prompt mode. The flag variables have to be resetted,
// since in prompt mode the program keeps running.
nbUserID, nbUserName, nbUserPwd, nbUserRole = "", "", "", ""
},
} }
var nbUserID string var nbUserID string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment