Display config details after oauth2
authorMikael Berthe <mikael@lilotux.net>
Sun, 13 Jan 2019 12:33:24 +0100
changeset 244 a01bc98ae01a
parent 243 1bec7d3d6a85
child 245 910f00ab2799
Display config details after oauth2 After a new oauth2 authorization, the configuration details are displayed even when the 'safe_mode' option is set.
cmd/config.go
cmd/oauth2.go
--- a/cmd/config.go	Sun Jan 13 12:28:07 2019 +0100
+++ b/cmd/config.go	Sun Jan 13 12:33:24 2019 +0100
@@ -43,7 +43,7 @@
 		Short:   "Dump the configuration",
 		Example: `  madonctl config dump -i INSTANCE -L USERNAME -P PASS > config.yaml`,
 		RunE: func(cmd *cobra.Command, args []string) error {
-			return configDump()
+			return configDump(false)
 		},
 	},
 	&cobra.Command{
@@ -84,8 +84,8 @@
 ...
 `
 
-func configDump() error {
-	if viper.GetBool("safe_mode") {
+func configDump(force bool) error {
+	if !force && viper.GetBool("safe_mode") {
 		errPrint("Cannot dump: disabled by configuration (safe_mode)")
 		return nil
 	}
--- a/cmd/oauth2.go	Sun Jan 13 12:28:07 2019 +0100
+++ b/cmd/oauth2.go	Sun Jan 13 12:33:24 2019 +0100
@@ -88,7 +88,7 @@
 
 	if gClient.UserToken != nil {
 		errPrint("Login successful.\n")
-		configDump()
+		configDump(true)
 	}
 	return nil
 }