@@ -62,36 +62,11 @@ var rootCmd = &cobra.Command{
6262
6363 PersistentPreRunE : func (cmd * cobra.Command , args []string ) error {
6464 fullPath := cmd .CommandPath ()
65+ isVersionTarget := strings .Index (fullPath , "version" ) != - 1
6566 if verbose == true {
6667 logrus .SetLevel (logrus .DebugLevel )
6768 }
6869
69- if configPath == "" {
70- configPath = fmt .Sprintf ("%s/.cfconfig" , os .Getenv ("HOME" ))
71- }
72-
73- if cfAPIHost == "" && cfAPIToken == "" {
74- context , err := sdkUtils .ReadAuthContext (configPath , cfContext )
75- if err != nil {
76- return err
77- }
78- cfAPIHost = context .URL
79- cfAPIToken = context .Token
80-
81- logrus .WithFields (logrus.Fields {
82- "Context-Name" : context .Name ,
83- "Codefresh-Host" : cfAPIHost ,
84- }).Debug ("Using codefresh context" )
85- } else {
86- logrus .Debug ("Using creentials from environment variables" )
87- }
88- client := codefresh .New (& codefresh.ClientOptions {
89- Auth : codefresh.AuthOptions {
90- Token : cfAPIToken ,
91- },
92- Host : cfAPIHost ,
93- })
94-
9570 s := store .GetStore ()
9671 s .Version = & store.Version {
9772 Current : & store.CurrentVersion {
@@ -104,6 +79,7 @@ var rootCmd = &cobra.Command{
10479 s .Image = & store.Image {
10580 Name : "codefresh/venona" ,
10681 }
82+
10783 if skipVerionCheck || localDevFlow == "true" {
10884 latestVersion := & store.LatestVersion {
10985 Version : store .DefaultVersion ,
@@ -124,14 +100,44 @@ var rootCmd = &cobra.Command{
124100 res , _ := store .IsRunningLatestVersion ()
125101 // the local version and the latest version not match
126102 // make sure the command is no venonactl version
127- if ! res && strings . Index ( fullPath , "version" ) == - 1 {
103+ if ! res && ! isVersionTarget {
128104 logrus .WithFields (logrus.Fields {
129105 "Local-Version" : s .Version .Current .Version ,
130106 "Latest-Version" : s .Version .Latest .Version ,
131107 }).Info ("New version is avaliable, please update" )
132108 }
133109 }
134110
111+ if isVersionTarget {
112+ return nil
113+ }
114+
115+ if configPath == "" {
116+ configPath = fmt .Sprintf ("%s/.cfconfig" , os .Getenv ("HOME" ))
117+ }
118+
119+ if cfAPIHost == "" && cfAPIToken == "" {
120+ context , err := sdkUtils .ReadAuthContext (configPath , cfContext )
121+ if err != nil {
122+ return err
123+ }
124+ cfAPIHost = context .URL
125+ cfAPIToken = context .Token
126+
127+ logrus .WithFields (logrus.Fields {
128+ "Context-Name" : context .Name ,
129+ "Codefresh-Host" : cfAPIHost ,
130+ }).Debug ("Using codefresh context" )
131+ } else {
132+ logrus .Debug ("Using creentials from environment variables" )
133+ }
134+ client := codefresh .New (& codefresh.ClientOptions {
135+ Auth : codefresh.AuthOptions {
136+ Token : cfAPIToken ,
137+ },
138+ Host : cfAPIHost ,
139+ })
140+
135141 if kubeConfigPath == "" {
136142 currentUser , _ := user .Current ()
137143 if currentUser != nil {
@@ -153,7 +159,6 @@ var rootCmd = &cobra.Command{
153159 Client : client ,
154160 }
155161 s .Mode = store .ModeInCluster
156-
157162 s .ServerCert = & certs.ServerCert {}
158163
159164 return nil
0 commit comments