Skip to content

Commit

Permalink
do not check letest version on remote, install from ldflags set
Browse files Browse the repository at this point in the history
  • Loading branch information
olegsu committed Feb 25, 2020
1 parent 2bee92c commit f24ea5b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 122 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "venona",
"version": "1.0.2",
"version": "1.0.3",
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion venonactl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.3
30 changes: 1 addition & 29 deletions venonactl/cmd/cmdutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ var (
version = "dev"
commit = "none"
date = "unknown"
// set to false by default, when running hack/build.sh will change to true
// to prevent version checking during development
localDevFlow = "false"

verbose bool

Expand All @@ -41,8 +38,6 @@ var (
cfContext string

kubeConfigPath string

skipVerionCheck bool
)

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

s.AppName = store.ApplicationName

if skipVerionCheck || localDevFlow == "true" {
latestVersion := &store.LatestVersion{
Version: store.DefaultVersion,
IsDefault: true,
}
s.Version.Latest = latestVersion
logger.Debug("Skipping version check")
} else {
latestVersion := &store.LatestVersion{
Version: store.GetLatestVersion(logger),
IsDefault: false,
}
s.Image.Tag = latestVersion.Version
s.Version.Latest = latestVersion
res, _ := store.IsRunningLatestVersion()
// the local version and the latest version not match
// make sure the command is no venonactl version
if !res {
logger.Info("New version is avaliable, please update",
"Local-Version", s.Version.Current.Version,
"Latest-Version", s.Version.Latest.Version)
}
}
s.Image.Tag = s.Version.Current.Version
}

func extendStoreWithCodefershClient(logger logger.Logger) error {
Expand Down
38 changes: 16 additions & 22 deletions venonactl/cmd/install-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ limitations under the License.
import (
"fmt"

"github.com/codefresh-io/venona/venonactl/pkg/store"
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
"github.com/codefresh-io/venona/venonactl/pkg/logger"
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
"github.com/codefresh-io/venona/venonactl/pkg/store"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var installAgentCmdOptions struct {
dryRun bool
kube struct {
dryRun bool
kube struct {
namespace string
inCluster bool
context string
nodeSelector string
}
venona struct {
venona struct {
version string
}
agentToken string
agentID string
kubernetesRunnerType bool
tolerations string
agentToken string
agentID string
kubernetesRunnerType bool
tolerations string
}

var installAgentCmd = &cobra.Command{
Use: "agent",
Use: "agent",
Short: "Install Codefresh's agent ",
Run: func(cmd *cobra.Command, args []string) {
s := store.GetStore()
Expand All @@ -59,7 +59,7 @@ var installAgentCmd = &cobra.Command{
cfAPIHost = "https://g.codefresh.io"
}
builderInstallOpt := &plugins.InstallOptions{
CodefreshHost: cfAPIHost,
CodefreshHost: cfAPIHost,
}

if installAgentCmdOptions.agentToken == "" {
Expand Down Expand Up @@ -93,10 +93,8 @@ var installAgentCmd = &cobra.Command{
version := installAgentCmdOptions.venona.version
lgr.Info("Version set manually", "version", version)
s.Image.Tag = version
s.Version.Latest.Version = version
}


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


builder.Add(plugins.VenonaPluginType)

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

},

}

func init() {
func init() {
installCommand.AddCommand(installAgentCmd)

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



func fillCodefreshAPI(logger logger.Logger) {
func fillCodefreshAPI(logger logger.Logger) {
s := store.GetStore()
s.CodefreshAPI = &store.CodefreshAPI{
Host: cfAPIHost,
Host: cfAPIHost,
}
}

}
1 change: 0 additions & 1 deletion venonactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ func init() {
rootCmd.PersistentFlags().StringVar(&kubeConfigPath, "kube-config-path", viper.GetString("kubeconfig"), "Path to kubeconfig file (default is $HOME/.kube/config) [$KUBECONFIG]")

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

}
1 change: 0 additions & 1 deletion venonactl/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var versionCmd = &cobra.Command{
fmt.Printf("Date: %s\n", s.Version.Current.Date)
fmt.Printf("Commit: %s\n", s.Version.Current.Commit)
fmt.Printf("Local Version: %s\n", s.Version.Current.Version)
fmt.Printf("Latest version: %s\n", s.Version.Latest.Version)
},
}

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

chmod +x $OUTFILE
21 changes: 7 additions & 14 deletions venonactl/pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type (

KubernetesAPI *KubernetesAPI

AgentAPI *AgentAPI
AgentAPI *AgentAPI

ClusterInCodefresh string

Expand Down Expand Up @@ -56,8 +56,8 @@ type (
}

AgentAPI struct {
Token string
Id string
Token string
Id string
}

Image struct {
Expand All @@ -67,20 +67,13 @@ type (

Version struct {
Current *CurrentVersion
Latest *LatestVersion
}

CurrentVersion struct {
Version string
Commit string
Date string
}
LatestVersion struct {
Version string
Commit string
Date string
IsDefault bool
}
)

func GetStore() *Values {
Expand All @@ -94,22 +87,22 @@ func GetStore() *Values {
func (s *Values) BuildValues() map[string]interface{} {
return map[string]interface{}{
"AppName": ApplicationName,
"Version": s.Version.Latest.Version,
"Version": s.Version.Current.Version,
"CodefreshHost": s.CodefreshAPI.Host,
"Mode": ModeInCluster,
"Image": map[string]string{
"Name": "codefresh/venona",
"Tag": s.Version.Latest.Version,
"Tag": s.Version.Current.Version,
},
"VolumeProvisionerImage": map[string]string{
"Name": "codefresh/dind-volume-provisioner",
"Tag": "v18",
},
"Namespace": s.KubernetesAPI.Namespace,
"ConfigPath": s.KubernetesAPI.ConfigPath,
"Context": s.KubernetesAPI.ContextName,
"Context": s.KubernetesAPI.ContextName,
"NodeSelector": s.KubernetesAPI.NodeSelector,
"Tolerations": s.KubernetesAPI.Tolerations,
"Tolerations": s.KubernetesAPI.Tolerations,
"AgentToken": s.AgentAPI.Token,
"AgentId": s.AgentAPI.Id,
"ServerCert": map[string]string{
Expand Down
52 changes: 0 additions & 52 deletions venonactl/pkg/store/utils.go

This file was deleted.

0 comments on commit f24ea5b

Please sign in to comment.