mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>
This commit is contained in:
parent
1ee7997fb8
commit
eaf9887d17
6 changed files with 28 additions and 75 deletions
|
|
@ -28,7 +28,6 @@ ADD hack/installers installers
|
|||
ADD hack/tool-versions.sh .
|
||||
|
||||
RUN ./install.sh packr-linux
|
||||
RUN ./install.sh kubectl-linux
|
||||
RUN ./install.sh ksonnet-linux
|
||||
RUN ./install.sh helm2-linux
|
||||
RUN ./install.sh helm-linux
|
||||
|
|
@ -62,7 +61,6 @@ COPY hack/git-verify-wrapper.sh /usr/local/bin/git-verify-wrapper.sh
|
|||
COPY --from=builder /usr/local/bin/ks /usr/local/bin/ks
|
||||
COPY --from=builder /usr/local/bin/helm2 /usr/local/bin/helm2
|
||||
COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm
|
||||
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl
|
||||
COPY --from=builder /usr/local/bin/kustomize /usr/local/bin/kustomize
|
||||
# script to add current (possibly arbitrary) user to /etc/passwd at runtime
|
||||
# (if it's not already there, to be openshift friendly)
|
||||
|
|
|
|||
6
Makefile
6
Makefile
|
|
@ -15,6 +15,7 @@ GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-
|
|||
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
|
||||
PACKR_CMD=$(shell if [ "`which packr`" ]; then echo "packr"; else echo "go run github.com/gobuffalo/packr/packr"; fi)
|
||||
VOLUME_MOUNT=$(shell if test "$(go env GOOS)" = "darwin"; then echo ":delegated"; elif test selinuxenabled; then echo ":delegated"; else echo ""; fi)
|
||||
KUBECTL_VERSION=$(shell awk '/k8s.io\/client-go => k8s.io\/client-go/ { print $$4 }' go.mod | sed -e 's/v0\.\(.*\)/v1\.\1/')
|
||||
|
||||
GOPATH?=$(shell if test -x `which go`; then go env GOPATH; else echo "$(HOME)/go"; fi)
|
||||
GOCACHE?=$(HOME)/.cache/go-build
|
||||
|
|
@ -120,7 +121,9 @@ override LDFLAGS += \
|
|||
-X ${PACKAGE}.version=${VERSION} \
|
||||
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
|
||||
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
|
||||
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}
|
||||
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}\
|
||||
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}\
|
||||
-X ${PACKAGE}.kubectlVersion=${KUBECTL_VERSION}
|
||||
|
||||
ifeq (${STATIC_BUILD}, true)
|
||||
override LDFLAGS += -extldflags "-static"
|
||||
|
|
@ -513,7 +516,6 @@ install-tools-local: install-test-tools-local install-codegen-tools-local instal
|
|||
.PHONY: install-test-tools-local
|
||||
install-test-tools-local:
|
||||
sudo ./hack/install.sh packr-linux
|
||||
sudo ./hack/install.sh kubectl-linux
|
||||
sudo ./hack/install.sh kustomize-linux
|
||||
sudo ./hack/install.sh ksonnet-linux
|
||||
sudo ./hack/install.sh helm2-linux
|
||||
|
|
|
|||
|
|
@ -8,23 +8,25 @@ import (
|
|||
// Version information set by link flags during build. We fall back to these sane
|
||||
// default values when we build outside the Makefile context (e.g. go run, go build, or go test).
|
||||
var (
|
||||
version = "99.99.99" // value from VERSION file
|
||||
buildDate = "1970-01-01T00:00:00Z" // output from `date -u +'%Y-%m-%dT%H:%M:%SZ'`
|
||||
gitCommit = "" // output from `git rev-parse HEAD`
|
||||
gitTag = "" // output from `git describe --exact-match --tags HEAD` (if clean tree state)
|
||||
gitTreeState = "" // determined from `git status --porcelain`. either 'clean' or 'dirty'
|
||||
version = "99.99.99" // value from VERSION file
|
||||
buildDate = "1970-01-01T00:00:00Z" // output from `date -u +'%Y-%m-%dT%H:%M:%SZ'`
|
||||
gitCommit = "" // output from `git rev-parse HEAD`
|
||||
gitTag = "" // output from `git describe --exact-match --tags HEAD` (if clean tree state)
|
||||
gitTreeState = "" // determined from `git status --porcelain`. either 'clean' or 'dirty'
|
||||
kubectlVersion = "" // determined from go.mod file
|
||||
)
|
||||
|
||||
// Version contains Argo version information
|
||||
type Version struct {
|
||||
Version string
|
||||
BuildDate string
|
||||
GitCommit string
|
||||
GitTag string
|
||||
GitTreeState string
|
||||
GoVersion string
|
||||
Compiler string
|
||||
Platform string
|
||||
Version string
|
||||
BuildDate string
|
||||
GitCommit string
|
||||
GitTag string
|
||||
GitTreeState string
|
||||
GoVersion string
|
||||
Compiler string
|
||||
Platform string
|
||||
KubectlVersion string
|
||||
}
|
||||
|
||||
func (v Version) String() string {
|
||||
|
|
@ -53,13 +55,14 @@ func GetVersion() Version {
|
|||
}
|
||||
}
|
||||
return Version{
|
||||
Version: versionStr,
|
||||
BuildDate: buildDate,
|
||||
GitCommit: gitCommit,
|
||||
GitTag: gitTag,
|
||||
GitTreeState: gitTreeState,
|
||||
GoVersion: runtime.Version(),
|
||||
Compiler: runtime.Compiler,
|
||||
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
||||
Version: versionStr,
|
||||
BuildDate: buildDate,
|
||||
GitCommit: gitCommit,
|
||||
GitTag: gitTag,
|
||||
GitTreeState: gitTreeState,
|
||||
GoVersion: runtime.Version(),
|
||||
Compiler: runtime.Compiler,
|
||||
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
||||
KubectlVersion: kubectlVersion,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -eux -o pipefail
|
||||
|
||||
. $(dirname $0)/../tool-versions.sh
|
||||
|
||||
# NOTE: keep the version synced with https://storage.googleapis.com/kubernetes-release/release/stable.txt
|
||||
[ -e $DOWNLOADS/kubectl ] || curl -sLf --retry 3 -o $DOWNLOADS/kubectl https://storage.googleapis.com/kubernetes-release/release/v${kubectl_version}/bin/linux/$ARCHITECTURE/kubectl
|
||||
cp $DOWNLOADS/kubectl $BIN/
|
||||
chmod +x $BIN/kubectl
|
||||
|
|
@ -1,16 +1,8 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/argoproj/gitops-engine/pkg/utils/tracing"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/google/go-jsonnet"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/argoproj/argo-cd/common"
|
||||
|
|
@ -18,38 +10,15 @@ import (
|
|||
"github.com/argoproj/argo-cd/util/helm"
|
||||
ksutil "github.com/argoproj/argo-cd/util/ksonnet"
|
||||
"github.com/argoproj/argo-cd/util/kustomize"
|
||||
"github.com/argoproj/argo-cd/util/log"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
ksonnetVersion string
|
||||
kustomizeVersion string
|
||||
helmVersion string
|
||||
kubectlVersion string
|
||||
jsonnetVersion string
|
||||
}
|
||||
|
||||
func getVersion() (string, error) {
|
||||
span := tracing.NewLoggingTracer(log.NewLogrusLogger(logrus.New())).StartSpan("Version")
|
||||
defer span.Finish()
|
||||
cmd := exec.Command("kubectl", "version", "--client")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get kubectl version: %s", err)
|
||||
}
|
||||
|
||||
re := regexp.MustCompile(`GitVersion:"([a-zA-Z0-9\.\-]+)"`)
|
||||
matches := re.FindStringSubmatch(string(out))
|
||||
if len(matches) != 2 {
|
||||
return "", errors.New("could not get kubectl version")
|
||||
}
|
||||
version := matches[1]
|
||||
if version[0] != 'v' {
|
||||
version = "v" + version
|
||||
}
|
||||
return strings.TrimSpace(version), nil
|
||||
}
|
||||
|
||||
// Version returns the version of the API server
|
||||
func (s *Server) Version(context.Context, *empty.Empty) (*version.VersionMessage, error) {
|
||||
vers := common.GetVersion()
|
||||
|
|
@ -77,14 +46,6 @@ func (s *Server) Version(context.Context, *empty.Empty) (*version.VersionMessage
|
|||
s.helmVersion = err.Error()
|
||||
}
|
||||
}
|
||||
if s.kubectlVersion == "" {
|
||||
kubectlVersion, err := getVersion()
|
||||
if err == nil {
|
||||
s.kubectlVersion = kubectlVersion
|
||||
} else {
|
||||
s.kubectlVersion = err.Error()
|
||||
}
|
||||
}
|
||||
s.jsonnetVersion = jsonnet.Version()
|
||||
return &version.VersionMessage{
|
||||
Version: vers.Version,
|
||||
|
|
@ -98,7 +59,6 @@ func (s *Server) Version(context.Context, *empty.Empty) (*version.VersionMessage
|
|||
KsonnetVersion: s.ksonnetVersion,
|
||||
KustomizeVersion: s.kustomizeVersion,
|
||||
HelmVersion: s.helmVersion,
|
||||
KubectlVersion: s.kubectlVersion,
|
||||
JsonnetVersion: s.jsonnetVersion,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ ADD ./hack/installers installers
|
|||
|
||||
RUN ./install.sh dep-linux && \
|
||||
./install.sh packr-linux && \
|
||||
./install.sh kubectl-linux && \
|
||||
./install.sh ksonnet-linux && \
|
||||
./install.sh helm2-linux && \
|
||||
./install.sh helm-linux && \
|
||||
|
|
|
|||
Loading…
Reference in a new issue