Skip to content

Commit 51c6a5b

Browse files
Julio Faermanr4f4
andauthored
SPLAT-1429: Adds flag to omit credentials in logging (#8287)
* Adds flag to omit credentials in logging * Update cmd/openshift-install/create.go Co-authored-by: Rafael F. <[email protected]> * Update cmd/openshift-install/create.go Co-authored-by: Rafael F. <[email protected]> --------- Co-authored-by: Rafael F. <[email protected]>
1 parent 1cb86cb commit 51c6a5b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmd/openshift-install/create.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ const (
7676
coStabilityThreshold float64 = 30
7777
)
7878

79+
var skipPasswordPrintFlag bool
80+
7981
// each target is a variable to preserve the order when creating subcommands and still
8082
// allow other functions to directly access each target individually.
8183
var (
@@ -111,6 +113,7 @@ var (
111113
},
112114
assets: targetassets.IgnitionConfigs,
113115
}
116+
114117
singleNodeIgnitionConfigTarget = target{
115118
name: "Single Node Ignition Config",
116119
command: &cobra.Command{
@@ -289,6 +292,9 @@ func newCreateCmd(ctx context.Context) *cobra.Command {
289292
for _, t := range targets {
290293
t.command.Args = cobra.ExactArgs(0)
291294
t.command.Run = runTargetCmd(ctx, t.assets...)
295+
if t.name == "Cluster" {
296+
t.command.PersistentFlags().BoolVar(&skipPasswordPrintFlag, "skip-password-print", false, "Do not print the generated user password.")
297+
}
292298
cmd.AddCommand(t.command)
293299
}
294300

@@ -329,7 +335,6 @@ func runTargetCmd(ctx context.Context, targets ...asset.WritableAsset) func(cmd
329335
default:
330336
logrus.Infof(logging.LogCreatedFiles(cmd.Name(), command.RootOpts.Dir, targets))
331337
}
332-
333338
}
334339
}
335340

@@ -771,7 +776,11 @@ func logComplete(directory, consoleURL string) error {
771776
logrus.Infof("To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=%s'", kubeconfig)
772777
if consoleURL != "" {
773778
logrus.Infof("Access the OpenShift web-console here: %s", consoleURL)
774-
logrus.Infof("Login to the console with user: %q, and password: %q", "kubeadmin", pw)
779+
if skipPasswordPrintFlag {
780+
logrus.Infof("Credentials omitted, if necessary verify the %s file", pwFile)
781+
} else {
782+
logrus.Infof("Login to the console with user: %q, and password: %q", "kubeadmin", pw)
783+
}
775784
}
776785
return nil
777786
}

0 commit comments

Comments
 (0)