mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-04-07 01:08:47 +02:00
Compare commits
10 Commits
v0.5.2
...
release-0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21b64886ce | ||
|
|
eeb1036dcf | ||
|
|
fa990ab0c9 | ||
|
|
933f3da538 | ||
|
|
a7fa2fd256 | ||
|
|
0de1a3b20a | ||
|
|
bcc114ec60 | ||
|
|
1148fae419 | ||
|
|
d7188c29f8 | ||
|
|
4b97732659 |
@@ -1,4 +1,4 @@
|
||||
FROM debian:9.3 as builder
|
||||
FROM debian:9.4 as builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Install go
|
||||
ENV GO_VERSION 1.9.3
|
||||
ENV GO_VERSION 1.10.3
|
||||
ENV GO_ARCH amd64
|
||||
ENV GOPATH /root/go
|
||||
ENV PATH ${GOPATH}/bin:/usr/local/go/bin:${PATH}
|
||||
@@ -58,7 +58,7 @@ FROM golang:1.10 as cli-tooling
|
||||
#RUN go get -v -u github.com/ksonnet/ksonnet && mv ${GOPATH}/bin/ksonnet /ks
|
||||
|
||||
# Option 2: use official tagged ksonnet release
|
||||
env KSONNET_VERSION=0.10.2
|
||||
env KSONNET_VERSION=0.11.0
|
||||
RUN wget https://github.com/ksonnet/ksonnet/releases/download/v${KSONNET_VERSION}/ks_${KSONNET_VERSION}_linux_amd64.tar.gz && \
|
||||
tar -C /tmp/ -xf ks_${KSONNET_VERSION}_linux_amd64.tar.gz && \
|
||||
mv /tmp/ks_${KSONNET_VERSION}_linux_amd64/ks /ks
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.9.2
|
||||
FROM golang:1.10.3
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
@@ -15,7 +15,7 @@ RUN curl -o /kubectl -LO https://storage.googleapis.com/kubernetes-release/relea
|
||||
chmod +x /kubectl && mv /kubectl /usr/local/bin/kubectl
|
||||
|
||||
# Install ksonnet
|
||||
env KSONNET_VERSION=0.10.2
|
||||
env KSONNET_VERSION=0.11.0
|
||||
RUN wget https://github.com/ksonnet/ksonnet/releases/download/v${KSONNET_VERSION}/ks_${KSONNET_VERSION}_linux_amd64.tar.gz && \
|
||||
tar -C /tmp/ -xf ks_${KSONNET_VERSION}_linux_amd64.tar.gz && \
|
||||
mv /tmp/ks_${KSONNET_VERSION}_linux_amd64/ks /usr/local/bin/ks && \
|
||||
|
||||
94
Gopkg.lock
generated
94
Gopkg.lock
generated
@@ -84,15 +84,6 @@
|
||||
revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e"
|
||||
version = "v3.2.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/emicklei/go-restful"
|
||||
packages = [
|
||||
".",
|
||||
"log"
|
||||
]
|
||||
revision = "26b41036311f2da8242db402557a0dbd09dc83da"
|
||||
version = "v2.6.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/ghodss/yaml"
|
||||
packages = ["."]
|
||||
@@ -209,12 +200,6 @@
|
||||
]
|
||||
revision = "e09c5db296004fbe3f74490e84dcd62c3c5ddb1b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/google/btree"
|
||||
packages = ["."]
|
||||
revision = "e89373fe6b4a7413d7acd6da1725b83ef713e6e4"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/google/go-jsonnet"
|
||||
packages = [
|
||||
@@ -240,15 +225,6 @@
|
||||
revision = "ee43cbb60db7bd22502942cccbc39059117352ab"
|
||||
version = "v0.1.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gregjones/httpcache"
|
||||
packages = [
|
||||
".",
|
||||
"diskcache"
|
||||
]
|
||||
revision = "2bcd89a1743fd4b373f7370ce8ddc14dfbd18229"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||
@@ -307,12 +283,6 @@
|
||||
revision = "e7c7f3b33712573affdcc7a107218e7926b9a05b"
|
||||
version = "1.0.6"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/juju/ratelimit"
|
||||
packages = ["."]
|
||||
revision = "59fac5042749a5afb9af70e813da1dd5474f0167"
|
||||
version = "1.0.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/kardianos/osext"
|
||||
@@ -327,6 +297,7 @@
|
||||
"pkg/component",
|
||||
"pkg/docparser",
|
||||
"pkg/lib",
|
||||
"pkg/log",
|
||||
"pkg/node",
|
||||
"pkg/params",
|
||||
"pkg/prototype",
|
||||
@@ -335,8 +306,8 @@
|
||||
"pkg/util/kslib",
|
||||
"pkg/util/strings"
|
||||
]
|
||||
revision = "8c44a5b1545d3d03135f610170ef0167129294bc"
|
||||
version = "v0.10.1"
|
||||
revision = "e943ae55d4fe256c8330a047ce8426ad9dac110c"
|
||||
version = "v0.11.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/ksonnet/ksonnet-lib"
|
||||
@@ -349,8 +320,8 @@
|
||||
"ksonnet-gen/nodemaker",
|
||||
"ksonnet-gen/printer"
|
||||
]
|
||||
revision = "d15220fdcdd07fd377894abff6276d86cb2d776d"
|
||||
version = "v0.1.3"
|
||||
revision = "dfcaa3d01d0c4948cb596403c35e966c774f2678"
|
||||
version = "v0.1.8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -368,18 +339,6 @@
|
||||
revision = "a3647f8e31d79543b2d0f0ae2fe5c379d72cedc0"
|
||||
version = "v2.1.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/petar/GoLLRB"
|
||||
packages = ["llrb"]
|
||||
revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/peterbourgon/diskv"
|
||||
packages = ["."]
|
||||
revision = "5f041e8faa004a95c88a202771f4cc3e991971e6"
|
||||
version = "v2.0.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
@@ -416,8 +375,7 @@
|
||||
[[projects]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
packages = ["."]
|
||||
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
||||
version = "v1.0.5"
|
||||
revision = "ea8897e79973357ba785ac2533559a6297e83c44"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -565,6 +523,12 @@
|
||||
]
|
||||
revision = "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/time"
|
||||
packages = ["rate"]
|
||||
revision = "fbb02b2291d28baffd63558aa44b4b56f178d650"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/tools"
|
||||
@@ -666,7 +630,7 @@
|
||||
revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/api"
|
||||
packages = [
|
||||
"admission/v1beta1",
|
||||
@@ -700,10 +664,10 @@
|
||||
"storage/v1alpha1",
|
||||
"storage/v1beta1"
|
||||
]
|
||||
revision = "acf347b865f29325eb61f4cd2df11e86e073a5ee"
|
||||
revision = "8b7507fac302640dd5f1efbf9643199952cc58db"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/apiextensions-apiserver"
|
||||
packages = [
|
||||
"pkg/apis/apiextensions",
|
||||
@@ -712,10 +676,10 @@
|
||||
"pkg/client/clientset/clientset/scheme",
|
||||
"pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
|
||||
]
|
||||
revision = "b89f5ce12ce6e022fc3e9d7586d61346e694d56e"
|
||||
revision = "b13a681559816a9c14f93086bbeeed1c7baf2bcb"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/apimachinery"
|
||||
packages = [
|
||||
"pkg/api/equality",
|
||||
@@ -728,7 +692,7 @@
|
||||
"pkg/apis/meta/internalversion",
|
||||
"pkg/apis/meta/v1",
|
||||
"pkg/apis/meta/v1/unstructured",
|
||||
"pkg/apis/meta/v1alpha1",
|
||||
"pkg/apis/meta/v1beta1",
|
||||
"pkg/conversion",
|
||||
"pkg/conversion/queryparams",
|
||||
"pkg/fields",
|
||||
@@ -764,10 +728,10 @@
|
||||
"third_party/forked/golang/json",
|
||||
"third_party/forked/golang/reflect"
|
||||
]
|
||||
revision = "19e3f5aa3adca672c153d324e6b7d82ff8935f03"
|
||||
revision = "f6313580a4d36c7c74a3d845dda6e116642c4f90"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-6.0"
|
||||
branch = "release-7.0"
|
||||
name = "k8s.io/client-go"
|
||||
packages = [
|
||||
"discovery",
|
||||
@@ -897,7 +861,10 @@
|
||||
"listers/storage/v1",
|
||||
"listers/storage/v1alpha1",
|
||||
"listers/storage/v1beta1",
|
||||
"pkg/apis/clientauthentication",
|
||||
"pkg/apis/clientauthentication/v1alpha1",
|
||||
"pkg/version",
|
||||
"plugin/pkg/client/auth/exec",
|
||||
"plugin/pkg/client/auth/gcp",
|
||||
"plugin/pkg/client/auth/oidc",
|
||||
"rest",
|
||||
@@ -920,19 +887,21 @@
|
||||
"util/homedir",
|
||||
"util/integer",
|
||||
"util/jsonpath",
|
||||
"util/retry",
|
||||
"util/workqueue"
|
||||
]
|
||||
revision = "9389c055a838d4f208b699b3c7c51b70f2368861"
|
||||
revision = "26a26f55b28aa1b338fbaf6fbbe0bcd76aed05e0"
|
||||
|
||||
[[projects]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/code-generator"
|
||||
packages = [
|
||||
"cmd/go-to-protobuf",
|
||||
"cmd/go-to-protobuf/protobuf",
|
||||
"pkg/util",
|
||||
"third_party/forked/golang/reflect"
|
||||
]
|
||||
revision = "91d3f6a57905178524105a085085901bb73bd3dc"
|
||||
revision = "9de8e796a74d16d2a285165727d04c185ebca6dc"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -949,10 +918,7 @@
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "k8s.io/kube-openapi"
|
||||
packages = [
|
||||
"pkg/common",
|
||||
"pkg/util/proto"
|
||||
]
|
||||
packages = ["pkg/util/proto"]
|
||||
revision = "50ae88d24ede7b8bad68e23c805b5d3da5c8abaf"
|
||||
|
||||
[[projects]]
|
||||
@@ -967,6 +933,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "866ac05c71a770ae44aa5d28d5d1844db0b045fa0ab7cecc4650d7db8aa38145"
|
||||
inputs-digest = "f2d179e0bbae6ede81f78cf6b0b16cb09fbeb5e97add78bdd97e3051238b86da"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
||||
17
Gopkg.toml
17
Gopkg.toml
@@ -13,25 +13,20 @@ required = [
|
||||
name = "github.com/grpc-ecosystem/grpc-gateway"
|
||||
version = "v1.3.1"
|
||||
|
||||
# override ksonnet's release-1.8 dependency
|
||||
[[override]]
|
||||
branch = "release-1.9"
|
||||
name = "k8s.io/apimachinery"
|
||||
|
||||
[[constraint]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/api"
|
||||
|
||||
[[constraint]]
|
||||
name = "k8s.io/apiextensions-apiserver"
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
|
||||
[[constraint]]
|
||||
branch = "release-1.9"
|
||||
branch = "release-1.10"
|
||||
name = "k8s.io/code-generator"
|
||||
|
||||
[[constraint]]
|
||||
branch = "release-6.0"
|
||||
branch = "release-7.0"
|
||||
name = "k8s.io/client-go"
|
||||
|
||||
[[constraint]]
|
||||
@@ -40,7 +35,7 @@ required = [
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/ksonnet/ksonnet"
|
||||
version = "v0.10.1"
|
||||
version = "v0.11.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gobuffalo/packr"
|
||||
@@ -49,4 +44,4 @@ required = [
|
||||
# override ksonnet's logrus dependency
|
||||
[[override]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
version = "v1.0.3"
|
||||
revision = "ea8897e79973357ba785ac2533559a6297e83c44"
|
||||
|
||||
17
Makefile
17
Makefile
@@ -57,29 +57,29 @@ codegen: protogen clientgen
|
||||
# NOTE: we use packr to do the build instead of go, since we embed .yaml files into the go binary.
|
||||
# This enables ease of maintenance of the yaml files.
|
||||
.PHONY: cli
|
||||
cli:
|
||||
cli: clean-debug
|
||||
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS} -extldflags "-static"' -o ${DIST_DIR}/${CLI_NAME} ./cmd/argocd
|
||||
|
||||
.PHONY: cli-linux
|
||||
cli-linux:
|
||||
cli-linux: clean-debug
|
||||
docker build --iidfile /tmp/argocd-linux-id --target builder --build-arg MAKE_TARGET="cli IMAGE_TAG=$(IMAGE_TAG) IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) CLI_NAME=argocd-linux-amd64" -f Dockerfile-argocd .
|
||||
docker create --name tmp-argocd-linux `cat /tmp/argocd-linux-id`
|
||||
docker cp tmp-argocd-linux:/root/go/src/github.com/argoproj/argo-cd/dist/argocd-linux-amd64 dist/
|
||||
docker rm tmp-argocd-linux
|
||||
|
||||
.PHONY: cli-darwin
|
||||
cli-darwin:
|
||||
cli-darwin: clean-debug
|
||||
docker build --iidfile /tmp/argocd-darwin-id --target builder --build-arg MAKE_TARGET="cli GOOS=darwin IMAGE_TAG=$(IMAGE_TAG) IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) CLI_NAME=argocd-darwin-amd64" -f Dockerfile-argocd .
|
||||
docker create --name tmp-argocd-darwin `cat /tmp/argocd-darwin-id`
|
||||
docker cp tmp-argocd-darwin:/root/go/src/github.com/argoproj/argo-cd/dist/argocd-darwin-amd64 dist/
|
||||
docker rm tmp-argocd-darwin
|
||||
|
||||
.PHONY: argocd-util
|
||||
argocd-util:
|
||||
argocd-util: clean-debug
|
||||
CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS} -extldflags "-static"' -o ${DIST_DIR}/argocd-util ./cmd/argocd-util
|
||||
|
||||
.PHONY: server
|
||||
server:
|
||||
server: clean-debug
|
||||
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-server ./cmd/argocd-server
|
||||
|
||||
.PHONY: server-image
|
||||
@@ -126,8 +126,13 @@ test:
|
||||
test-e2e:
|
||||
go test ./test/e2e
|
||||
|
||||
# Cleans VSCode debug.test files from sub-dirs to prevent them from being included in packr boxes
|
||||
.PHONY: clean-debug
|
||||
clean-debug:
|
||||
-find ${CURRENT_DIR} -name debug.test | xargs rm -f
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
clean: clean-debug
|
||||
-rm -rf ${CURRENT_DIR}/dist
|
||||
|
||||
.PHONY: precheckin
|
||||
|
||||
4
Procfile
4
Procfile
@@ -1,5 +1,5 @@
|
||||
controller: go run ./cmd/argocd-application-controller/main.go --app-resync 10
|
||||
controller: go run ./cmd/argocd-application-controller/main.go --app-resync 60
|
||||
api-server: go run ./cmd/argocd-server/main.go --insecure --disable-auth
|
||||
repo-server: go run ./cmd/argocd-repo-server/main.go --loglevel debug
|
||||
dex: sh -c "go run ./cmd/argocd-util/main.go gendexcfg -o `pwd`/dist/dex.yaml && docker run --rm -p 5556:5556 -p 5557:5557 -v `pwd`/dist/dex.yaml:/dex.yaml quay.io/coreos/dex:v2.10.0 serve /dex.yaml"
|
||||
redis: docker run --rm -p 6379:6379 redis:3.2.11
|
||||
redis: docker run --rm -p 6379:6379 redis:3.2.11
|
||||
|
||||
@@ -2,6 +2,8 @@ package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"strconv"
|
||||
|
||||
"github.com/argoproj/argo-cd/errors"
|
||||
appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
|
||||
@@ -19,6 +21,7 @@ func NewCommand() *cobra.Command {
|
||||
var (
|
||||
insecure bool
|
||||
logLevel string
|
||||
glogLevel int
|
||||
clientConfig clientcmd.ClientConfig
|
||||
staticAssetsDir string
|
||||
repoServerAddress string
|
||||
@@ -33,6 +36,11 @@ func NewCommand() *cobra.Command {
|
||||
errors.CheckError(err)
|
||||
log.SetLevel(level)
|
||||
|
||||
// Set the glog level for the k8s go-client
|
||||
_ = flag.CommandLine.Parse([]string{})
|
||||
_ = flag.Lookup("logtostderr").Value.Set("true")
|
||||
_ = flag.Lookup("v").Value.Set(strconv.Itoa(glogLevel))
|
||||
|
||||
config, err := clientConfig.ClientConfig()
|
||||
errors.CheckError(err)
|
||||
|
||||
@@ -67,6 +75,7 @@ func NewCommand() *cobra.Command {
|
||||
command.Flags().BoolVar(&insecure, "insecure", false, "Run server without TLS")
|
||||
command.Flags().StringVar(&staticAssetsDir, "staticassets", "", "Static assets directory path")
|
||||
command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
|
||||
command.Flags().IntVar(&glogLevel, "gloglevel", 0, "Set the glog logging level")
|
||||
command.Flags().StringVar(&repoServerAddress, "repo-server", "localhost:8081", "Repo server address.")
|
||||
command.Flags().BoolVar(&disableAuth, "disable-auth", false, "Disable client authentication")
|
||||
command.AddCommand(cli.NewVersionCmd(cliName))
|
||||
|
||||
@@ -2,6 +2,7 @@ package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
||||
"github.com/argoproj/argo-cd/common"
|
||||
"github.com/argoproj/argo-cd/errors"
|
||||
argocdclient "github.com/argoproj/argo-cd/pkg/apiclient"
|
||||
argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
@@ -29,6 +31,8 @@ import (
|
||||
"github.com/argoproj/argo-cd/util"
|
||||
"github.com/argoproj/argo-cd/util/cli"
|
||||
"github.com/argoproj/argo-cd/util/diff"
|
||||
"github.com/argoproj/argo-cd/util/ksonnet"
|
||||
kubeutil "github.com/argoproj/argo-cd/util/kube"
|
||||
)
|
||||
|
||||
// NewApplicationCommand returns a new instance of an `argocd app` command
|
||||
@@ -131,7 +135,10 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
|
||||
// NewApplicationGetCommand returns a new instance of an `argocd app get` command
|
||||
func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
showParams bool
|
||||
output string
|
||||
showParams bool
|
||||
showOperation bool
|
||||
refresh bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
Use: "get APPNAME",
|
||||
@@ -145,33 +152,74 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
|
||||
conn, appIf := acdClient.NewApplicationClientOrDie()
|
||||
defer util.Close(conn)
|
||||
appName := args[0]
|
||||
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
|
||||
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName, Refresh: refresh})
|
||||
errors.CheckError(err)
|
||||
format := "%-15s%s\n"
|
||||
fmt.Printf(format, "Name:", app.Name)
|
||||
fmt.Printf(format, "Server:", app.Spec.Destination.Server)
|
||||
fmt.Printf(format, "Namespace:", app.Spec.Destination.Namespace)
|
||||
fmt.Printf(format, "URL:", appURL(acdClient, app))
|
||||
fmt.Printf(format, "Environment:", app.Spec.Source.Environment)
|
||||
fmt.Printf(format, "Repo:", app.Spec.Source.RepoURL)
|
||||
fmt.Printf(format, "Path:", app.Spec.Source.Path)
|
||||
fmt.Printf(format, "Target:", app.Spec.Source.TargetRevision)
|
||||
if app.Status.ComparisonResult.Error != "" {
|
||||
fmt.Printf(format, "Error:", app.Status.ComparisonResult.Error)
|
||||
}
|
||||
if showParams {
|
||||
printParams(app)
|
||||
}
|
||||
if len(app.Status.ComparisonResult.Resources) > 0 {
|
||||
fmt.Println()
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
fmt.Fprintf(w, "KIND\tNAME\tSTATUS\tHEALTH\n")
|
||||
printAppResources(w, app)
|
||||
_ = w.Flush()
|
||||
switch output {
|
||||
case "yaml":
|
||||
yamlBytes, err := yaml.Marshal(app)
|
||||
errors.CheckError(err)
|
||||
fmt.Println(string(yamlBytes))
|
||||
case "json":
|
||||
jsonBytes, err := json.MarshalIndent(app, "", " ")
|
||||
errors.CheckError(err)
|
||||
fmt.Println(string(jsonBytes))
|
||||
case "":
|
||||
format := "%-15s%s\n"
|
||||
fmt.Printf(format, "Name:", app.Name)
|
||||
fmt.Printf(format, "Server:", app.Spec.Destination.Server)
|
||||
fmt.Printf(format, "Namespace:", app.Spec.Destination.Namespace)
|
||||
fmt.Printf(format, "URL:", appURL(acdClient, app))
|
||||
fmt.Printf(format, "Environment:", app.Spec.Source.Environment)
|
||||
fmt.Printf(format, "Repo:", app.Spec.Source.RepoURL)
|
||||
fmt.Printf(format, "Path:", app.Spec.Source.Path)
|
||||
fmt.Printf(format, "Target:", app.Spec.Source.TargetRevision)
|
||||
if app.Status.ComparisonResult.Error != "" {
|
||||
fmt.Printf(format, "Error:", app.Status.ComparisonResult.Error)
|
||||
}
|
||||
var opState *argoappv1.OperationState
|
||||
if showOperation && app.Status.OperationState != nil {
|
||||
opState = app.Status.OperationState
|
||||
fmt.Println()
|
||||
var opName string
|
||||
if opState.SyncResult != nil {
|
||||
opName = "Sync"
|
||||
} else if opState.RollbackResult != nil {
|
||||
opName = "Rollback"
|
||||
}
|
||||
fmt.Printf(format, "Operation:", opName)
|
||||
fmt.Printf(format, " Phase:", opState.Phase)
|
||||
fmt.Printf(format, " Start:", opState.StartedAt)
|
||||
fmt.Printf(format, " Finished:", opState.FinishedAt)
|
||||
var duration time.Duration
|
||||
if !opState.FinishedAt.IsZero() {
|
||||
duration = time.Second * time.Duration(opState.FinishedAt.Unix()-opState.StartedAt.Unix())
|
||||
} else {
|
||||
duration = time.Second * time.Duration(time.Now().UTC().Unix()-opState.StartedAt.Unix())
|
||||
}
|
||||
fmt.Printf(format, " Duration:", duration)
|
||||
fmt.Printf(format, " Phase:", opState.Phase)
|
||||
if opState.Message != "" {
|
||||
fmt.Printf(format, " Message:", opState.Message)
|
||||
}
|
||||
}
|
||||
if showParams {
|
||||
printParams(app)
|
||||
}
|
||||
if len(app.Status.ComparisonResult.Resources) > 0 {
|
||||
fmt.Println()
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
printAppResources(w, app, opState)
|
||||
_ = w.Flush()
|
||||
}
|
||||
default:
|
||||
log.Fatalf("Unknown output format: %s", output)
|
||||
}
|
||||
},
|
||||
}
|
||||
command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: yaml, json")
|
||||
command.Flags().BoolVar(&showOperation, "show-operation", false, "Show application operation")
|
||||
command.Flags().BoolVar(&showParams, "show-params", false, "Show application parameters and overrides")
|
||||
command.Flags().BoolVar(&refresh, "refresh", false, "Refresh application data when retrieving")
|
||||
return command
|
||||
}
|
||||
|
||||
@@ -342,6 +390,11 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
|
||||
|
||||
// NewApplicationDiffCommand returns a new instance of an `argocd app diff` command
|
||||
func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
refresh bool
|
||||
local string
|
||||
env string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
Use: "diff APPNAME",
|
||||
Short: "Perform a diff against the target and live state",
|
||||
@@ -353,32 +406,76 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
||||
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
|
||||
defer util.Close(conn)
|
||||
appName := args[0]
|
||||
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
|
||||
errors.CheckError(err)
|
||||
targetObjs, err := app.Status.ComparisonResult.TargetObjects()
|
||||
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName, Refresh: refresh})
|
||||
errors.CheckError(err)
|
||||
liveObjs, err := app.Status.ComparisonResult.LiveObjects()
|
||||
errors.CheckError(err)
|
||||
diffResults, err := diff.DiffArray(targetObjs, liveObjs)
|
||||
|
||||
var compareObjs []*unstructured.Unstructured
|
||||
if local != "" {
|
||||
if env == "" {
|
||||
log.Fatal("--env required when performing local diff")
|
||||
}
|
||||
ksApp, err := ksonnet.NewKsonnetApp(local)
|
||||
errors.CheckError(err)
|
||||
compareObjs, err = ksApp.Show(env)
|
||||
errors.CheckError(err)
|
||||
if len(app.Spec.Source.ComponentParameterOverrides) > 0 {
|
||||
log.Warnf("Unable to display parameter overrides")
|
||||
}
|
||||
compareObjs, liveObjs = diff.MatchObjectLists(compareObjs, liveObjs)
|
||||
} else {
|
||||
if env != "" {
|
||||
log.Fatal("--env option invalid when performing git diff")
|
||||
}
|
||||
compareObjs, err = app.Status.ComparisonResult.TargetObjects()
|
||||
errors.CheckError(err)
|
||||
}
|
||||
|
||||
// In order for the diff to be clean, need to set our app labels
|
||||
setAppLabels(appName, compareObjs)
|
||||
diffResults, err := diff.DiffArray(compareObjs, liveObjs)
|
||||
errors.CheckError(err)
|
||||
for i := 0; i < len(targetObjs); i++ {
|
||||
targetObj := targetObjs[i]
|
||||
for i := 0; i < len(compareObjs); i++ {
|
||||
kind, name := getObjKindName(compareObjs[i], liveObjs[i])
|
||||
diffRes := diffResults.Diffs[i]
|
||||
fmt.Printf("===== %s %s ======\n", targetObj.GetKind(), targetObj.GetName())
|
||||
fmt.Printf("===== %s %s ======\n", kind, name)
|
||||
if diffRes.Modified {
|
||||
formatOpts := formatter.AsciiFormatterConfig{
|
||||
Coloring: terminal.IsTerminal(int(os.Stdout.Fd())),
|
||||
}
|
||||
out, err := diffResults.Diffs[i].ASCIIFormat(targetObj, formatOpts)
|
||||
out, err := diffResults.Diffs[i].ASCIIFormat(compareObjs[i], formatOpts)
|
||||
errors.CheckError(err)
|
||||
fmt.Println(out)
|
||||
}
|
||||
}
|
||||
if local != "" && len(app.Spec.Source.ComponentParameterOverrides) > 0 {
|
||||
log.Warnf("Unable to display parameter overrides")
|
||||
}
|
||||
},
|
||||
}
|
||||
command.Flags().BoolVar(&refresh, "refresh", false, "Refresh application data when retrieving")
|
||||
command.Flags().StringVar(&local, "local", "", "Compare live app to a local ksonnet app")
|
||||
command.Flags().StringVar(&env, "env", "", "Compare live app to a specific environment")
|
||||
return command
|
||||
}
|
||||
|
||||
func getObjKindName(compare, live *unstructured.Unstructured) (string, string) {
|
||||
if compare == nil {
|
||||
return live.GetKind(), live.GetName()
|
||||
}
|
||||
return compare.GetKind(), compare.GetName()
|
||||
}
|
||||
|
||||
func setAppLabels(appName string, compareObjs []*unstructured.Unstructured) {
|
||||
for _, obj := range compareObjs {
|
||||
if obj == nil {
|
||||
continue
|
||||
}
|
||||
_ = kubeutil.SetLabel(obj, common.LabelApplicationName, appName)
|
||||
}
|
||||
}
|
||||
|
||||
// NewApplicationDeleteCommand returns a new instance of an `argocd app delete` command
|
||||
func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
@@ -427,8 +524,8 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
||||
var fmtStr string
|
||||
headers := []interface{}{"NAME", "CLUSTER", "NAMESPACE", "STATUS", "HEALTH"}
|
||||
if output == "wide" {
|
||||
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
|
||||
headers = append(headers, "ENV", "REPO", "TARGET")
|
||||
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
|
||||
headers = append(headers, "ENV", "REPO", "PATH", "TARGET")
|
||||
} else {
|
||||
fmtStr = "%s\t%s\t%s\t%s\t%s\n"
|
||||
}
|
||||
@@ -442,7 +539,7 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
||||
app.Status.Health.Status,
|
||||
}
|
||||
if output == "wide" {
|
||||
vals = append(vals, app.Spec.Source.Environment, app.Spec.Source.RepoURL, app.Spec.Source.TargetRevision)
|
||||
vals = append(vals, app.Spec.Source.Environment, app.Spec.Source.RepoURL, app.Spec.Source.Path, app.Spec.Source.TargetRevision)
|
||||
}
|
||||
fmt.Fprintf(w, fmtStr, vals...)
|
||||
}
|
||||
@@ -489,8 +586,7 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
||||
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName})
|
||||
errors.CheckError(err)
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
fmt.Fprintf(w, "KIND\tNAME\tSTATUS\tHEALTH\n")
|
||||
printAppResources(w, app)
|
||||
printAppResources(w, app, nil)
|
||||
_ = w.Flush()
|
||||
prevCompRes := &app.Status.ComparisonResult
|
||||
|
||||
@@ -571,7 +667,19 @@ func watchApp(ctx context.Context, appIf application.ApplicationServiceClient, a
|
||||
}
|
||||
|
||||
// printAppResources prints the resources of an application in a tabwriter table
|
||||
func printAppResources(w io.Writer, app *argoappv1.Application) {
|
||||
// Optionally prints the message from the operation state
|
||||
func printAppResources(w io.Writer, app *argoappv1.Application, opState *argoappv1.OperationState) {
|
||||
messages := make(map[string]string)
|
||||
if opState != nil && opState.SyncResult != nil {
|
||||
for _, resDetails := range opState.SyncResult.Resources {
|
||||
messages[fmt.Sprintf("%s/%s", resDetails.Kind, resDetails.Name)] = resDetails.Message
|
||||
}
|
||||
}
|
||||
if opState != nil {
|
||||
fmt.Fprintf(w, "KIND\tNAME\tSTATUS\tHEALTH\tOPERATIONMSG\n")
|
||||
} else {
|
||||
fmt.Fprintf(w, "KIND\tNAME\tSTATUS\tHEALTH\n")
|
||||
}
|
||||
for _, res := range app.Status.ComparisonResult.Resources {
|
||||
obj, err := argoappv1.UnmarshalToUnstructured(res.TargetState)
|
||||
errors.CheckError(err)
|
||||
@@ -579,7 +687,12 @@ func printAppResources(w io.Writer, app *argoappv1.Application) {
|
||||
obj, err = argoappv1.UnmarshalToUnstructured(res.LiveState)
|
||||
errors.CheckError(err)
|
||||
}
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", obj.GetKind(), obj.GetName(), res.Status, res.Health.Status)
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s", obj.GetKind(), obj.GetName(), res.Status, res.Health.Status)
|
||||
if opState != nil {
|
||||
message := messages[fmt.Sprintf("%s/%s", obj.GetKind(), obj.GetName())]
|
||||
fmt.Fprintf(w, "\t%s", message)
|
||||
}
|
||||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,9 +757,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
||||
status, err := waitUntilOperationCompleted(appIf, appName)
|
||||
errors.CheckError(err)
|
||||
err = printOperationResult(appName, status)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
errors.CheckError(err)
|
||||
if !status.Phase.Successful() && !dryRun {
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -797,9 +908,7 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
|
||||
status, err := waitUntilOperationCompleted(appIf, appName)
|
||||
errors.CheckError(err)
|
||||
err = printOperationResult(appName, status)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
errors.CheckError(err)
|
||||
if !status.Phase.Successful() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientc
|
||||
|
||||
// NewClusterAddCommand returns a new instance of an `argocd cluster add` command
|
||||
func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
|
||||
var (
|
||||
inCluster bool
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
Use: "add",
|
||||
Short: fmt.Sprintf("%s cluster add CONTEXT", cliName),
|
||||
@@ -71,6 +74,9 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
|
||||
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
|
||||
defer util.Close(conn)
|
||||
clst := NewCluster(args[0], conf, managerBearerToken)
|
||||
if inCluster {
|
||||
clst.Server = common.KubernetesInternalAPIServerAddr
|
||||
}
|
||||
clstCreateReq := cluster.ClusterCreateRequest{Cluster: clst}
|
||||
clst, err = clusterIf.Create(context.Background(), &clstCreateReq)
|
||||
errors.CheckError(err)
|
||||
@@ -78,6 +84,7 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
|
||||
},
|
||||
}
|
||||
command.PersistentFlags().StringVar(&pathOpts.LoadingRules.ExplicitPath, pathOpts.ExplicitFileFlag, pathOpts.LoadingRules.ExplicitPath, "use a particular kubeconfig file")
|
||||
command.Flags().BoolVar(&inCluster, "in-cluster", false, "Indicates ArgoCD resides inside this cluster and should connect using the internal k8s hostname (kubernetes.default.svc)")
|
||||
return command
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ const (
|
||||
AuthCookieName = "argocd.token"
|
||||
// ResourcesFinalizerName is a number of application CRD finalizer
|
||||
ResourcesFinalizerName = "resources-finalizer." + MetadataPrefix
|
||||
|
||||
// KubernetesInternalAPIServerAddr is address of the k8s API server when accessing internal to the cluster
|
||||
KubernetesInternalAPIServerAddr = "https://kubernetes.default.svc"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,7 +3,6 @@ apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: argocd-cm
|
||||
namespace: argocd
|
||||
data:
|
||||
# url is the externally facing base URL of ArgoCD.
|
||||
# This field is required when configuring SSO, which ArgoCD uses as part the redirectURI for the
|
||||
|
||||
@@ -4,7 +4,6 @@ apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: argocd-secret
|
||||
namespace: argocd
|
||||
type: Opaque
|
||||
stringData:
|
||||
# bcrypt hash of the string "password"
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: argocd-rbac-cm
|
||||
namespace: argocd
|
||||
data:
|
||||
# policy.csv holds the CSV file policy file which contains additional policy and role definitions.
|
||||
# ArgoCD defines two built-in roles:
|
||||
|
||||
@@ -2,4 +2,3 @@ apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: application-controller
|
||||
namespace: argocd
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: application-controller-role
|
||||
namespace: argocd
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: application-controller-role-binding
|
||||
namespace: argocd
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: application-controller
|
||||
namespace: argocd
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
|
||||
@@ -2,4 +2,3 @@ apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: argocd-server
|
||||
namespace: argocd
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: argocd-server-role
|
||||
namespace: argocd
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: argocd-server-role-binding
|
||||
namespace: argocd
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: argocd-server
|
||||
namespace: argocd
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: argocd-server
|
||||
namespace: argocd
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: argocd-repo-server
|
||||
namespace: argocd
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
|
||||
@@ -2,7 +2,6 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: argocd-repo-server
|
||||
namespace: argocd
|
||||
spec:
|
||||
ports:
|
||||
- port: 8081
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -9,15 +10,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/argoproj/argo-cd/common"
|
||||
"github.com/argoproj/argo-cd/util"
|
||||
"github.com/argoproj/argo-cd/util/cache"
|
||||
"github.com/argoproj/argo-cd/util/git"
|
||||
ksutil "github.com/argoproj/argo-cd/util/ksonnet"
|
||||
"github.com/argoproj/argo-cd/util/kube"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -177,7 +177,7 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani
|
||||
manifests := make([]string, len(targetObjs))
|
||||
for i, target := range targetObjs {
|
||||
if q.AppLabel != "" {
|
||||
err = setAppLabels(target, q.AppLabel)
|
||||
err = kube.SetLabel(target, common.LabelApplicationName, q.AppLabel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -206,28 +206,6 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
// setAppLabels sets our app labels against an unstructured object
|
||||
func setAppLabels(target *unstructured.Unstructured, appName string) error {
|
||||
labels := target.GetLabels()
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
labels[common.LabelApplicationName] = appName
|
||||
target.SetLabels(labels)
|
||||
// special case for deployment: make sure that derived replicaset and pod has application label
|
||||
if target.GetKind() == kube.DeploymentKind {
|
||||
labels, ok := unstructured.NestedMap(target.UnstructuredContent(), "spec", "template", "metadata", "labels")
|
||||
if ok {
|
||||
if labels == nil {
|
||||
labels = make(map[string]interface{})
|
||||
}
|
||||
labels[common.LabelApplicationName] = appName
|
||||
}
|
||||
unstructured.SetNestedMap(target.UnstructuredContent(), labels, "spec", "template", "metadata", "labels")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// tempRepoPath returns a formulated temporary directory location to clone a repository
|
||||
func tempRepoPath(repo string) string {
|
||||
return path.Join(os.TempDir(), strings.Replace(repo, "/", "_", -1))
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/argoproj/argo-cd/reposerver"
|
||||
"github.com/argoproj/argo-cd/reposerver/repository"
|
||||
"github.com/argoproj/argo-cd/util"
|
||||
argoutil "github.com/argoproj/argo-cd/util/argo"
|
||||
"github.com/argoproj/argo-cd/util/db"
|
||||
"github.com/argoproj/argo-cd/util/git"
|
||||
"github.com/argoproj/argo-cd/util/grpc"
|
||||
@@ -169,13 +170,24 @@ func (s *Server) GetManifests(ctx context.Context, q *ApplicationManifestQuery)
|
||||
|
||||
// Get returns an application by name
|
||||
func (s *Server) Get(ctx context.Context, q *ApplicationQuery) (*appv1.Application, error) {
|
||||
a, err := s.appclientset.ArgoprojV1alpha1().Applications(s.ns).Get(*q.Name, metav1.GetOptions{})
|
||||
appIf := s.appclientset.ArgoprojV1alpha1().Applications(s.ns)
|
||||
a, err := appIf.Get(*q.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !s.enf.EnforceClaims(ctx.Value("claims"), "applications", "get", appRBACName(*a)) {
|
||||
return nil, grpc.ErrPermissionDenied
|
||||
}
|
||||
if q.Refresh {
|
||||
_, err = argoutil.RefreshApp(appIf, *q.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a, err = argoutil.WaitForRefresh(appIf, *q.Name, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||
// ApplicationQuery is a query for application resources
|
||||
type ApplicationQuery struct {
|
||||
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||
Refresh bool `protobuf:"varint,2,opt,name=refresh" json:"refresh"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@@ -72,6 +73,13 @@ func (m *ApplicationQuery) GetName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ApplicationQuery) GetRefresh() bool {
|
||||
if m != nil {
|
||||
return m.Refresh
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ApplicationEventsQuery is a query for application resource events
|
||||
type ApplicationResourceEventsQuery struct {
|
||||
Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
|
||||
@@ -1038,6 +1046,14 @@ func (m *ApplicationQuery) MarshalTo(dAtA []byte) (int, error) {
|
||||
i = encodeVarintApplication(dAtA, i, uint64(len(*m.Name)))
|
||||
i += copy(dAtA[i:], *m.Name)
|
||||
}
|
||||
dAtA[i] = 0x10
|
||||
i++
|
||||
if m.Refresh {
|
||||
dAtA[i] = 1
|
||||
} else {
|
||||
dAtA[i] = 0
|
||||
}
|
||||
i++
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
@@ -1531,6 +1547,7 @@ func (m *ApplicationQuery) Size() (n int) {
|
||||
l = len(*m.Name)
|
||||
n += 1 + l + sovApplication(uint64(l))
|
||||
}
|
||||
n += 2
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
@@ -1797,6 +1814,26 @@ func (m *ApplicationQuery) Unmarshal(dAtA []byte) error {
|
||||
s := string(dAtA[iNdEx:postIndex])
|
||||
m.Name = &s
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Refresh", wireType)
|
||||
}
|
||||
var v int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowApplication
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.Refresh = bool(v != 0)
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipApplication(dAtA[iNdEx:])
|
||||
@@ -3487,79 +3524,80 @@ var (
|
||||
func init() { proto.RegisterFile("server/application/application.proto", fileDescriptorApplication) }
|
||||
|
||||
var fileDescriptorApplication = []byte{
|
||||
// 1174 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xc1, 0x6f, 0x1c, 0x35,
|
||||
0x17, 0xff, 0xbc, 0xd9, 0x6c, 0x12, 0xa7, 0xd2, 0x87, 0x4c, 0x1b, 0x56, 0xd3, 0x24, 0x8d, 0x9c,
|
||||
0xa4, 0x4d, 0xb6, 0x74, 0x26, 0x89, 0x90, 0x40, 0x11, 0x12, 0x22, 0x24, 0xb4, 0x81, 0x50, 0x85,
|
||||
0x0d, 0x15, 0x12, 0x17, 0xe4, 0xce, 0xb8, 0x93, 0x21, 0xbb, 0xf6, 0x60, 0x7b, 0x17, 0x2d, 0x55,
|
||||
0x0f, 0x54, 0x08, 0x21, 0x81, 0x84, 0x10, 0x17, 0x6e, 0x40, 0xcf, 0xdc, 0xb8, 0x73, 0xee, 0x11,
|
||||
0x89, 0x7b, 0x85, 0x22, 0x0e, 0xfc, 0x19, 0xc8, 0x9e, 0x99, 0x8c, 0xa7, 0xbb, 0x33, 0x29, 0x62,
|
||||
0xb9, 0x79, 0xfc, 0x9e, 0xdf, 0xfb, 0xbd, 0xf7, 0x7b, 0xfb, 0xde, 0x5b, 0xb8, 0x22, 0xa9, 0xe8,
|
||||
0x53, 0xe1, 0x91, 0x38, 0xee, 0x44, 0x3e, 0x51, 0x11, 0x67, 0xf6, 0xd9, 0x8d, 0x05, 0x57, 0x1c,
|
||||
0xcd, 0x5a, 0x57, 0xce, 0xc5, 0x90, 0x87, 0xdc, 0xdc, 0x7b, 0xfa, 0x94, 0xa8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, 0xbe, 0xef, 0xec, 0xef, 0x36,
|
||||
0x27, 0x2c, 0x45, 0x5b, 0x80, 0x0f, 0x61, 0xd3, 0xc2, 0xf1, 0x0e, 0x61, 0xd1, 0x3d, 0x2a, 0x55,
|
||||
0x39, 0x82, 0x25, 0x38, 0x2d, 0x68, 0x3f, 0x92, 0x11, 0x67, 0xcd, 0x9a, 0x0e, 0x28, 0x35, 0x7a,
|
||||
0x76, 0x8b, 0x2f, 0xc1, 0xe7, 0x8b, 0x91, 0xc5, 0x9c, 0x49, 0x8a, 0x1f, 0x81, 0x82, 0xa7, 0x37,
|
||||
0x04, 0x25, 0x8a, 0xb6, 0xe9, 0xc7, 0x3d, 0x2a, 0x15, 0x62, 0xd0, 0x2e, 0x31, 0xe3, 0x70, 0x76,
|
||||
0xeb, 0x4d, 0x37, 0x27, 0xc4, 0xcd, 0x08, 0x31, 0x87, 0x0f, 0xfd, 0xc0, 0x8d, 0x4f, 0x42, 0x57,
|
||||
0x73, 0xeb, 0xda, 0xe5, 0x9a, 0x71, 0xeb, 0x5a, 0x9e, 0xb2, 0xa8, 0x2d, 0x3d, 0x34, 0x07, 0x1b,
|
||||
0xbd, 0x58, 0x52, 0xa1, 0x4c, 0x0c, 0xd3, 0xed, 0xf4, 0x0b, 0x7f, 0x5e, 0x04, 0x79, 0x27, 0x0e,
|
||||
0x2c, 0x90, 0xc7, 0xff, 0x21, 0xc8, 0x02, 0x3c, 0x7c, 0xab, 0x80, 0x62, 0x97, 0x76, 0x68, 0x8e,
|
||||
0x62, 0x14, 0x29, 0x4d, 0x38, 0xe5, 0x13, 0xe9, 0x93, 0x80, 0xa6, 0xf1, 0x64, 0x9f, 0xf8, 0x4b,
|
||||
0x00, 0xe7, 0x2c, 0x53, 0x47, 0x03, 0xe6, 0x57, 0x19, 0x2a, 0xb2, 0x5b, 0x1b, 0x66, 0x17, 0xcd,
|
||||
0xc3, 0x46, 0x20, 0x06, 0xed, 0x1e, 0x33, 0x25, 0x35, 0x9d, 0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x17, 0xed, 0xfc, 0xb1, 0xc6, 0xa5, 0x48, 0xd4, 0x39,
|
||||
0x88, 0x18, 0x95, 0xcd, 0x86, 0xe5, 0x30, 0xbf, 0xd6, 0x64, 0xdc, 0xe3, 0x9d, 0x0e, 0xff, 0xa4,
|
||||
0x39, 0x65, 0x93, 0x91, 0xdc, 0xe1, 0x4f, 0xe1, 0xf4, 0x01, 0x0f, 0xf7, 0x98, 0x12, 0x03, 0xb4,
|
||||
0x08, 0xa7, 0x74, 0x38, 0x94, 0xa9, 0x24, 0x2d, 0xa9, 0x6a, 0x76, 0x89, 0x6e, 0xc3, 0x19, 0x15,
|
||||
0x75, 0xe9, 0x91, 0x22, 0xdd, 0x38, 0x2d, 0xc8, 0x7f, 0x80, 0xfb, 0x0c, 0x59, 0x66, 0x62, 0xeb,
|
||||
0xaf, 0xff, 0x43, 0x64, 0x57, 0x25, 0x15, 0xfd, 0xc8, 0xa7, 0xe8, 0x1b, 0x00, 0xeb, 0x07, 0x91,
|
||||
0x54, 0x68, 0xa1, 0x50, 0xc8, 0x4f, 0x8f, 0x15, 0x67, 0x4c, 0x3f, 0x06, 0xed, 0x0a, 0xcf, 0x3f,
|
||||
0xfc, 0xfd, 0xcf, 0xef, 0x6a, 0x73, 0xe8, 0xa2, 0x99, 0xd0, 0xfd, 0x4d, 0x7b, 0x60, 0x4a, 0xf4,
|
||||
0x35, 0x80, 0x48, 0xab, 0x15, 0xa7, 0x14, 0xba, 0x5e, 0x86, 0x6f, 0xc4, 0x34, 0x73, 0x16, 0xac,
|
||||
0x4c, 0xb9, 0x7a, 0x05, 0xd0, 0x79, 0x31, 0x0a, 0x06, 0x40, 0xcb, 0x00, 0x58, 0x41, 0x78, 0x14,
|
||||
0x00, 0xef, 0xbe, 0xae, 0xcf, 0x07, 0x1e, 0x4d, 0xfc, 0xfe, 0x00, 0xe0, 0xe4, 0xfb, 0x44, 0xf9,
|
||||
0xc7, 0xe7, 0x65, 0xe8, 0x70, 0x3c, 0x19, 0x32, 0xbe, 0x0c, 0x54, 0xbc, 0x6c, 0x60, 0x2e, 0xa0,
|
||||
0xcb, 0x19, 0x4c, 0xa9, 0x04, 0x25, 0xdd, 0x02, 0xda, 0x0d, 0x80, 0x1e, 0x01, 0xd8, 0x48, 0x06,
|
||||
0x1c, 0x5a, 0x2d, 0x83, 0x58, 0x18, 0x80, 0xce, 0x98, 0xc6, 0x08, 0x5e, 0x37, 0x00, 0x97, 0xf1,
|
||||
0x48, 0x22, 0xb7, 0x0b, 0x33, 0xf0, 0x5b, 0x00, 0x27, 0x6e, 0xd2, 0x73, 0xcb, 0x6c, 0x5c, 0xc8,
|
||||
0x86, 0x52, 0x37, 0x82, 0x61, 0xf4, 0x10, 0xc0, 0x0b, 0x37, 0xa9, 0xca, 0xd6, 0x10, 0x59, 0x9e,
|
||||
0xbe, 0xc2, 0xa6, 0xe2, 0xcc, 0xbb, 0xd6, 0x26, 0x96, 0x89, 0xce, 0x56, 0x8f, 0x1b, 0xc6, 0xf5,
|
||||
0x35, 0xb4, 0x5a, 0x55, 0x5c, 0xdd, 0x33, 0x9f, 0xbf, 0x02, 0xd8, 0x48, 0xa6, 0x53, 0xb9, 0xfb,
|
||||
0xc2, 0x66, 0x30, 0xb6, 0x1c, 0xed, 0x19, 0xa0, 0xaf, 0x39, 0x1b, 0xa3, 0x81, 0xda, 0xef, 0x75,
|
||||
0x6b, 0x09, 0x88, 0x22, 0xae, 0x41, 0x5f, 0x64, 0xf6, 0x17, 0x00, 0x61, 0x3e, 0x5e, 0xd1, 0x7a,
|
||||
0x75, 0x10, 0xd6, 0x08, 0x76, 0xc6, 0x38, 0x60, 0xb1, 0x6b, 0x82, 0x59, 0x73, 0x96, 0xaa, 0xb2,
|
||||
0xae, 0xc7, 0xef, 0xb6, 0x19, 0xc2, 0xa8, 0x0f, 0x1b, 0xc9, 0xc0, 0x2b, 0xcf, 0x7a, 0x61, 0x13,
|
||||
0x72, 0x96, 0x2a, 0xfa, 0x4f, 0x42, 0x7c, 0x5a, 0x73, 0xad, 0xca, 0x9a, 0xfb, 0x11, 0xc0, 0xba,
|
||||
0xde, 0x8b, 0xd0, 0x72, 0x99, 0x3d, 0x6b, 0x6b, 0x1a, 0x1b, 0xd5, 0xd7, 0x0d, 0xb4, 0x55, 0x5c,
|
||||
0x9d, 0x9d, 0x01, 0xf3, 0xb7, 0x41, 0x0b, 0xfd, 0x0c, 0xe0, 0x74, 0xb6, 0x94, 0xa0, 0x6b, 0xa5,
|
||||
0x61, 0x17, 0xd7, 0x96, 0xb1, 0x41, 0xf5, 0x0c, 0xd4, 0x75, 0xbc, 0x52, 0x05, 0x55, 0xa4, 0xce,
|
||||
0x35, 0xdc, 0xaf, 0x00, 0x9c, 0x39, 0xdb, 0x5d, 0xd0, 0x5a, 0x35, 0x9b, 0xf9, 0x7a, 0xf3, 0x0c,
|
||||
0x84, 0x6e, 0x19, 0x28, 0x2f, 0xb6, 0x5a, 0x55, 0x50, 0x62, 0x1e, 0x48, 0xef, 0x7e, 0xba, 0xbb,
|
||||
0x3c, 0x40, 0x9f, 0x01, 0x38, 0x95, 0xee, 0x3e, 0x68, 0xa5, 0xcc, 0x83, 0xbd, 0x1c, 0x39, 0x97,
|
||||
0x0a, 0x5a, 0xd9, 0x7e, 0x80, 0x5f, 0x36, 0xce, 0x37, 0x91, 0xf7, 0xec, 0xce, 0xbd, 0x0e, 0x0f,
|
||||
0xe5, 0x06, 0xd8, 0x79, 0xf5, 0xf1, 0xe9, 0x22, 0xf8, 0xed, 0x74, 0x11, 0xfc, 0x71, 0xba, 0x08,
|
||||
0x3e, 0x70, 0xab, 0xfe, 0x68, 0x0e, 0xff, 0x21, 0xff, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x87, 0x2f,
|
||||
0x7b, 0x79, 0xa5, 0x0f, 0x00, 0x00,
|
||||
// 1186 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x41, 0x6f, 0x1b, 0x45,
|
||||
0x14, 0x66, 0x1c, 0xc7, 0x49, 0x26, 0x95, 0x40, 0x43, 0x1b, 0xac, 0x6d, 0x92, 0x5a, 0x93, 0x84,
|
||||
0x3a, 0x2e, 0xdd, 0x4d, 0x2c, 0x24, 0x50, 0x84, 0x84, 0x08, 0x49, 0xdb, 0x40, 0xa8, 0x82, 0x43,
|
||||
0x85, 0xc4, 0x05, 0x4d, 0x77, 0x27, 0xeb, 0x25, 0xf6, 0xce, 0x32, 0x33, 0x36, 0x32, 0x55, 0x0f,
|
||||
0x54, 0x08, 0x21, 0x81, 0x84, 0x10, 0x17, 0x6e, 0x40, 0xcf, 0xdc, 0xb8, 0x73, 0xee, 0x11, 0x89,
|
||||
0x7b, 0x85, 0x22, 0x0e, 0xfc, 0x0c, 0x34, 0xb3, 0xbb, 0xde, 0xd9, 0xda, 0xde, 0x14, 0xe1, 0xde,
|
||||
0x66, 0xdf, 0xbc, 0x79, 0xef, 0x7b, 0xef, 0x7b, 0x7e, 0xef, 0x19, 0xae, 0x0b, 0xca, 0xfb, 0x94,
|
||||
0x3b, 0x24, 0x8a, 0x3a, 0x81, 0x4b, 0x64, 0xc0, 0x42, 0xf3, 0x6c, 0x47, 0x9c, 0x49, 0x86, 0x16,
|
||||
0x0d, 0x91, 0x75, 0xd1, 0x67, 0x3e, 0xd3, 0x72, 0x47, 0x9d, 0x62, 0x15, 0x6b, 0xd9, 0x67, 0xcc,
|
||||
0xef, 0x50, 0x87, 0x44, 0x81, 0x43, 0xc2, 0x90, 0x49, 0xad, 0x2c, 0x92, 0x5b, 0x7c, 0xfa, 0xba,
|
||||
0xb0, 0x03, 0xa6, 0x6f, 0x5d, 0xc6, 0xa9, 0xd3, 0xdf, 0x76, 0x7c, 0x1a, 0x52, 0x4e, 0x24, 0xf5,
|
||||
0x12, 0x9d, 0x57, 0x33, 0x9d, 0x2e, 0x71, 0xdb, 0x41, 0x48, 0xf9, 0xc0, 0x89, 0x4e, 0x7d, 0x25,
|
||||
0x10, 0x4e, 0x97, 0x4a, 0x32, 0xee, 0xd5, 0x81, 0x1f, 0xc8, 0x76, 0xef, 0xae, 0xed, 0xb2, 0xae,
|
||||
0x43, 0xb8, 0x06, 0xf6, 0x89, 0x3e, 0x5c, 0x77, 0xbd, 0xec, 0xb5, 0x19, 0x5e, 0x7f, 0x9b, 0x74,
|
||||
0xa2, 0x36, 0x19, 0x35, 0xb5, 0x5b, 0x64, 0x8a, 0xd3, 0x88, 0x25, 0xb9, 0xd2, 0xc7, 0x40, 0x32,
|
||||
0x3e, 0x30, 0x8e, 0xb1, 0x0d, 0x7c, 0x03, 0xbe, 0xf0, 0x56, 0xe6, 0xeb, 0xfd, 0x1e, 0xe5, 0x03,
|
||||
0x84, 0x60, 0x39, 0x24, 0x5d, 0x5a, 0x05, 0x35, 0x50, 0x5f, 0x68, 0xe9, 0x33, 0x5a, 0x85, 0x73,
|
||||
0x9c, 0x9e, 0x70, 0x2a, 0xda, 0xd5, 0x52, 0x0d, 0xd4, 0xe7, 0x77, 0xcb, 0x8f, 0x1e, 0x5f, 0x79,
|
||||
0xae, 0x95, 0x0a, 0xf1, 0x57, 0x00, 0xae, 0x1a, 0x86, 0x5a, 0x54, 0xb0, 0x1e, 0x77, 0xe9, 0x7e,
|
||||
0x9f, 0x86, 0x52, 0x3c, 0x69, 0xb6, 0x34, 0x34, 0x5b, 0x87, 0x17, 0x78, 0xa2, 0x7a, 0x5b, 0xdd,
|
||||
0x95, 0xd4, 0x5d, 0x62, 0x3b, 0x77, 0x83, 0x5e, 0x86, 0x8b, 0xe9, 0xf7, 0x9d, 0x83, 0xbd, 0xea,
|
||||
0x8c, 0xa1, 0x68, 0x5e, 0xe0, 0x23, 0x58, 0x35, 0x70, 0xbc, 0x47, 0xc2, 0xe0, 0x84, 0x0a, 0x39,
|
||||
0x19, 0x41, 0x0d, 0xce, 0x73, 0xda, 0x0f, 0x44, 0xc0, 0x42, 0x1d, 0x59, 0x6a, 0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x1f, 0x4a, 0x3e, 0x50, 0x3d, 0x5b, 0x85, 0x43,
|
||||
0x43, 0x19, 0xa7, 0x25, 0xed, 0xd9, 0x89, 0x10, 0xdd, 0x86, 0x0b, 0x32, 0xe8, 0xd2, 0x63, 0x49,
|
||||
0xba, 0x51, 0x52, 0x90, 0xff, 0x01, 0xf7, 0x10, 0x59, 0x6a, 0xa2, 0xf9, 0xcf, 0xf3, 0x10, 0x99,
|
||||
0x55, 0x49, 0x79, 0x3f, 0x70, 0x29, 0xfa, 0x0e, 0xc0, 0xf2, 0x61, 0x20, 0x24, 0x5a, 0xc9, 0x15,
|
||||
0xf2, 0x93, 0x63, 0xc7, 0x9a, 0xd2, 0x8f, 0x41, 0xb9, 0xc2, 0xcb, 0x0f, 0xfe, 0xfc, 0xfb, 0x87,
|
||||
0xd2, 0x12, 0xba, 0xa8, 0x27, 0x78, 0x7f, 0xdb, 0x1c, 0xa8, 0x02, 0x7d, 0x0b, 0x20, 0x52, 0x6a,
|
||||
0xf9, 0x29, 0x85, 0xae, 0x4d, 0xc2, 0x37, 0x66, 0x9a, 0x59, 0x2b, 0x46, 0xa6, 0x6c, 0xb5, 0x22,
|
||||
0xa8, 0xbc, 0x68, 0x05, 0x0d, 0xa0, 0xa1, 0x01, 0xac, 0x23, 0x3c, 0x0e, 0x80, 0x73, 0x4f, 0xd5,
|
||||
0xe7, 0x7d, 0x87, 0xc6, 0x7e, 0x7f, 0x02, 0x70, 0xf6, 0x43, 0x22, 0xdd, 0xf6, 0x79, 0x19, 0x3a,
|
||||
0x9a, 0x4e, 0x86, 0xb4, 0x2f, 0x0d, 0x15, 0xaf, 0x69, 0x98, 0x2b, 0xe8, 0x72, 0x0a, 0x53, 0x48,
|
||||
0x4e, 0x49, 0x37, 0x87, 0x76, 0x0b, 0xa0, 0x87, 0x00, 0x56, 0xe2, 0x01, 0x87, 0x36, 0x26, 0x41,
|
||||
0xcc, 0x0d, 0x40, 0x6b, 0x4a, 0x63, 0x04, 0x6f, 0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7c, 0xba, 0x94, 0xa0, 0xab, 0x13, 0xc3, 0xce, 0xaf, 0x2d,
|
||||
0x53, 0x83, 0xea, 0x68, 0xa8, 0x9b, 0x78, 0xbd, 0x08, 0x2a, 0x4f, 0x9c, 0x2b, 0xb8, 0xdf, 0x00,
|
||||
0xb8, 0x30, 0xdc, 0x5d, 0x50, 0xbd, 0x98, 0xcd, 0x6c, 0xbd, 0x79, 0x0a, 0x42, 0x9b, 0x1a, 0xca,
|
||||
0x2b, 0x8d, 0x46, 0x11, 0x94, 0x88, 0x79, 0xc2, 0xb9, 0x97, 0xec, 0x2e, 0xf7, 0xd1, 0x17, 0x00,
|
||||
0xce, 0x25, 0xbb, 0x0f, 0x5a, 0x9f, 0xe4, 0xc1, 0x5c, 0x8e, 0xac, 0x4b, 0x39, 0xad, 0x74, 0x3f,
|
||||
0xc0, 0xaf, 0x69, 0xe7, 0xdb, 0xc8, 0x79, 0x7a, 0xe7, 0x4e, 0x87, 0xf9, 0x62, 0x0b, 0xec, 0xbe,
|
||||
0xf1, 0xe8, 0x6c, 0x15, 0xfc, 0x71, 0xb6, 0x0a, 0xfe, 0x3a, 0x5b, 0x05, 0x1f, 0xd9, 0x45, 0x7f,
|
||||
0x44, 0x47, 0xff, 0xb0, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x33, 0x2f, 0xbb, 0xc5, 0x0f,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
@@ -126,6 +126,10 @@ func request_ApplicationService_Create_0(ctx context.Context, marshaler runtime.
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_ApplicationService_Get_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_ApplicationService_Get_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ApplicationQuery
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -148,6 +152,10 @@ func request_ApplicationService_Get_0(ctx context.Context, marshaler runtime.Mar
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ApplicationService_Get_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Get(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import "github.com/argoproj/argo-cd/reposerver/repository/repository.proto";
|
||||
// ApplicationQuery is a query for application resources
|
||||
message ApplicationQuery {
|
||||
optional string name = 1;
|
||||
optional bool refresh = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// ApplicationEventsQuery is a query for application resource events
|
||||
|
||||
@@ -48,6 +48,7 @@ import (
|
||||
"github.com/argoproj/argo-cd/util/rbac"
|
||||
util_session "github.com/argoproj/argo-cd/util/session"
|
||||
settings_util "github.com/argoproj/argo-cd/util/settings"
|
||||
tlsutil "github.com/argoproj/argo-cd/util/tls"
|
||||
"github.com/argoproj/argo-cd/util/webhook"
|
||||
)
|
||||
|
||||
@@ -228,6 +229,10 @@ func (a *ArgoCDServer) watchSettings(ctx context.Context) {
|
||||
prevGitHubSecret := a.settings.WebhookGitHubSecret
|
||||
prevGitLabSecret := a.settings.WebhookGitLabSecret
|
||||
prevBitBucketUUID := a.settings.WebhookBitbucketUUID
|
||||
var prevCert, prevCertKey string
|
||||
if a.settings.Certificate != nil {
|
||||
prevCert, prevCertKey = tlsutil.EncodeX509KeyPairString(*a.settings.Certificate)
|
||||
}
|
||||
|
||||
for {
|
||||
<-updateCh
|
||||
@@ -249,6 +254,14 @@ func (a *ArgoCDServer) watchSettings(ctx context.Context) {
|
||||
log.Infof("bitbucket uuid modified. restarting")
|
||||
break
|
||||
}
|
||||
var newCert, newCertKey string
|
||||
if a.settings.Certificate != nil {
|
||||
newCert, newCertKey = tlsutil.EncodeX509KeyPairString(*a.settings.Certificate)
|
||||
}
|
||||
if newCert != prevCert || newCertKey != prevCertKey {
|
||||
log.Infof("tls certificate modified. restarting")
|
||||
break
|
||||
}
|
||||
}
|
||||
log.Info("shutting down settings watch")
|
||||
a.Shutdown()
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package argo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
apierr "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
|
||||
"github.com/argoproj/argo-cd/common"
|
||||
argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/application/v1alpha1"
|
||||
log "github.com/sirupsen/logrus"
|
||||
apierr "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
// RefreshApp updates the refresh annotation of an application to coerce the controller to process it
|
||||
@@ -46,3 +53,54 @@ func RefreshApp(appIf v1alpha1.ApplicationInterface, name string) (*argoappv1.Ap
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// WaitForRefresh watches a workflow until its comparison timestamp is after the refresh timestamp
|
||||
func WaitForRefresh(appIf v1alpha1.ApplicationInterface, name string, timeout *time.Duration) (*argoappv1.Application, error) {
|
||||
ctx := context.Background()
|
||||
var cancel context.CancelFunc
|
||||
if timeout != nil {
|
||||
ctx, cancel = context.WithTimeout(ctx, *timeout)
|
||||
defer cancel()
|
||||
}
|
||||
fieldSelector := fields.ParseSelectorOrDie(fmt.Sprintf("metadata.name=%s", name))
|
||||
listOpts := metav1.ListOptions{FieldSelector: fieldSelector.String()}
|
||||
watchIf, err := appIf.Watch(listOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer watchIf.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err := ctx.Err()
|
||||
if err != nil {
|
||||
if err == context.DeadlineExceeded {
|
||||
return nil, fmt.Errorf("Timed out (%v) waiting for application to refresh", timeout)
|
||||
}
|
||||
return nil, fmt.Errorf("Error waiting for refresh: %v", err)
|
||||
}
|
||||
return nil, fmt.Errorf("Application watch on %s closed", name)
|
||||
case next := <-watchIf.ResultChan():
|
||||
if next.Type == watch.Error {
|
||||
errMsg := "Application watch completed with error"
|
||||
if status, ok := next.Object.(*metav1.Status); ok {
|
||||
errMsg = fmt.Sprintf("%s: %v", errMsg, status)
|
||||
}
|
||||
return nil, errors.New(errMsg)
|
||||
}
|
||||
app, ok := next.Object.(*argoappv1.Application)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Application event object failed conversion: %v", next)
|
||||
}
|
||||
refreshTimestampStr := app.ObjectMeta.Annotations[common.AnnotationKeyRefresh]
|
||||
refreshTimestamp, err := time.Parse(time.RFC3339, refreshTimestampStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to parse '%s': %v", common.AnnotationKeyRefresh, err)
|
||||
}
|
||||
if app.Status.ComparisonResult.ComparedAt.After(refreshTimestamp) {
|
||||
return app, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package argo
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
|
||||
"github.com/argoproj/argo-cd/common"
|
||||
argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/fake"
|
||||
"github.com/stretchr/testify/assert"
|
||||
testcore "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
func TestRefreshApp(t *testing.T) {
|
||||
@@ -21,3 +28,34 @@ func TestRefreshApp(t *testing.T) {
|
||||
//_, ok := newApp.Annotations[common.AnnotationKeyRefresh]
|
||||
//assert.True(t, ok)
|
||||
}
|
||||
|
||||
func TestWaitForRefresh(t *testing.T) {
|
||||
appClientset := appclientset.NewSimpleClientset()
|
||||
|
||||
// Verify timeout
|
||||
appIf := appClientset.ArgoprojV1alpha1().Applications("default")
|
||||
oneHundredMs := 100 * time.Millisecond
|
||||
app, err := WaitForRefresh(appIf, "test-app", &oneHundredMs)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, app)
|
||||
assert.Contains(t, strings.ToLower(err.Error()), "timed out")
|
||||
|
||||
// Verify success
|
||||
var testApp argoappv1.Application
|
||||
testApp.Name = "test-app"
|
||||
testApp.Namespace = "default"
|
||||
testApp.ObjectMeta.Annotations = map[string]string{
|
||||
common.AnnotationKeyRefresh: time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
testApp.Status.ComparisonResult.ComparedAt = metav1.Time{Time: time.Now().UTC()}
|
||||
appClientset = appclientset.NewSimpleClientset()
|
||||
|
||||
appIf = appClientset.ArgoprojV1alpha1().Applications("default")
|
||||
watcher := watch.NewFake()
|
||||
appClientset.PrependWatchReactor("applications", testcore.DefaultWatchReactor(watcher, nil))
|
||||
// simulate add/update/delete watch events
|
||||
go watcher.Add(&testApp)
|
||||
app, err = WaitForRefresh(appIf, "test-app", &oneHundredMs)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, app)
|
||||
}
|
||||
|
||||
@@ -147,6 +147,53 @@ func getLastAppliedConfigAnnotation(live *unstructured.Unstructured) *unstructur
|
||||
return &obj
|
||||
}
|
||||
|
||||
// MatchObjectLists takes two possibly disjoint lists of Unstructured objects, and returns two new
|
||||
// lists of equal lengths, filled out with nils from missing objects in the opposite list.
|
||||
// These lists can then be passed into DiffArray for comparison
|
||||
func MatchObjectLists(leftObjs, rightObjs []*unstructured.Unstructured) ([]*unstructured.Unstructured, []*unstructured.Unstructured) {
|
||||
newLeftObjs := make([]*unstructured.Unstructured, 0)
|
||||
newRightObjs := make([]*unstructured.Unstructured, 0)
|
||||
|
||||
for _, left := range leftObjs {
|
||||
if left == nil {
|
||||
continue
|
||||
}
|
||||
newLeftObjs = append(newLeftObjs, left)
|
||||
right := objByKindName(rightObjs, left.GetKind(), left.GetName())
|
||||
newRightObjs = append(newRightObjs, right)
|
||||
}
|
||||
|
||||
for _, right := range rightObjs {
|
||||
if right == nil {
|
||||
continue
|
||||
}
|
||||
left := objByKindName(leftObjs, right.GetKind(), right.GetName())
|
||||
if left != nil {
|
||||
// object exists in both list. this object was already appended to both lists in the
|
||||
// first for/loop
|
||||
continue
|
||||
}
|
||||
// if we get here, we found a right which doesn't exist in the left object list.
|
||||
// append a nil to the left object list
|
||||
newLeftObjs = append(newLeftObjs, nil)
|
||||
newRightObjs = append(newRightObjs, right)
|
||||
|
||||
}
|
||||
return newLeftObjs, newRightObjs
|
||||
}
|
||||
|
||||
func objByKindName(objs []*unstructured.Unstructured, kind, name string) *unstructured.Unstructured {
|
||||
for _, obj := range objs {
|
||||
if obj == nil {
|
||||
continue
|
||||
}
|
||||
if obj.GetKind() == kind && obj.GetName() == name {
|
||||
return obj
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiffArray performs a diff on a list of unstructured objects. Objects are expected to match
|
||||
// environments
|
||||
func DiffArray(configArray, liveArray []*unstructured.Unstructured) (*DiffResultList, error) {
|
||||
|
||||
@@ -93,6 +93,34 @@ func MustToUnstructured(obj interface{}) *unstructured.Unstructured {
|
||||
return uObj
|
||||
}
|
||||
|
||||
// SetLabel sets our app labels against an unstructured object
|
||||
func SetLabel(target *unstructured.Unstructured, key, val string) error {
|
||||
labels := target.GetLabels()
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
labels[key] = val
|
||||
target.SetLabels(labels)
|
||||
// special case for deployment: make sure that derived replicaset and pod has application label
|
||||
if target.GetKind() == DeploymentKind {
|
||||
labels, ok, err := unstructured.NestedMap(target.UnstructuredContent(), "spec", "template", "metadata", "labels")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok {
|
||||
if labels == nil {
|
||||
labels = make(map[string]interface{})
|
||||
}
|
||||
labels[key] = val
|
||||
}
|
||||
err = unstructured.SetNestedMap(target.UnstructuredContent(), labels, "spec", "template", "metadata", "labels")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCachedServerResources discovers API resources supported by a Kube API server.
|
||||
// Caches the results for apiResourceCacheDuration (per host)
|
||||
func GetCachedServerResources(host string, disco discovery.DiscoveryInterface) ([]*metav1.APIResourceList, error) {
|
||||
|
||||
@@ -200,9 +200,9 @@ func (mgr *SettingsManager) SaveSettings(settings *ArgoCDSettings) error {
|
||||
argoCDSecret.StringData[settingsWebhookBitbucketUUIDKey] = settings.WebhookBitbucketUUID
|
||||
}
|
||||
if settings.Certificate != nil {
|
||||
certBytes, keyBytes := tlsutil.EncodeX509KeyPair(*settings.Certificate)
|
||||
argoCDSecret.StringData[settingServerCertificate] = string(certBytes)
|
||||
argoCDSecret.StringData[settingServerPrivateKey] = string(keyBytes)
|
||||
cert, key := tlsutil.EncodeX509KeyPairString(*settings.Certificate)
|
||||
argoCDSecret.StringData[settingServerCertificate] = cert
|
||||
argoCDSecret.StringData[settingServerPrivateKey] = key
|
||||
} else {
|
||||
delete(argoCDSecret.Data, settingServerCertificate)
|
||||
delete(argoCDSecret.Data, settingServerPrivateKey)
|
||||
|
||||
@@ -172,9 +172,15 @@ func GenerateX509KeyPair(opts CertOptions) (*tls.Certificate, error) {
|
||||
return &cert, nil
|
||||
}
|
||||
|
||||
// EncodeX509KeyPair encodes a TLS Certificate into its pem encoded for storage
|
||||
// EncodeX509KeyPair encodes a TLS Certificate into its pem encoded format for storage
|
||||
func EncodeX509KeyPair(cert tls.Certificate) ([]byte, []byte) {
|
||||
certpem := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cert.Certificate[0]})
|
||||
keypem := pem.EncodeToMemory(pemBlockForKey(cert.PrivateKey))
|
||||
return certpem, keypem
|
||||
}
|
||||
|
||||
// EncodeX509KeyPairString encodes a TLS Certificate into its pem encoded string format
|
||||
func EncodeX509KeyPairString(cert tls.Certificate) (string, string) {
|
||||
certpem, keypem := EncodeX509KeyPair(cert)
|
||||
return string(certpem), string(keypem)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user