Skip to content

Commit f24ea5b

Browse files
committed
do not check letest version on remote, install from ldflags set
1 parent 2bee92c commit f24ea5b

File tree

9 files changed

+29
-122
lines changed

9 files changed

+29
-122
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venona",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
55
"main": "index.js",
66
"scripts": {

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.3

venonactl/cmd/cmdutils.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ var (
2929
version = "dev"
3030
commit = "none"
3131
date = "unknown"
32-
// set to false by default, when running hack/build.sh will change to true
33-
// to prevent version checking during development
34-
localDevFlow = "false"
3532

3633
verbose bool
3734

@@ -41,8 +38,6 @@ var (
4138
cfContext string
4239

4340
kubeConfigPath string
44-
45-
skipVerionCheck bool
4641
)
4742

4843
func buildBasicStore(logger logger.Logger) {
@@ -64,30 +59,7 @@ func buildBasicStore(logger logger.Logger) {
6459
s.ServerCert = &certs.ServerCert{}
6560

6661
s.AppName = store.ApplicationName
67-
68-
if skipVerionCheck || localDevFlow == "true" {
69-
latestVersion := &store.LatestVersion{
70-
Version: store.DefaultVersion,
71-
IsDefault: true,
72-
}
73-
s.Version.Latest = latestVersion
74-
logger.Debug("Skipping version check")
75-
} else {
76-
latestVersion := &store.LatestVersion{
77-
Version: store.GetLatestVersion(logger),
78-
IsDefault: false,
79-
}
80-
s.Image.Tag = latestVersion.Version
81-
s.Version.Latest = latestVersion
82-
res, _ := store.IsRunningLatestVersion()
83-
// the local version and the latest version not match
84-
// make sure the command is no venonactl version
85-
if !res {
86-
logger.Info("New version is avaliable, please update",
87-
"Local-Version", s.Version.Current.Version,
88-
"Latest-Version", s.Version.Latest.Version)
89-
}
90-
}
62+
s.Image.Tag = s.Version.Current.Version
9163
}
9264

9365
func extendStoreWithCodefershClient(logger logger.Logger) error {

venonactl/cmd/install-agent.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ limitations under the License.
1919
import (
2020
"fmt"
2121

22-
"github.com/codefresh-io/venona/venonactl/pkg/store"
23-
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
2422
"github.com/codefresh-io/venona/venonactl/pkg/logger"
23+
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
24+
"github.com/codefresh-io/venona/venonactl/pkg/store"
2525
"github.com/spf13/cobra"
2626
"github.com/spf13/viper"
2727
)
2828

2929
var installAgentCmdOptions struct {
30-
dryRun bool
31-
kube struct {
30+
dryRun bool
31+
kube struct {
3232
namespace string
3333
inCluster bool
3434
context string
3535
nodeSelector string
3636
}
37-
venona struct {
37+
venona struct {
3838
version string
3939
}
40-
agentToken string
41-
agentID string
42-
kubernetesRunnerType bool
43-
tolerations string
40+
agentToken string
41+
agentID string
42+
kubernetesRunnerType bool
43+
tolerations string
4444
}
4545

4646
var installAgentCmd = &cobra.Command{
47-
Use: "agent",
47+
Use: "agent",
4848
Short: "Install Codefresh's agent ",
4949
Run: func(cmd *cobra.Command, args []string) {
5050
s := store.GetStore()
@@ -59,7 +59,7 @@ var installAgentCmd = &cobra.Command{
5959
cfAPIHost = "https://g.codefresh.io"
6060
}
6161
builderInstallOpt := &plugins.InstallOptions{
62-
CodefreshHost: cfAPIHost,
62+
CodefreshHost: cfAPIHost,
6363
}
6464

6565
if installAgentCmdOptions.agentToken == "" {
@@ -93,10 +93,8 @@ var installAgentCmd = &cobra.Command{
9393
version := installAgentCmdOptions.venona.version
9494
lgr.Info("Version set manually", "version", version)
9595
s.Image.Tag = version
96-
s.Version.Latest.Version = version
9796
}
9897

99-
10098
kns, err := parseNodeSelector(installAgentCmdOptions.kube.nodeSelector)
10199
if err != nil {
102100
dieOnError(err)
@@ -107,7 +105,6 @@ var installAgentCmd = &cobra.Command{
107105
builderInstallOpt.KubeBuilder = getKubeClientBuilder(builderInstallOpt.ClusterName, s.KubernetesAPI.Namespace, s.KubernetesAPI.ConfigPath, s.KubernetesAPI.InCluster)
108106
builderInstallOpt.ClusterNamespace = s.KubernetesAPI.Namespace
109107

110-
111108
builder.Add(plugins.VenonaPluginType)
112109

113110
values := s.BuildValues()
@@ -120,10 +117,9 @@ var installAgentCmd = &cobra.Command{
120117
lgr.Info("Agent installation completed Successfully")
121118

122119
},
123-
124120
}
125121

126-
func init() {
122+
func init() {
127123
installCommand.AddCommand(installAgentCmd)
128124

129125
viper.BindEnv("kube-namespace", "KUBE_NAMESPACE")
@@ -141,12 +137,10 @@ func init() {
141137
installAgentCmd.Flags().BoolVar(&installAgentCmdOptions.kubernetesRunnerType, "kubernetes-runner-type", false, "Set the runner type to kubernetes (alpha feature)")
142138
}
143139

144-
145-
146-
func fillCodefreshAPI(logger logger.Logger) {
140+
func fillCodefreshAPI(logger logger.Logger) {
147141
s := store.GetStore()
148142
s.CodefreshAPI = &store.CodefreshAPI{
149-
Host: cfAPIHost,
143+
Host: cfAPIHost,
150144
}
151-
152-
}
145+
146+
}

venonactl/cmd/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,5 @@ func init() {
4949
rootCmd.PersistentFlags().StringVar(&kubeConfigPath, "kube-config-path", viper.GetString("kubeconfig"), "Path to kubeconfig file (default is $HOME/.kube/config) [$KUBECONFIG]")
5050

5151
rootCmd.PersistentFlags().BoolVar(&verbose, "verbose", false, "Print logs")
52-
rootCmd.PersistentFlags().BoolVar(&skipVerionCheck, "skip-version-check", false, "Do not compare current Venona's version with latest")
5352

5453
}

venonactl/cmd/version.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ var versionCmd = &cobra.Command{
3434
fmt.Printf("Date: %s\n", s.Version.Current.Date)
3535
fmt.Printf("Commit: %s\n", s.Version.Current.Commit)
3636
fmt.Printf("Local Version: %s\n", s.Version.Current.Version)
37-
fmt.Printf("Latest version: %s\n", s.Version.Latest.Version)
3837
},
3938
}
4039

venonactl/hack/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ OUTFILE=/usr/local/bin/venonactl
44
go generate ${PWD}/hack/generate.go
55
go fmt ${PWD}/pkg/obj/kubeobj/kubeobj.go
66
go fmt ${PWD}/pkg/templates/kubernetes/templates.go
7-
go build -ldflags '-X github.com/codefresh-io/venona/venonactl/cmd.localDevFlow=true' -o $OUTFILE main.go
7+
VERSION="$(cat VERSION)-$(git rev-parse --short HEAD)"
8+
echo "Setting up version $VERSION"
9+
go build -ldflags "-X github.com/codefresh-io/venona/venonactl/cmd.version=$VERSION" -o $OUTFILE main.go
810

911
chmod +x $OUTFILE

venonactl/pkg/store/store.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type (
2828

2929
KubernetesAPI *KubernetesAPI
3030

31-
AgentAPI *AgentAPI
31+
AgentAPI *AgentAPI
3232

3333
ClusterInCodefresh string
3434

@@ -56,8 +56,8 @@ type (
5656
}
5757

5858
AgentAPI struct {
59-
Token string
60-
Id string
59+
Token string
60+
Id string
6161
}
6262

6363
Image struct {
@@ -67,20 +67,13 @@ type (
6767

6868
Version struct {
6969
Current *CurrentVersion
70-
Latest *LatestVersion
7170
}
7271

7372
CurrentVersion struct {
7473
Version string
7574
Commit string
7675
Date string
7776
}
78-
LatestVersion struct {
79-
Version string
80-
Commit string
81-
Date string
82-
IsDefault bool
83-
}
8477
)
8578

8679
func GetStore() *Values {
@@ -94,22 +87,22 @@ func GetStore() *Values {
9487
func (s *Values) BuildValues() map[string]interface{} {
9588
return map[string]interface{}{
9689
"AppName": ApplicationName,
97-
"Version": s.Version.Latest.Version,
90+
"Version": s.Version.Current.Version,
9891
"CodefreshHost": s.CodefreshAPI.Host,
9992
"Mode": ModeInCluster,
10093
"Image": map[string]string{
10194
"Name": "codefresh/venona",
102-
"Tag": s.Version.Latest.Version,
95+
"Tag": s.Version.Current.Version,
10396
},
10497
"VolumeProvisionerImage": map[string]string{
10598
"Name": "codefresh/dind-volume-provisioner",
10699
"Tag": "v18",
107100
},
108101
"Namespace": s.KubernetesAPI.Namespace,
109102
"ConfigPath": s.KubernetesAPI.ConfigPath,
110-
"Context": s.KubernetesAPI.ContextName,
103+
"Context": s.KubernetesAPI.ContextName,
111104
"NodeSelector": s.KubernetesAPI.NodeSelector,
112-
"Tolerations": s.KubernetesAPI.Tolerations,
105+
"Tolerations": s.KubernetesAPI.Tolerations,
113106
"AgentToken": s.AgentAPI.Token,
114107
"AgentId": s.AgentAPI.Id,
115108
"ServerCert": map[string]string{

venonactl/pkg/store/utils.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)