@@ -62,36 +62,11 @@ var rootCmd = &cobra.Command{
62
62
63
63
PersistentPreRunE : func (cmd * cobra.Command , args []string ) error {
64
64
fullPath := cmd .CommandPath ()
65
+ isVersionTarget := strings .Index (fullPath , "version" ) != - 1
65
66
if verbose == true {
66
67
logrus .SetLevel (logrus .DebugLevel )
67
68
}
68
69
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
-
95
70
s := store .GetStore ()
96
71
s .Version = & store.Version {
97
72
Current : & store.CurrentVersion {
@@ -104,6 +79,7 @@ var rootCmd = &cobra.Command{
104
79
s .Image = & store.Image {
105
80
Name : "codefresh/venona" ,
106
81
}
82
+
107
83
if skipVerionCheck || localDevFlow == "true" {
108
84
latestVersion := & store.LatestVersion {
109
85
Version : store .DefaultVersion ,
@@ -124,14 +100,44 @@ var rootCmd = &cobra.Command{
124
100
res , _ := store .IsRunningLatestVersion ()
125
101
// the local version and the latest version not match
126
102
// make sure the command is no venonactl version
127
- if ! res && strings . Index ( fullPath , "version" ) == - 1 {
103
+ if ! res && ! isVersionTarget {
128
104
logrus .WithFields (logrus.Fields {
129
105
"Local-Version" : s .Version .Current .Version ,
130
106
"Latest-Version" : s .Version .Latest .Version ,
131
107
}).Info ("New version is avaliable, please update" )
132
108
}
133
109
}
134
110
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
+
135
141
if kubeConfigPath == "" {
136
142
currentUser , _ := user .Current ()
137
143
if currentUser != nil {
@@ -153,7 +159,6 @@ var rootCmd = &cobra.Command{
153
159
Client : client ,
154
160
}
155
161
s .Mode = store .ModeInCluster
156
-
157
162
s .ServerCert = & certs.ServerCert {}
158
163
159
164
return nil
0 commit comments