Skip to content

Commit

Permalink
Prevent panic when using the managed-cluster-configfile argument
Browse files Browse the repository at this point in the history
Some previous change seems to have removed the case to parse the congif
when the managed-cluster-configfile argument is specified.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl authored and openshift-merge-bot[bot] committed Dec 1, 2023
1 parent 823d36e commit 08dd229
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,24 @@ func main() {

tool.Options.ManagedConfigFilePathName, found = os.LookupEnv("MANAGED_CONFIG")
if found {
log.Info("Found ENV MANAGED_CONFIG, initializing using", "tool.Options.ManagedConfigFilePathName",
tool.Options.ManagedConfigFilePathName)
log.Info(
"Found ENV MANAGED_CONFIG, initializing using",
"tool.Options.ManagedConfigFilePathName", tool.Options.ManagedConfigFilePathName,
)
}
}

managedCfg, err = clientcmd.BuildConfigFromFlags("", tool.Options.ManagedConfigFilePathName)
if err != nil {
log.Error(err, "Failed to build managed cluster config")
os.Exit(1)
}
} else {
managedCfg, err = config.GetConfig()
if err != nil {
log.Error(err, "Failed to build managed cluster config")
os.Exit(1)
}
if tool.Options.ManagedConfigFilePathName == "" {
managedCfg, err = config.GetConfig()
if err != nil {
log.Error(err, "Failed to build managed cluster config")
os.Exit(1)
}
} else {
managedCfg, err = clientcmd.BuildConfigFromFlags("", tool.Options.ManagedConfigFilePathName)
if err != nil {
log.Error(err, "Failed to build managed cluster config")
os.Exit(1)
}
}

Expand Down

0 comments on commit 08dd229

Please sign in to comment.