Skip to content

Commit b8a4ac7

Browse files
committed
Added support for console hostname environment variable
1 parent 23c2513 commit b8a4ac7

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

cmd/root.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
"fmt"
2020
"os"
2121

22-
"github.com/spf13/cobra"
23-
22+
"github.com/redhat-cop/oc-helm/pkg/constants"
2423
"github.com/redhat-cop/oc-helm/pkg/options"
24+
"github.com/spf13/cobra"
2525
)
2626

2727
func newRootCmd(commandLineOptions *options.CommandLineOption) (*cobra.Command, error) {
@@ -34,10 +34,10 @@ func newRootCmd(commandLineOptions *options.CommandLineOption) (*cobra.Command,
3434
SilenceErrors: true,
3535
}
3636

37-
rootCmd.PersistentFlags().StringVar(&commandLineOptions.ConsoleHostname, "console-hostname", "", "OpenShift Console Hostname")
37+
rootCmd.PersistentFlags().StringVar(&commandLineOptions.ConsoleHostname, "console-hostname", os.Getenv(constants.OPENSHIFT_CONSOLE_HOSTNAME_ENV), "OpenShift Console Hostname")
3838
rootCmd.PersistentFlags().StringVar(&commandLineOptions.Context, "context", "", "Kubernetes Context")
3939
rootCmd.PersistentFlags().StringVarP(&commandLineOptions.Namespace, "namespace", "n", "", "Kubernetes namespace")
40-
rootCmd.PersistentFlags().StringVarP(&commandLineOptions.Token, "token", "t", "", "OpenShift OAuth token")
40+
rootCmd.PersistentFlags().StringVarP(&commandLineOptions.Token, "token", "t", os.Getenv(constants.OPENSHIFT_OAUTH_TOKEN_ENV), "OpenShift OAuth token")
4141

4242
rootCmd.AddCommand(
4343
newHistoryCmd(commandLineOptions),
@@ -56,7 +56,6 @@ func newRootCmd(commandLineOptions *options.CommandLineOption) (*cobra.Command,
5656
func Execute() {
5757

5858
commandLineOption := options.NewCommandLineOption()
59-
6059
rootCmd, _ := newRootCmd(commandLineOption)
6160

6261
if err := rootCmd.Execute(); err != nil {

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,6 @@ k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeY
10011001
k8s.io/component-helpers v0.20.1/go.mod h1:Q8trCj1zyLNdeur6pD2QvsF8d/nWVfK71YjN5+qVXy4=
10021002
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
10031003
k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
1004-
k8s.io/helm v1.2.1 h1:Ny4wgW4p7X3tFXR34PziNkUxw2pV0G1DIFmI1QRDdo0=
10051004
k8s.io/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao=
10061005
k8s.io/helm v2.17.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
10071006
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=

pkg/constants/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ package constants
22

33
const (
44
OPENSHIFT_HELM_INDEX_SEPERATOR = "--"
5+
OPENSHIFT_CONSOLE_HOSTNAME_ENV = "OPENSHIFT_CONSOLE_HOSTNAME"
6+
OPENSHIFT_OAUTH_TOKEN_ENV = "OPENSHIFT_OAUTH_TOKEN"
57
)

0 commit comments

Comments
 (0)