From df9632e59223497e0d1b1e3687c8c13b0f431bcf Mon Sep 17 00:00:00 2001 From: elad-codefresh <82316166+elad-codefresh@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:24:06 +0300 Subject: [PATCH] CR-5778-2 (#41) * final * update * update * update * update * update * update * update --- Makefile | 2 +- README.md | 4 ++-- cmd/commands/runtime.go | 7 ++++++- docs/releases/release_notes.md | 8 ++++---- go.mod | 3 ++- go.sum | 4 ++-- manifests/runtime.yaml | 2 +- pkg/util/util.go | 12 ++++++++++++ 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b96b9d80c..ae49b36f6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.0.45 +VERSION=v0.0.46 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/README.md b/README.md index 27844dae0..70f689d2a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The new Codefresh CLI tool. ```bash # get the latest version or change to a specific version -VERSION=$(curl --silent "https://api.github.com/repos/codefresh-io/cli-v2/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') +VERSION=$(curl --silent "https://api.github.com/repos/codefresh-io/cli-v2/releases/latest" | jq -r ".tag_name") # download and extract the binary curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/$VERSION/cf-darwin-amd64.tar.gz | tar zx @@ -30,7 +30,7 @@ cf version ### Linux ```bash # get the latest version or change to a specific version -VERSION=$(curl --silent "https://api.github.com/repos/codefresh-io/cli-v2/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') +VERSION=$(curl --silent "https://api.github.com/repos/codefresh-io/cli-v2/releases/latest" | jq -r ".tag_name") # download and extract the binary curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/$VERSION/cf-linux-amd64.tar.gz | tar zx diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index e6798576c..8f972d76c 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -185,7 +185,12 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error { return fmt.Errorf("failed to download runtime definition: %w", err) } - runtimeCreationResponse, err := cfConfig.NewClient().ArgoRuntime().Create(opts.RuntimeName) + server, err := util.CurrentServer() + if err != nil { + return fmt.Errorf("failed to get current server address: %w", err) + } + + runtimeCreationResponse, err := cfConfig.NewClient().ArgoRuntime().Create(opts.RuntimeName, server, rt.Spec.Version.String()) if err != nil { return fmt.Errorf("failed to create a new runtime: %w", err) } diff --git a/docs/releases/release_notes.md b/docs/releases/release_notes.md index b6315bc7c..81b304531 100644 --- a/docs/releases/release_notes.md +++ b/docs/releases/release_notes.md @@ -2,13 +2,13 @@ * Argo CD [v2.1.0-rc1](https://github.com/codefresh-io/argo-cd/releases/tag/v2.1.0-rc1) * Argo CD ApplicationSet Controller [2c62537a8e5a](https://github.com/argoproj-labs/applicationset/commit/2c62537a8e5a3d5aecad87b843870789b74bdf89) * Argo Events [v1.4.0](https://github.com/argoproj/argo-events/releases/tag/v1.4.0) -* Argo Rollouts [v1.0.2](https://github.com/argoproj/argo-rollouts/releases/tag/v1.0.2) -* Argo Workflows [v3.1.2](https://github.com/argoproj/argo-workflows/releases/tag/v3.1.2) +* Argo Rollouts [v1.0.4](https://github.com/argoproj/argo-rollouts/releases/tag/v1.0.4) +* Argo Workflows [v3.1.3](https://github.com/argoproj/argo-workflows/releases/tag/v3.1.3) ### Linux ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.45/cf-linux-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.46/cf-linux-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-linux-amd64 /usr/local/bin/cf @@ -20,7 +20,7 @@ cf version ### Mac ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.45/cf-darwin-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.46/cf-darwin-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-darwin-amd64 /usr/local/bin/cf diff --git a/go.mod b/go.mod index b70685e88..23eb0e666 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/argoproj/argo-workflows/v3 v3.1.0 github.com/argoproj/gitops-engine v0.3.3 // indirect github.com/briandowns/spinner v1.13.0 - github.com/codefresh-io/go-sdk v0.30.1 + github.com/codefresh-io/go-sdk v0.30.2 github.com/fatih/color v1.12.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/go-git/go-billy/v5 v5.3.1 @@ -25,6 +25,7 @@ require ( github.com/stretchr/testify v1.7.0 k8s.io/api v0.21.1 k8s.io/apimachinery v0.21.1 + k8s.io/client-go v11.0.1-0.20190816222228-6d55c1b1f1ca+incompatible sigs.k8s.io/kustomize/api v0.8.8 ) diff --git a/go.sum b/go.sum index 8ee50bcae..59feb99f2 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/codefresh-io/go-sdk v0.30.1 h1:NmXSodeyqjbh+75e7jpfhum/9F44Fn+j44RgQazqSrs= -github.com/codefresh-io/go-sdk v0.30.1/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg= +github.com/codefresh-io/go-sdk v0.30.2 h1:NbWph0RUsE9R6Iesm+pvB+5ODuFCGyofbSTrbfx3w4o= +github.com/codefresh-io/go-sdk v0.30.2/go.mod h1:CcoVmTFWHGkbrSW8LyOGB/vJe5Vzr3iC/pNE2QIBTyg= github.com/colinmarc/hdfs v1.1.4-0.20180802165501-48eb8d6c34a9/go.mod h1:0DumPviB681UcSuJErAbDIOx6SIaJWj463TymfZG02I= github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31/go.mod h1:vSBumefK4HA5uiRSwNP+3ofgrEoScpCS2MMWcWXEuQ4= github.com/container-storage-interface/spec v1.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= diff --git a/manifests/runtime.yaml b/manifests/runtime.yaml index 7ee83511b..05118a9ad 100644 --- a/manifests/runtime.yaml +++ b/manifests/runtime.yaml @@ -5,7 +5,7 @@ metadata: namespace: "{{ namespace }}" spec: defVersion: 1.0.0 - version: 0.0.45 + version: 0.0.46 bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd components: - name: events diff --git a/pkg/util/util.go b/pkg/util/util.go index ea30af0fe..6a0637ab4 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -28,6 +28,7 @@ import ( "github.com/codefresh-io/cli-v2/pkg/store" "github.com/briandowns/spinner" + "k8s.io/client-go/tools/clientcmd" ) const ( @@ -155,3 +156,14 @@ func (ar *AsyncRunner) Wait() error { func EscapeAppsetFieldName(field string) string { return appsetFieldRegexp.ReplaceAllString(field, "_") } + +func CurrentServer() (string, error) { + configAccess := clientcmd.NewDefaultPathOptions() + conf, err := configAccess.GetStartingConfig() + if err != nil { + return "", err + } + + server := conf.Clusters[conf.Contexts[conf.CurrentContext].Cluster].Server + return server, nil +}