From 0fc65eb7870ec01b3d545e2e68a321ec20bc380d Mon Sep 17 00:00:00 2001 From: qiaozp <47812250+chivalryq@users.noreply.github.com> Date: Tue, 14 Dec 2021 14:52:10 +0800 Subject: [PATCH] Feat: add mock server (#2911) * add mock server Signed-off-by: qiaozp * use mock server Signed-off-by: qiaozp * reviewable Signed-off-by: qiaozp * reviewable Signed-off-by: qiaozp * fix test Signed-off-by: qiaozp * complate terraform-alibaba addon Signed-off-by: qiaozp * move to test dir Signed-off-by: qiaozp * fix test Signed-off-by: qiaozp * complete terraform Signed-off-by: qiaozp * fix test Signed-off-by: qiaozp * add back oss Signed-off-by: qiaozp * fix test Signed-off-by: qiaozp * remove useless readme Signed-off-by: qiaozp --- Makefile | 4 + e2e/addon/addon_test.go | 112 +-- e2e/addon/mock/mock_server.go | 112 +++ .../testdata/example/definitions/helm.yaml | 62 ++ e2e/addon/mock/testdata/example/metadata.yaml | 23 + .../testdata/example/resources/configmap.cue | 12 + .../testdata/example/resources/parameter.cue | 3 + .../resources/service/source-controller.yaml | 17 + e2e/addon/mock/testdata/example/template.yaml | 22 + .../fluxcd/definitions/helm-release-def.yaml | 182 +++++ .../fluxcd/definitions/json-patch.yaml | 47 ++ .../fluxcd/definitions/kustomize-patch.yaml | 39 + .../fluxcd/definitions/kustomize.yaml | 228 ++++++ .../fluxcd/definitions/strategy-merge.yaml | 25 + e2e/addon/mock/testdata/fluxcd/metadata.yaml | 18 + .../fluxcd/resources/crds/bucket.yaml | 220 ++++++ .../fluxcd/resources/crds/git-repo.yaml | 321 ++++++++ .../fluxcd/resources/crds/helm-chart.yaml | 235 ++++++ .../fluxcd/resources/crds/helm-release.yaml | 738 ++++++++++++++++++ .../fluxcd/resources/crds/helm-repo.yaml | 208 +++++ .../fluxcd/resources/crds/kustomize.yaml | 539 +++++++++++++ .../resources/deployment/helm-controller.yaml | 68 ++ .../deployment/kustomize-controller.yaml | 70 ++ .../deployment/source-controller.yaml | 79 ++ .../resources/rbac/binding-cluster-admin.yaml | 17 + .../rbac/binding-crd-controller.yaml | 23 + .../fluxcd/resources/rbac/crd-controller.yaml | 71 ++ .../resources/rbac/rbac-helm-controller.yaml | 7 + .../rbac/rbac-kustomize-controller.yaml | 7 + .../rbac/rbac-source-controller.yaml | 7 + .../service/svc-source-controller.yaml | 17 + .../resources/service/webhook-receiver.yaml | 17 + e2e/addon/mock/testdata/fluxcd/template.yaml | 6 + .../definitions/terraform-alibaba-ack.yaml | 19 + .../definitions/terraform-alibaba-oss.yaml | 42 + .../testdata/terraform-alibaba/metadata.yaml | 0 .../resources/alibaba-account-creds.cue | 18 + .../resources/alibaba-provider.cue | 23 + .../terraform-alibaba/resources/parameter.cue | 5 + .../testdata/terraform-alibaba/template.yaml | 5 + .../mock}/testdata/terraform/metadata.yaml | 0 .../mock/testdata/terraform/template.yaml | 30 + .../testdata/test-addon/metadata.yaml | 0 .../testdata/test-addon/template.yaml | 0 e2e/addon/mock/utils/utils.go | 74 ++ 45 files changed, 3662 insertions(+), 110 deletions(-) create mode 100644 e2e/addon/mock/mock_server.go create mode 100644 e2e/addon/mock/testdata/example/definitions/helm.yaml create mode 100644 e2e/addon/mock/testdata/example/metadata.yaml create mode 100644 e2e/addon/mock/testdata/example/resources/configmap.cue create mode 100644 e2e/addon/mock/testdata/example/resources/parameter.cue create mode 100644 e2e/addon/mock/testdata/example/resources/service/source-controller.yaml create mode 100644 e2e/addon/mock/testdata/example/template.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/definitions/helm-release-def.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/definitions/json-patch.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/definitions/kustomize-patch.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/definitions/kustomize.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/definitions/strategy-merge.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/metadata.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/bucket.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/git-repo.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/helm-chart.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/helm-release.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/helm-repo.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/crds/kustomize.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/deployment/helm-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/deployment/kustomize-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/deployment/source-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-cluster-admin.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-crd-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/crd-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-helm-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-kustomize-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-source-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/service/svc-source-controller.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/resources/service/webhook-receiver.yaml create mode 100644 e2e/addon/mock/testdata/fluxcd/template.yaml create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-ack.yaml create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-oss.yaml rename {pkg/addon => e2e/addon/mock}/testdata/terraform-alibaba/metadata.yaml (100%) create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-account-creds.cue create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-provider.cue create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/resources/parameter.cue create mode 100644 e2e/addon/mock/testdata/terraform-alibaba/template.yaml rename {pkg/addon => e2e/addon/mock}/testdata/terraform/metadata.yaml (100%) create mode 100644 e2e/addon/mock/testdata/terraform/template.yaml rename e2e/addon/{ => mock}/testdata/test-addon/metadata.yaml (100%) rename e2e/addon/{ => mock}/testdata/test-addon/template.yaml (100%) create mode 100644 e2e/addon/mock/utils/utils.go diff --git a/Makefile b/Makefile index 61611426a..c86a1f7ec 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,7 @@ e2e-setup-core: sh ./hack/e2e/modify_charts.sh helm upgrade --install --create-namespace --namespace vela-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set applicationRevisionLimit=5 --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --set multicluster.enabled=true --wait kubevela ./charts/vela-core kubectl wait --for=condition=Available deployment/kubevela-vela-core -n vela-system --timeout=180s + go run ./e2e/addon/mock & setup-runtime-e2e-cluster: helm upgrade --install --create-namespace --namespace vela-system --kubeconfig=$(RUNTIME_CLUSTER_CONFIG) --set image.pullPolicy=IfNotPresent --set image.repository=vela-runtime-rollout-test --set image.tag=$(GIT_COMMIT) --wait vela-rollout ./runtime/rollout/charts @@ -165,7 +166,9 @@ e2e-setup: sh ./hack/e2e/modify_charts.sh helm upgrade --install --create-namespace --namespace vela-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set applicationRevisionLimit=5 --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --wait kubevela ./charts/vela-core helm upgrade --install --create-namespace --namespace oam-runtime-system --set image.pullPolicy=IfNotPresent --set image.repository=vela-core-test --set dependCheckWait=10s --set image.tag=$(GIT_COMMIT) --wait oam-runtime ./charts/oam-runtime + go run ./e2e/addon/mock & bin/vela addon enable fluxcd + bin/vela addon enable terraform bin/vela addon enable terraform-alibaba ALICLOUD_ACCESS_KEY=xxx ALICLOUD_SECRET_KEY=yyy ALICLOUD_REGION=cn-beijing ginkgo version ginkgo -v -r e2e/setup @@ -183,6 +186,7 @@ e2e-api-test: ginkgo -v -r e2e/application e2e-apiserver-test: build-swagger + go run ./e2e/addon/mock & go test -v -coverpkg=./... -coverprofile=/tmp/e2e_apiserver_test.out ./test/e2e-apiserver-test @$(OK) tests pass diff --git a/e2e/addon/addon_test.go b/e2e/addon/addon_test.go index d1f8db1da..272db850c 100644 --- a/e2e/addon/addon_test.go +++ b/e2e/addon/addon_test.go @@ -18,23 +18,14 @@ package e2e import ( "context" - "encoding/xml" "fmt" - "net/http" - "os" - "path" - "regexp" "strings" "time" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/onsi/gomega/ghttp" - v1 "k8s.io/api/core/v1" - "sigs.k8s.io/yaml" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" "github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1" "github.com/oam-dev/kubevela/e2e" @@ -45,39 +36,6 @@ var _ = Describe("Addon Test", func() { args := common.Args{Schema: common.Scheme} k8sClient, err := args.GetClient() Expect(err).Should(BeNil()) - ctx := context.Background() - originCm := v1.ConfigMap{} - cm := v1.ConfigMap{} - - BeforeEach(func() { - server := ghttp.NewServer() - pathExp, err := regexp.Compile(".+") - Expect(err).Should(BeNil()) - server.RouteToHandler("GET", pathExp, ossHandler) - registryCmStr := strings.ReplaceAll(velaRegistry, "REGISTRY_ADDR", server.Addr()) - - Expect(yaml.Unmarshal([]byte(registryCmStr), &cm)) - - err = k8sClient.Get(ctx, types.NamespacedName{Name: cm.Name, Namespace: cm.Namespace}, &originCm) - if err != nil { - if apierrors.IsNotFound(err) { - Expect(k8sClient.Create(ctx, &cm)).Should(BeNil()) - } else { - Expect(err).Should(BeNil()) - } - } else { - cm.ResourceVersion = originCm.ResourceVersion - Expect(k8sClient.Update(ctx, &cm)).Should(BeNil()) - } - }) - - AfterEach(func() { - // after test we should write configmap back - latestCm := v1.ConfigMap{} - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cm.Name, Namespace: cm.Namespace}, &latestCm)) - originCm.ResourceVersion = latestCm.ResourceVersion - Expect(k8sClient.Update(ctx, &originCm)).Should(BeNil()) - }) Context("List addons", func() { It("List all addon", func() { @@ -153,69 +111,3 @@ var _ = Describe("Addon Test", func() { }) }) }) - -var velaRegistry = ` -apiVersion: v1 -data: - registries: '{ "KubeVela":{ "name": "KubeVela", "oss": { "end_point": "http://REGISTRY_ADDR", - "bucket": "" } } }' -kind: ConfigMap -metadata: - name: vela-addon-registry - namespace: vela-system -` - -// ListBucketResult describe a file list from OSS -type ListBucketResult struct { - Files []File `xml:"Contents"` - Count int `xml:"KeyCount"` -} - -// File is for oss xml parse -type File struct { - Name string `xml:"Key"` - Size int `xml:"Size"` -} - -var ossHandler http.HandlerFunc = func(rw http.ResponseWriter, req *http.Request) { - queryPath := strings.TrimPrefix(req.URL.Path, "/") - if strings.Contains(req.URL.RawQuery, "prefix") { - prefix := req.URL.Query().Get("prefix") - res := ListBucketResult{ - Files: []File{}, - Count: 0, - } - for _, p := range paths { - if strings.HasPrefix(p, prefix) { - res.Files = append(res.Files, File{Name: p, Size: 100}) - res.Count += 1 - } - } - data, err := xml.Marshal(res) - if err != nil { - rw.Write([]byte(err.Error())) - } - rw.Write(data) - } else { - found := false - for _, p := range paths { - if queryPath == p { - file, err := os.ReadFile(path.Join("testdata", queryPath)) - if err != nil { - rw.Write([]byte(err.Error())) - } - found = true - rw.Write(file) - break - } - } - if !found { - rw.Write([]byte("not found")) - } - } -} - -var paths = []string{ - "test-addon/metadata.yaml", - "test-addon/template.yaml", -} diff --git a/e2e/addon/mock/mock_server.go b/e2e/addon/mock/mock_server.go new file mode 100644 index 000000000..0bcc2a886 --- /dev/null +++ b/e2e/addon/mock/mock_server.go @@ -0,0 +1,112 @@ +/* +Copyright 2021 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "embed" + "encoding/xml" + "fmt" + "io/fs" + "log" + "net/http" + "path" + "strings" + + "github.com/oam-dev/kubevela/e2e/addon/mock/utils" + "github.com/oam-dev/kubevela/pkg/addon" +) + +var ( + //go:embed testdata + testData embed.FS + paths []struct { + path string + length int64 + } +) + +func main() { + err := utils.ApplyMockServerConfig() + if err != nil { + log.Fatal("Apply mock server config to ConfigMap fail") + } + http.HandleFunc("/", ossHandler) + err = http.ListenAndServe(fmt.Sprintf(":%d", utils.Port), nil) + if err != nil { + log.Fatal("ListenAndServe: ", err) + } +} + +var ossHandler http.HandlerFunc = func(rw http.ResponseWriter, req *http.Request) { + queryPath := strings.TrimPrefix(req.URL.Path, "/") + + if strings.Contains(req.URL.RawQuery, "prefix") { + prefix := req.URL.Query().Get("prefix") + res := addon.ListBucketResult{ + Files: []addon.File{}, + Count: 0, + } + for _, p := range paths { + if strings.HasPrefix(p.path, prefix) { + res.Files = append(res.Files, addon.File{Name: p.path, Size: int(p.length)}) + res.Count++ + } + } + data, err := xml.Marshal(res) + if err != nil { + _, _ = rw.Write([]byte(err.Error())) + } + _, _ = rw.Write(data) + } else { + found := false + for _, p := range paths { + if queryPath == p.path { + file, err := testData.ReadFile(path.Join("testdata", queryPath)) + if err != nil { + _, _ = rw.Write([]byte(err.Error())) + } + found = true + _, _ = rw.Write(file) + break + } + } + if !found { + _, _ = rw.Write([]byte("not found")) + } + } +} + +func init() { + _ = fs.WalkDir(testData, "testdata", func(path string, d fs.DirEntry, err error) error { + path = strings.TrimPrefix(path, "testdata/") + path = strings.TrimPrefix(path, "testdata") + + info, _ := d.Info() + size := info.Size() + if path == "" { + return nil + } + if size == 0 { + path += "/" + } + paths = append(paths, struct { + path string + length int64 + }{path: path, length: size}) + return nil + }) +} diff --git a/e2e/addon/mock/testdata/example/definitions/helm.yaml b/e2e/addon/mock/testdata/example/definitions/helm.yaml new file mode 100644 index 000000000..75150f08c --- /dev/null +++ b/e2e/addon/mock/testdata/example/definitions/helm.yaml @@ -0,0 +1,62 @@ +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition +metadata: + annotations: + definition.oam.dev/description: helm release is a group of K8s resources + from either git repository or helm repo + name: helm-example + namespace: vela-system +spec: + schematic: + cue: + template: "output: {\n\tapiVersion: \"source.toolkit.fluxcd.io/v1beta1\"\n\tmetadata: + {\n\t\tname: context.name\n\t}\n\tif parameter.repoType == \"git\" {\n\t\tkind: + \"GitRepository\"\n\t\tspec: {\n\t\t\turl: parameter.url\n\t\t\tif parameter.git.branch + != _|_ {\n\t\t\t\tref: branch: parameter.git.branch\n\t\t\t}\n\t\t\t_secret\n\t\t\t_sourceCommonArgs\n\t\t}\n\t}\n\tif + parameter.repoType == \"oss\" {\n\t\tkind: \"Bucket\"\n\t\tspec: {\n\t\t\tendpoint: + \ parameter.url\n\t\t\tbucketName: parameter.oss.bucketName\n\t\t\tprovider: + \ parameter.oss.provider\n\t\t\tif parameter.oss.region != _|_ {\n\t\t\t\tregion: + parameter.oss.region\n\t\t\t}\n\t\t\t_secret\n\t\t\t_sourceCommonArgs\n\t\t}\n\t}\n\tif + parameter.repoType == \"helm\" {\n\t\tkind: \"HelmRepository\"\n\t\tspec: + {\n\t\t\turl: parameter.url\n\t\t\t_secret\n\t\t\t_sourceCommonArgs\n\t\t}\n\t}\n}\n\noutputs: + release: {\n\tapiVersion: \"helm.toolkit.fluxcd.io/v2beta1\"\n\tkind: + \ \"HelmRelease\"\n\tmetadata: {\n\t\tname: context.name\n\t}\n\tspec: + {\n\t\tinterval: parameter.pullInterval\n\t\tchart: {\n\t\t\tspec: {\n\t\t\t\tchart: + \ parameter.chart\n\t\t\t\tversion: parameter.version\n\t\t\t\tsourceRef: + {\n\t\t\t\t\tif parameter.repoType == \"git\" {\n\t\t\t\t\t\tkind: \"GitRepository\"\n\t\t\t\t\t}\n\t\t\t\t\tif + parameter.repoType == \"helm\" {\n\t\t\t\t\t\tkind: \"HelmRepository\"\n\t\t\t\t\t}\n\t\t\t\t\tif + parameter.repoType == \"oss\" {\n\t\t\t\t\t\tkind: \"Bucket\"\n\t\t\t\t\t}\n\t\t\t\t\tname: + \ context.name\n\t\t\t\t\tnamespace: context.namespace\n\t\t\t\t}\n\t\t\t\tinterval: + parameter.pullInterval\n\t\t\t}\n\t\t}\n\t\tif parameter.targetNamespace + != _|_ {\n\t\t\ttargetNamespace: parameter.targetNamespace\n\t\t}\n\t\tif + parameter.releaseName != _|_ {\n\t\t\treleaseName: parameter.releaseName\n\t\t}\n\t\tif + parameter.values != _|_ {\n\t\t\tvalues: parameter.values\n\t\t}\n\t}\n}\n\n_secret: + {\n\tif parameter.secretRef != _|_ {\n\t\tsecretRef: {\n\t\t\tname: + parameter.secretRef\n\t\t}\n\t}\n}\n\n_sourceCommonArgs: {\n\tinterval: + parameter.pullInterval\n\tif parameter.timeout != _|_ {\n\t\ttimeout: + parameter.timeout\n\t}\n}\n\nparameter: {\n\trepoType: *\"helm\" | \"git\" + | \"oss\"\n\t// +usage=The interval at which to check for repository/bucket + and relese updates, default to 5m\n\tpullInterval: *\"5m\" | string\n\t// + +usage=The Git or Helm repository URL, OSS endpoint, accept HTTP/S or + SSH address as git url,\n\turl: string\n\t// +usage=The name of the + secret containing authentication credentials\n\tsecretRef?: string\n\t// + +usage=The timeout for operations like download index/clone repository, + optional\n\ttimeout?: string\n\n\tgit?: {\n\t\t// +usage=The Git reference + to checkout and monitor for changes, defaults to master branch\n\t\tbranch: + string\n\t}\n\toss?: {\n\t\t// +usage=The bucket's name, required if + repoType is oss\n\t\tbucketName: string\n\t\t// +usage=\"generic\" for + Minio, Amazon S3, Google Cloud Storage, Alibaba Cloud OSS, \"aws\" for + retrieve credentials from the EC2 service when credentials not specified, + default \"generic\"\n\t\tprovider: *\"generic\" | \"aws\"\n\t\t// +usage=The + bucket region, optional\n\t\tregion?: string\n\t}\n\n\t// +usage=1.The + relative path to helm chart for git/oss source. 2. chart name for helm + resource 3. relative path for chart package(e.g. ./charts/podinfo-1.2.3.tgz)\n\tchart: + string\n\t// +usage=Chart version\n\tversion: *\"*\" | string\n\t// + +usage=The namespace for helm chart, optional\n\ttargetNamespace?: string\n\t// + +usage=The release name\n\treleaseName?: string\n\t// +usage=Chart values\n\tvalues?: + #nestedmap\n}\n\n#nestedmap: {\n\t...\n}\n" + status: + healthPolicy: 'isHealth: len(context.outputs.release.status.conditions) + != 0 && context.outputs.release.status.conditions[0]["status"]=="True"' + workload: + type: autodetects.core.oam.dev diff --git a/e2e/addon/mock/testdata/example/metadata.yaml b/e2e/addon/mock/testdata/example/metadata.yaml new file mode 100644 index 000000000..e47ad7776 --- /dev/null +++ b/e2e/addon/mock/testdata/example/metadata.yaml @@ -0,0 +1,23 @@ +name: example +version: 1.0.0 +description: Extended workload to do continuous and progressive delivery +icon: https://raw.githubusercontent.com/fluxcd/flux/master/docs/_files/weave-flux.png +url: https://fluxcd.io + +tags: + - extended_workload + - gitops + - only_example + +deployTo: + control_plane: true + runtime_cluster: false + +dependencies: [] +#- name: addon_name + +# set invisible means this won't be list and will be enabled when depended on +# for example, terraform-alibaba depends on terraform which is invisible, +# when terraform-alibaba is enabled, terraform will be enabled automatically +# default: false +invisible: false diff --git a/e2e/addon/mock/testdata/example/resources/configmap.cue b/e2e/addon/mock/testdata/example/resources/configmap.cue new file mode 100644 index 000000000..3f52984c3 --- /dev/null +++ b/e2e/addon/mock/testdata/example/resources/configmap.cue @@ -0,0 +1,12 @@ +output: { + type: "raw" + properties: { + apiVersion: "v1" + kind: "ConfigMap" + metadata: { + name: "exampleinput" + namespace: "default" + } + data: input: parameter.example + } +} diff --git a/e2e/addon/mock/testdata/example/resources/parameter.cue b/e2e/addon/mock/testdata/example/resources/parameter.cue new file mode 100644 index 000000000..2b0222f39 --- /dev/null +++ b/e2e/addon/mock/testdata/example/resources/parameter.cue @@ -0,0 +1,3 @@ +parameter: { + example: string +} \ No newline at end of file diff --git a/e2e/addon/mock/testdata/example/resources/service/source-controller.yaml b/e2e/addon/mock/testdata/example/resources/service/source-controller.yaml new file mode 100644 index 000000000..999f4c4d8 --- /dev/null +++ b/e2e/addon/mock/testdata/example/resources/service/source-controller.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: source-controller + namespace: example-system +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http + selector: + app: source-controller + type: ClusterIP diff --git a/e2e/addon/mock/testdata/example/template.yaml b/e2e/addon/mock/testdata/example/template.yaml new file mode 100644 index 000000000..069cec1a2 --- /dev/null +++ b/e2e/addon/mock/testdata/example/template.yaml @@ -0,0 +1,22 @@ +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: example + namespace: vela-system +spec: + workflow: + steps: + - name: apply-ns + type: apply-component + properties: + component: ns-example-system + - name: apply-resources + type: apply-remaining + components: + - name: ns-example-system + type: raw + properties: + apiVersion: v1 + kind: Namespace + metadata: + name: example-system diff --git a/e2e/addon/mock/testdata/fluxcd/definitions/helm-release-def.yaml b/e2e/addon/mock/testdata/fluxcd/definitions/helm-release-def.yaml new file mode 100644 index 000000000..bd73c24ea --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/definitions/helm-release-def.yaml @@ -0,0 +1,182 @@ +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition +metadata: + name: helm + namespace: vela-system + annotations: + definition.oam.dev/description: "helm release is a group of K8s resources from either git repository or helm repo" +spec: + workload: + type: autodetects.core.oam.dev + schematic: + cue: + template: | + output: { + apiVersion: "source.toolkit.fluxcd.io/v1beta1" + metadata: { + name: context.name + } + if parameter.repoType == "git" { + kind: "GitRepository" + spec: { + url: parameter.url + if parameter.git.branch != _|_ { + ref: branch: parameter.git.branch + } + _secret + _sourceCommonArgs + } + } + if parameter.repoType == "oss" { + kind: "Bucket" + spec: { + endpoint: parameter.url + bucketName: parameter.oss.bucketName + provider: parameter.oss.provider + if parameter.oss.region != _|_ { + region: parameter.oss.region + } + _secret + _sourceCommonArgs + } + } + if parameter.repoType == "helm" { + kind: "HelmRepository" + spec: { + url: parameter.url + _secret + _sourceCommonArgs + } + } + } + + outputs: release: { + apiVersion: "helm.toolkit.fluxcd.io/v2beta1" + kind: "HelmRelease" + metadata: { + name: context.name + } + spec: { + timeout: parameter.installTimeout + interval: parameter.pullInterval + chart: { + spec: { + chart: parameter.chart + version: parameter.version + sourceRef: { + if parameter.repoType == "git" { + kind: "GitRepository" + } + if parameter.repoType == "helm" { + kind: "HelmRepository" + } + if parameter.repoType == "oss" { + kind: "Bucket" + } + name: context.name + namespace: context.namespace + } + interval: parameter.pullInterval + } + } + if parameter.targetNamespace != _|_ { + targetNamespace: parameter.targetNamespace + } + if parameter.releaseName != _|_ { + releaseName: parameter.releaseName + } + if parameter.values != _|_ { + values: parameter.values + } + } + } + + _secret: { + if parameter.secretRef != _|_ { + secretRef: { + name: parameter.secretRef + } + } + } + + _sourceCommonArgs: { + interval: parameter.pullInterval + if parameter.timeout != _|_ { + timeout: parameter.timeout + } + } + + parameter: { + repoType: *"helm" | "git" | "oss" + // +usage=The interval at which to check for repository/bucket and relese updates, default to 5m + pullInterval: *"5m" | string + // +usage=The Git or Helm repository URL, OSS endpoint, accept HTTP/S or SSH address as git url, + url: string + // +usage=The name of the secret containing authentication credentials + secretRef?: string + // +usage=The timeout for operations like download index/clone repository, optional + timeout?: string + // +usage=The timeout for operation `helm install`, optional + installTimeout: *"10m" | string + + git?: { + // +usage=The Git reference to checkout and monitor for changes, defaults to master branch + branch: string + } + oss?: { + // +usage=The bucket's name, required if repoType is oss + bucketName: string + // +usage="generic" for Minio, Amazon S3, Google Cloud Storage, Alibaba Cloud OSS, "aws" for retrieve credentials from the EC2 service when credentials not specified, default "generic" + provider: *"generic" | "aws" + // +usage=The bucket region, optional + region?: string + } + + // +usage=1.The relative path to helm chart for git/oss source. 2. chart name for helm resource 3. relative path for chart package(e.g. ./charts/podinfo-1.2.3.tgz) + chart: string + // +usage=Chart version + version: *"*" | string + // +usage=The namespace for helm chart, optional + targetNamespace?: string + // +usage=The release name + releaseName?: string + // +usage=Chart values + values?: #nestedmap + } + + #nestedmap: { + ... + } + status: + # helmRelease's `ready` condition must be the first one + healthPolicy: 'isHealth: len(context.outputs.release.status.conditions) != 0 && context.outputs.release.status.conditions[0]["status"]=="True"' + customStatus: |- + repoMessage: string + releaseMessage: string + if context.output.status == _|_ { + repoMessage: "Fetching repository" + releaseMessage: "Wating repository ready" + } + if context.output.status != _|_ { + repoStatus: context.output.status + if repoStatus.conditions[0]["type"] != "Ready" { + repoMessage: "Fetch repository fail" + } + if repoStatus.conditions[0]["type"] == "Ready" { + repoMessage: "Fetch repository successfully" + } + + if context.outputs.release.status == _|_ { + releaseMessage: "Creating helm release" + } + if context.outputs.release.status != _|_ { + if context.outputs.release.status.conditions[0]["message"] == "Release reconciliation succeeded" { + releaseMessage: "Create helm release successfully" + } + if context.outputs.release.status.conditions[0]["message"] != "Release reconciliation succeeded" { + releaseMessage: "Create helm release fail, message: " + context.outputs.release.status.conditions[0]["message"] + } + } + + } + message: repoMessage + ", " + releaseMessage diff --git a/e2e/addon/mock/testdata/fluxcd/definitions/json-patch.yaml b/e2e/addon/mock/testdata/fluxcd/definitions/json-patch.yaml new file mode 100644 index 000000000..ca99f94e6 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/definitions/json-patch.yaml @@ -0,0 +1,47 @@ +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "A list of JSON6902 patch to selected target" + name: kustomize-json-patch + namespace: vela-system +spec: + schematic: + cue: + template: | + patch: { + spec: { + patchesJson6902: parameter.patchesJson + } + } + + parameter: { + // +usage=A list of JSON6902 patch. + patchesJson: [...#jsonPatchItem] + } + + // +usage=Contains a JSON6902 patch + #jsonPatchItem: { + target: #selector + patch: [...{ + // +usage=operation to perform + op: string | "add" | "remove" | "replace" | "move" | "copy" | "test" + // +usage=operate path e.g. /foo/bar + path: string + // +usage=specify source path when op is copy/move + from?: string + // +usage=specify opraation value when op is test/add/replace + value?: string + }] + } + + // +usage=Selector specifies a set of resources + #selector: { + group?: string + version?: string + kind?: string + namespace?: string + name?: string + annotationSelector?: string + labelSelector?: string + } diff --git a/e2e/addon/mock/testdata/fluxcd/definitions/kustomize-patch.yaml b/e2e/addon/mock/testdata/fluxcd/definitions/kustomize-patch.yaml new file mode 100644 index 000000000..22450e352 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/definitions/kustomize-patch.yaml @@ -0,0 +1,39 @@ +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "A list of StrategicMerge or JSON6902 patch to selected target" + name: kustomize-patch + namespace: vela-system +spec: + schematic: + cue: + template: | + patch: { + spec: { + patches: parameter.patches + } + } + parameter: { + // +usage=a list of StrategicMerge or JSON6902 patch to selected target + patches: [...#patchItem] + } + + // +usage=Contains a strategicMerge or JSON6902 patch + #patchItem: { + // +usage=Inline patch string, in yaml style + patch: string + // +usage=Specify the target the patch should be applied to + target: #selector + } + + // +usage=Selector specifies a set of resources + #selector: { + group?: string + version?: string + kind?: string + namespace?: string + name?: string + annotationSelector?: string + labelSelector?: string + } diff --git a/e2e/addon/mock/testdata/fluxcd/definitions/kustomize.yaml b/e2e/addon/mock/testdata/fluxcd/definitions/kustomize.yaml new file mode 100644 index 000000000..c934f1e78 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/definitions/kustomize.yaml @@ -0,0 +1,228 @@ +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition +metadata: + name: kustomize + namespace: vela-system + annotations: + definition.oam.dev/description: "kustomize can fetching, building, updating and applying Kustomize manifests from git repo." +spec: + workload: + type: autodetects.core.oam.dev + schematic: + cue: + template: | + output: { + apiVersion: "kustomize.toolkit.fluxcd.io/v1beta1" + kind: "Kustomization" + metadata: { + name: context.name + namespace: context.namespace + } + spec: { + interval: parameter.pullInterval + sourceRef: { + if parameter.repoType == "git" { + kind: "GitRepository" + } + if parameter.repoType == "oss" { + kind: "Bucket" + } + name: context.name + namespace: context.namespace + } + path: parameter.path + prune: true + validation: "client" + } + } + + outputs: { + repo: { + apiVersion: "source.toolkit.fluxcd.io/v1beta1" + metadata: { + name: context.name + namespace: context.namespace + } + if parameter.repoType == "git" { + kind: "GitRepository" + spec: { + url: parameter.url + if parameter.git.branch != _|_ { + ref: branch: parameter.git.branch + } + if parameter.git.provider != _|_ { + if parameter.git.provider == "GitHub" { + gitImplementation: "go-git" + } + if parameter.git.provider == "AzureDevOps" { + gitImplementation: "libgit2" + } + } + _secret + _sourceCommonArgs + } + } + if parameter.repoType == "oss" { + kind: "Bucket" + spec: { + endpoint: parameter.url + bucketName: parameter.oss.bucketName + provider: parameter.oss.provider + if parameter.oss.region != _|_ { + region: parameter.oss.region + } + _secret + _sourceCommonArgs + } + } + } + + if parameter.imageRepository != _|_ { + imageRepo: { + apiVersion: "image.toolkit.fluxcd.io/v1beta1" + kind: "ImageRepository" + metadata: { + name: context.name + namespace: context.namespace + } + spec: { + image: parameter.imageRepository.image + interval: parameter.pullInterval + if parameter.imageRepository.secretRef != _|_ { + secretRef: name: parameter.imageRepository.secretRef + } + } + } + + imagePolicy: { + apiVersion: "image.toolkit.fluxcd.io/v1beta1" + kind: "ImagePolicy" + metadata: { + name: context.name + namespace: context.namespace + } + spec: { + imageRepositoryRef: name: context.name + policy: parameter.imageRepository.policy + if parameter.imageRepository.filterTags != _|_ { + filterTags: parameter.imageRepository.filterTags + } + } + } + + imageUpdate: { + apiVersion: "image.toolkit.fluxcd.io/v1beta1" + kind: "ImageUpdateAutomation" + metadata: { + name: context.name + namespace: context.namespace + } + spec: { + interval: parameter.pullInterval + sourceRef: { + kind: "GitRepository" + name: context.name + } + git: { + checkout: ref: branch: parameter.git.branch + commit: { + author: { + email: "kubevelabot@users.noreply.github.com" + name: "kubevelabot" + } + if parameter.imageRepository.commitMessage != _|_ { + messageTemplate: "Update image automatically.\n" + parameter.imageRepository.commitMessage + } + if parameter.imageRepository.commitMessage == _|_ { + messageTemplate: "Update image automatically." + } + } + push: branch: parameter.git.branch + } + update: { + path: parameter.path + strategy: "Setters" + } + } + } + } + } + + _secret: { + if parameter.secretRef != _|_ { + secretRef: { + name: parameter.secretRef + } + } + } + + _sourceCommonArgs: { + interval: parameter.pullInterval + if parameter.timeout != _|_ { + timeout: parameter.timeout + } + } + + parameter: { + repoType: *"git" | "oss" + // +usage=The image repository for automatically update image to git + imageRepository?: { + // +usage=The image url + image: string + // +usage=The name of the secret containing authentication credentials + secretRef?: string + // +usage=Policy gives the particulars of the policy to be followed in selecting the most recent image. + policy: { + // +usage=Alphabetical set of rules to use for alphabetical ordering of the tags. + alphabetical?: { + // +usage=Order specifies the sorting order of the tags. + // +usage=Given the letters of the alphabet as tags, ascending order would select Z, and descending order would select A. + order?: "asc" | "desc" + } + // +usage=Numerical set of rules to use for numerical ordering of the tags. + numerical?: { + // +usage=Order specifies the sorting order of the tags. + // +usage=Given the integer values from 0 to 9 as tags, ascending order would select 9, and descending order would select 0. + order: "asc" | "desc" + } + // +usage=SemVer gives a semantic version range to check against the tags available. + semver?: { + // +usage=Range gives a semver range for the image tag; the highest version within the range that's a tag yields the latest image. + range: string + } + } + // +usage=FilterTags enables filtering for only a subset of tags based on a set of rules. If no rules are provided, all the tags from the repository will be ordered and compared. + filterTags?: { + // +usage=Extract allows a capture group to be extracted from the specified regular expression pattern, useful before tag evaluation. + extract?: string + // +usage=Pattern specifies a regular expression pattern used to filter for image tags. + pattern?: string + } + // +usage=The image url + commitMessage?: string + } + // +usage=The interval at which to check for repository/bucket and release updates, default to 5m + pullInterval: *"5m" | string + // +usage=The Git or Helm repository URL, OSS endpoint, accept HTTP/S or SSH address as git url, + url: string + // +usage=The name of the secret containing authentication credentials + secretRef?: string + // +usage=The timeout for operations like download index/clone repository, optional + timeout?: string + git?: { + // +usage=The Git reference to checkout and monitor for changes, defaults to master branch + branch: string + // +usage=Determines which git client library to use. Defaults to GitHub, it will pick go-git. AzureDevOps will pick libgit2. + provider?: *"GitHub" | "AzureDevOps" + } + oss?: { + // +usage=The bucket's name, required if repoType is oss + bucketName: string + // +usage="generic" for Minio, Amazon S3, Google Cloud Storage, Alibaba Cloud OSS, "aws" for retrieve credentials from the EC2 service when credentials not specified, default "generic" + provider: *"generic" | "aws" + // +usage=The bucket region, optional + region?: string + } + //+usage=Path to the directory containing the kustomization.yaml file, or the set of plain YAMLs a kustomization.yaml should be generated for. + path: string + } \ No newline at end of file diff --git a/e2e/addon/mock/testdata/fluxcd/definitions/strategy-merge.yaml b/e2e/addon/mock/testdata/fluxcd/definitions/strategy-merge.yaml new file mode 100644 index 000000000..b33063e61 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/definitions/strategy-merge.yaml @@ -0,0 +1,25 @@ +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "A list of strategic merge to kustomize config" + name: kustomize-strategy-merge + namespace: vela-system +spec: + schematic: + cue: + template: | + patch: { + spec: { + patchesStrategicMerge: parameter.patchesStrategicMerge + } + } + + parameter: { + // +usage=a list of strategicmerge, defined as inline yaml objects. + patchesStrategicMerge: [...#nestedmap] + } + + #nestedmap: { + ... + } diff --git a/e2e/addon/mock/testdata/fluxcd/metadata.yaml b/e2e/addon/mock/testdata/fluxcd/metadata.yaml new file mode 100644 index 000000000..661df3a8d --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/metadata.yaml @@ -0,0 +1,18 @@ +name: fluxcd +version: 1.0.0 +description: Extended workload to do continuous and progressive delivery +icon: https://raw.githubusercontent.com/fluxcd/flux/master/docs/_files/weave-flux.png +url: https://fluxcd.io + +tags: +- extended_workload +- gitops + +deployTo: + control_plane: true + runtime_cluster: true + +needNamespace: + - flux-system + +invisible: false diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/bucket.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/bucket.yaml new file mode 100644 index 000000000..7cc2b2bba --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/bucket.yaml @@ -0,0 +1,220 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: buckets.source.toolkit.fluxcd.io +spec: + group: source.toolkit.fluxcd.io + names: + kind: Bucket + listKind: BucketList + plural: buckets + singular: bucket + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.url + name: URL + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: Bucket is the Schema for the buckets API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: BucketSpec defines the desired state of an S3 compatible + bucket + properties: + bucketName: + description: The bucket name. + type: string + endpoint: + description: The bucket endpoint address. + type: string + ignore: + description: Ignore overrides the set of excluded patterns in the + .sourceignore format (which is the same as .gitignore). If not provided, + a default will be used, consult the documentation for your version + to find out what those are. + type: string + insecure: + description: Insecure allows connecting to a non-TLS S3 HTTP endpoint. + type: boolean + interval: + description: The interval at which to check for bucket updates. + type: string + provider: + default: generic + description: The S3 compatible storage provider name, default ('generic'). + enum: + - generic + - aws + type: string + region: + description: The bucket region. + type: string + secretRef: + description: The name of the secret containing authentication credentials + for the Bucket. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean + timeout: + default: 20s + description: The timeout for download operations, defaults to 20s. + type: string + required: + - bucketName + - endpoint + - interval + type: object + status: + description: BucketStatus defines the observed state of a bucket + properties: + artifact: + description: Artifact represents the output of the last successful + Bucket sync. + properties: + checksum: + description: Checksum is the SHA1 checksum of the artifact. + type: string + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to + the last update of this artifact. + format: date-time + type: string + path: + description: Path is the relative file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable + in the origin source system. It can be a Git commit SHA, Git + tag, a Helm index timestamp, a Helm chart version, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object + conditions: + description: Conditions holds the conditions for the Bucket. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + observedGeneration: + description: ObservedGeneration is the last observed generation. + format: int64 + type: integer + url: + description: URL is the download link for the artifact output of the + last Bucket sync. + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/git-repo.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/git-repo.yaml new file mode 100644 index 000000000..388fba846 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/git-repo.yaml @@ -0,0 +1,321 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: gitrepositories.source.toolkit.fluxcd.io +spec: + group: source.toolkit.fluxcd.io + names: + kind: GitRepository + listKind: GitRepositoryList + plural: gitrepositories + shortNames: + - gitrepo + singular: gitrepository + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.url + name: URL + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: GitRepository is the Schema for the gitrepositories API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: GitRepositorySpec defines the desired state of a Git repository. + properties: + gitImplementation: + default: go-git + description: Determines which git client library to use. Defaults + to go-git, valid values are ('go-git', 'libgit2'). + enum: + - go-git + - libgit2 + type: string + ignore: + description: Ignore overrides the set of excluded patterns in the + .sourceignore format (which is the same as .gitignore). If not provided, + a default will be used, consult the documentation for your version + to find out what those are. + type: string + include: + description: Extra git repositories to map into the repository + items: + description: GitRepositoryInclude defines a source with a from and + to path. + properties: + fromPath: + description: The path to copy contents from, defaults to the + root directory. + type: string + repository: + description: Reference to a GitRepository to include. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + toPath: + description: The path to copy contents to, defaults to the name + of the source ref. + type: string + required: + - repository + type: object + type: array + interval: + description: The interval at which to check for repository updates. + type: string + recurseSubmodules: + description: When enabled, after the clone is created, initializes + all submodules within, using their default settings. This option + is available only when using the 'go-git' GitImplementation. + type: boolean + ref: + description: The Git reference to checkout and monitor for changes, + defaults to master branch. + properties: + branch: + default: master + description: The Git branch to checkout, defaults to master. + type: string + commit: + description: The Git commit SHA to checkout, if specified Tag + filters will be ignored. + type: string + semver: + description: The Git tag semver expression, takes precedence over + Tag. + type: string + tag: + description: The Git tag to checkout, takes precedence over Branch. + type: string + type: object + secretRef: + description: The secret name containing the Git credentials. For HTTPS + repositories the secret must contain username and password fields. + For SSH repositories the secret must contain identity, identity.pub + and known_hosts fields. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean + timeout: + default: 20s + description: The timeout for remote Git operations like cloning, defaults + to 20s. + type: string + url: + description: The repository URL, can be a HTTP/S or SSH address. + pattern: ^(http|https|ssh):// + type: string + verify: + description: Verify OpenPGP signature for the Git commit HEAD points + to. + properties: + mode: + description: Mode describes what git object should be verified, + currently ('head'). + enum: + - head + type: string + secretRef: + description: The secret name containing the public keys of all + trusted Git authors. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + required: + - mode + type: object + required: + - interval + - url + type: object + status: + description: GitRepositoryStatus defines the observed state of a Git repository. + properties: + artifact: + description: Artifact represents the output of the last successful + repository sync. + properties: + checksum: + description: Checksum is the SHA1 checksum of the artifact. + type: string + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to + the last update of this artifact. + format: date-time + type: string + path: + description: Path is the relative file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable + in the origin source system. It can be a Git commit SHA, Git + tag, a Helm index timestamp, a Helm chart version, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object + conditions: + description: Conditions holds the conditions for the GitRepository. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + includedArtifacts: + description: IncludedArtifacts represents the included artifacts from + the last successful repository sync. + items: + description: Artifact represents the output of a source synchronisation. + properties: + checksum: + description: Checksum is the SHA1 checksum of the artifact. + type: string + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to + the last update of this artifact. + format: date-time + type: string + path: + description: Path is the relative file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable + in the origin source system. It can be a Git commit SHA, Git + tag, a Helm index timestamp, a Helm chart version, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object + type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + observedGeneration: + description: ObservedGeneration is the last observed generation. + format: int64 + type: integer + url: + description: URL is the download link for the artifact output of the + last repository sync. + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} \ No newline at end of file diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-chart.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-chart.yaml new file mode 100644 index 000000000..ed501c2e1 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-chart.yaml @@ -0,0 +1,235 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: helmcharts.source.toolkit.fluxcd.io +spec: + group: source.toolkit.fluxcd.io + names: + kind: HelmChart + listKind: HelmChartList + plural: helmcharts + shortNames: + - hc + singular: helmchart + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.chart + name: Chart + type: string + - jsonPath: .spec.version + name: Version + type: string + - jsonPath: .spec.sourceRef.kind + name: Source Kind + type: string + - jsonPath: .spec.sourceRef.name + name: Source Name + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: HelmChart is the Schema for the helmcharts API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: HelmChartSpec defines the desired state of a Helm chart. + properties: + chart: + description: The name or path the Helm chart is available at in the + SourceRef. + type: string + interval: + description: The interval at which to check the Source for updates. + type: string + sourceRef: + description: The reference to the Source the chart is available at. + properties: + apiVersion: + description: APIVersion of the referent. + type: string + kind: + description: Kind of the referent, valid values are ('HelmRepository', + 'GitRepository', 'Bucket'). + enum: + - HelmRepository + - GitRepository + - Bucket + type: string + name: + description: Name of the referent. + type: string + required: + - kind + - name + type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean + valuesFile: + description: Alternative values file to use as the default chart values, + expected to be a relative path in the SourceRef. Deprecated in favor + of ValuesFiles, for backwards compatibility the file defined here + is merged before the ValuesFiles items. Ignored when omitted. + type: string + valuesFiles: + description: Alternative list of values files to use as the chart + values (values.yaml is not included by default), expected to be + a relative path in the SourceRef. Values files are merged in the + order of this list with the last file overriding the first. Ignored + when omitted. + items: + type: string + type: array + version: + default: '*' + description: The chart version semver expression, ignored for charts + from GitRepository and Bucket sources. Defaults to latest when omitted. + type: string + required: + - chart + - interval + - sourceRef + type: object + status: + description: HelmChartStatus defines the observed state of the HelmChart. + properties: + artifact: + description: Artifact represents the output of the last successful + chart sync. + properties: + checksum: + description: Checksum is the SHA1 checksum of the artifact. + type: string + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to + the last update of this artifact. + format: date-time + type: string + path: + description: Path is the relative file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable + in the origin source system. It can be a Git commit SHA, Git + tag, a Helm index timestamp, a Helm chart version, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object + conditions: + description: Conditions holds the conditions for the HelmChart. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + observedGeneration: + description: ObservedGeneration is the last observed generation. + format: int64 + type: integer + url: + description: URL is the download link for the last chart pulled. + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-release.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-release.yaml new file mode 100644 index 000000000..194c9d75b --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-release.yaml @@ -0,0 +1,738 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: helmreleases.helm.toolkit.fluxcd.io +spec: + group: helm.toolkit.fluxcd.io + names: + kind: HelmRelease + listKind: HelmReleaseList + plural: helmreleases + shortNames: + - hr + singular: helmrelease + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v2beta1 + schema: + openAPIV3Schema: + description: HelmRelease is the Schema for the helmreleases API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: HelmReleaseSpec defines the desired state of a Helm release. + properties: + chart: + description: Chart defines the template of the v1beta1.HelmChart that + should be created for this HelmRelease. + properties: + spec: + description: Spec holds the template for the v1beta1.HelmChartSpec + for this HelmRelease. + properties: + chart: + description: The name or path the Helm chart is available + at in the SourceRef. + type: string + interval: + description: Interval at which to check the v1beta1.Source + for updates. Defaults to 'HelmReleaseSpec.Interval'. + type: string + sourceRef: + description: The name and namespace of the v1beta1.Source + the chart is available at. + properties: + apiVersion: + description: APIVersion of the referent. + type: string + kind: + description: Kind of the referent. + enum: + - HelmRepository + - GitRepository + - Bucket + type: string + name: + description: Name of the referent. + maxLength: 253 + minLength: 1 + type: string + namespace: + description: Namespace of the referent. + maxLength: 63 + minLength: 1 + type: string + required: + - name + type: object + valuesFile: + description: Alternative values file to use as the default + chart values, expected to be a relative path in the SourceRef. + Deprecated in favor of ValuesFiles, for backwards compatibility + the file defined here is merged before the ValuesFiles items. + Ignored when omitted. + type: string + valuesFiles: + description: Alternative list of values files to use as the + chart values (values.yaml is not included by default), expected + to be a relative path in the SourceRef. Values files are + merged in the order of this list with the last file overriding + the first. Ignored when omitted. + items: + type: string + type: array + version: + default: '*' + description: Version semver expression, ignored for charts + from v1beta1.GitRepository and v1beta1.Bucket sources. Defaults + to latest when omitted. + type: string + required: + - chart + - sourceRef + type: object + required: + - spec + type: object + dependsOn: + description: DependsOn may contain a dependency.CrossNamespaceDependencyReference + slice with references to HelmRelease resources that must be ready + before this HelmRelease can be reconciled. + items: + description: CrossNamespaceDependencyReference holds the reference + to a dependency. + properties: + name: + description: Name holds the name reference of a dependency. + type: string + namespace: + description: Namespace holds the namespace reference of a dependency. + type: string + required: + - name + type: object + type: array + install: + description: Install holds the configuration for Helm install actions + for this HelmRelease. + properties: + crds: + description: "CRDs upgrade CRDs from the Helm Chart's crds directory + according to the CRD upgrade policy provided here. Valid values + are `Skip`, `Create` or `CreateReplace`. Default is `Create` + and if omitted CRDs are installed but not updated. \n Skip: + do neither install nor replace (update) any CRDs. \n Create: + new CRDs are created, existing CRDs are neither updated nor + deleted. \n CreateReplace: new CRDs are created, existing CRDs + are updated (replaced) but not deleted. \n By default, CRDs + are applied (installed) during Helm install action. With this + option users can opt-in to CRD replace existing CRDs on Helm + install actions, which is not (yet) natively supported by Helm. + https://helm.sh/docs/chart_best_practices/custom_resource_definitions." + enum: + - Skip + - Create + - CreateReplace + type: string + createNamespace: + description: CreateNamespace tells the Helm install action to + create the HelmReleaseSpec.TargetNamespace if it does not exist + yet. On uninstall, the namespace will not be garbage collected. + type: boolean + disableHooks: + description: DisableHooks prevents hooks from running during the + Helm install action. + type: boolean + disableOpenAPIValidation: + description: DisableOpenAPIValidation prevents the Helm install + action from validating rendered templates against the Kubernetes + OpenAPI Schema. + type: boolean + disableWait: + description: DisableWait disables the waiting for resources to + be ready after a Helm install has been performed. + type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm install has been performed. + type: boolean + remediation: + description: Remediation holds the remediation configuration for + when the Helm install action for the HelmRelease fails. The + default is to not perform any action. + properties: + ignoreTestFailures: + description: IgnoreTestFailures tells the controller to skip + remediation when the Helm tests are run after an install + action but fail. Defaults to 'Test.IgnoreFailures'. + type: boolean + remediateLastFailure: + description: RemediateLastFailure tells the controller to + remediate the last failure, when no retries remain. Defaults + to 'false'. + type: boolean + retries: + description: Retries is the number of retries that should + be attempted on failures before bailing. Remediation, using + an uninstall, is performed between each attempt. Defaults + to '0', a negative integer equals to unlimited retries. + type: integer + type: object + replace: + description: Replace tells the Helm install action to re-use the + 'ReleaseName', but only if that name is a deleted release which + remains in the history. + type: boolean + skipCRDs: + description: "SkipCRDs tells the Helm install action to not install + any CRDs. By default, CRDs are installed if not already present. + \n Deprecated use CRD policy (`crds`) attribute with value `Skip` + instead." + type: boolean + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation (like Jobs for hooks) during the performance of a + Helm install action. Defaults to 'HelmReleaseSpec.Timeout'. + type: string + type: object + interval: + description: Interval at which to reconcile the Helm release. + type: string + kubeConfig: + description: KubeConfig for reconciling the HelmRelease on a remote + cluster. When specified, KubeConfig takes precedence over ServiceAccountName. + properties: + secretRef: + description: SecretRef holds the name to a secret that contains + a 'value' key with the kubeconfig file as the value. It must + be in the same namespace as the HelmRelease. It is recommended + that the kubeconfig is self-contained, and the secret is regularly + updated if credentials such as a cloud-access-token expire. + Cloud specific `cmd-path` auth helpers will not function without + adding binaries and credentials to the Pod that is responsible + for reconciling the HelmRelease. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + type: object + maxHistory: + description: MaxHistory is the number of revisions saved by Helm for + this HelmRelease. Use '0' for an unlimited number of revisions; + defaults to '10'. + type: integer + postRenderers: + description: PostRenderers holds an array of Helm PostRenderers, which + will be applied in order of their definition. + items: + description: PostRenderer contains a Helm PostRenderer specification. + properties: + kustomize: + description: Kustomization to apply as PostRenderer. + properties: + images: + description: Images is a list of (image name, new name, + new tag or digest) for changing image names, tags or digests. + This can also be achieved with a patch, but this operator + is simpler to specify. + items: + description: Image contains an image name, a new name, + a new tag or digest, which will replace the original + name and tag. + properties: + digest: + description: Digest is the value used to replace the + original image tag. If digest is present NewTag + value is ignored. + type: string + name: + description: Name is a tag-less image name. + type: string + newName: + description: NewName is the value used to replace + the original name. + type: string + newTag: + description: NewTag is the value used to replace the + original tag. + type: string + required: + - name + type: object + type: array + patchesJson6902: + description: JSON 6902 patches, defined as inline YAML objects. + items: + description: JSON6902Patch contains a JSON6902 patch and + the target the patch should be applied to. + properties: + patch: + description: Patch contains the JSON6902 patch document + with an array of operation objects. + items: + description: JSON6902 is a JSON6902 operation object. + https://tools.ietf.org/html/rfc6902#section-4 + properties: + from: + type: string + op: + enum: + - test + - remove + - add + - replace + - move + - copy + type: string + path: + type: string + value: + x-kubernetes-preserve-unknown-fields: true + required: + - op + - path + type: object + type: array + target: + description: Target points to the resources that the + patch document should be applied to. + properties: + annotationSelector: + description: AnnotationSelector is a string that + follows the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource annotations. + type: string + group: + description: Group is the API group to select + resources from. Together with Version and Kind + it is capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + kind: + description: Kind of the API Group to select resources + from. Together with Group and Version it is + capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + labelSelector: + description: LabelSelector is a string that follows + the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource labels. + type: string + name: + description: Name to match resources with. + type: string + namespace: + description: Namespace to select resources from. + type: string + version: + description: Version of the API Group to select + resources from. Together with Group and Kind + it is capable of unambiguously identifying and/or + selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + type: object + required: + - patch + - target + type: object + type: array + patchesStrategicMerge: + description: Strategic merge patches, defined as inline + YAML objects. + items: + x-kubernetes-preserve-unknown-fields: true + type: array + type: object + type: object + type: array + releaseName: + description: ReleaseName used for the Helm release. Defaults to a + composition of '[TargetNamespace-]Name'. + maxLength: 53 + minLength: 1 + type: string + rollback: + description: Rollback holds the configuration for Helm rollback actions + for this HelmRelease. + properties: + cleanupOnFail: + description: CleanupOnFail allows deletion of new resources created + during the Helm rollback action when it fails. + type: boolean + disableHooks: + description: DisableHooks prevents hooks from running during the + Helm rollback action. + type: boolean + disableWait: + description: DisableWait disables the waiting for resources to + be ready after a Helm rollback has been performed. + type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm rollback has been performed. + type: boolean + force: + description: Force forces resource updates through a replacement + strategy. + type: boolean + recreate: + description: Recreate performs pod restarts for the resource if + applicable. + type: boolean + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation (like Jobs for hooks) during the performance of a + Helm rollback action. Defaults to 'HelmReleaseSpec.Timeout'. + type: string + type: object + serviceAccountName: + description: The name of the Kubernetes service account to impersonate + when reconciling this HelmRelease. + type: string + storageNamespace: + description: StorageNamespace used for the Helm storage. Defaults + to the namespace of the HelmRelease. + maxLength: 63 + minLength: 1 + type: string + suspend: + description: Suspend tells the controller to suspend reconciliation + for this HelmRelease, it does not apply to already started reconciliations. + Defaults to false. + type: boolean + targetNamespace: + description: TargetNamespace to target when performing operations + for the HelmRelease. Defaults to the namespace of the HelmRelease. + maxLength: 63 + minLength: 1 + type: string + test: + description: Test holds the configuration for Helm test actions for + this HelmRelease. + properties: + enable: + description: Enable enables Helm test actions for this HelmRelease + after an Helm install or upgrade action has been performed. + type: boolean + ignoreFailures: + description: IgnoreFailures tells the controller to skip remediation + when the Helm tests are run but fail. Can be overwritten for + tests run after install or upgrade actions in 'Install.IgnoreTestFailures' + and 'Upgrade.IgnoreTestFailures'. + type: boolean + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation during the performance of a Helm test action. Defaults + to 'HelmReleaseSpec.Timeout'. + type: string + type: object + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation (like Jobs for hooks) during the performance of a Helm + action. Defaults to '5m0s'. + type: string + uninstall: + description: Uninstall holds the configuration for Helm uninstall + actions for this HelmRelease. + properties: + disableHooks: + description: DisableHooks prevents hooks from running during the + Helm rollback action. + type: boolean + keepHistory: + description: KeepHistory tells Helm to remove all associated resources + and mark the release as deleted, but retain the release history. + type: boolean + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation (like Jobs for hooks) during the performance of a + Helm uninstall action. Defaults to 'HelmReleaseSpec.Timeout'. + type: string + type: object + upgrade: + description: Upgrade holds the configuration for Helm upgrade actions + for this HelmRelease. + properties: + cleanupOnFail: + description: CleanupOnFail allows deletion of new resources created + during the Helm upgrade action when it fails. + type: boolean + crds: + description: "CRDs upgrade CRDs from the Helm Chart's crds directory + according to the CRD upgrade policy provided here. Valid values + are `Skip`, `Create` or `CreateReplace`. Default is `Skip` and + if omitted CRDs are neither installed nor upgraded. \n Skip: + do neither install nor replace (update) any CRDs. \n Create: + new CRDs are created, existing CRDs are neither updated nor + deleted. \n CreateReplace: new CRDs are created, existing CRDs + are updated (replaced) but not deleted. \n By default, CRDs + are not applied during Helm upgrade action. With this option + users can opt-in to CRD upgrade, which is not (yet) natively + supported by Helm. https://helm.sh/docs/chart_best_practices/custom_resource_definitions." + enum: + - Skip + - Create + - CreateReplace + type: string + disableHooks: + description: DisableHooks prevents hooks from running during the + Helm upgrade action. + type: boolean + disableOpenAPIValidation: + description: DisableOpenAPIValidation prevents the Helm upgrade + action from validating rendered templates against the Kubernetes + OpenAPI Schema. + type: boolean + disableWait: + description: DisableWait disables the waiting for resources to + be ready after a Helm upgrade has been performed. + type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm upgrade has been performed. + type: boolean + force: + description: Force forces resource updates through a replacement + strategy. + type: boolean + preserveValues: + description: PreserveValues will make Helm reuse the last release's + values and merge in overrides from 'Values'. Setting this flag + makes the HelmRelease non-declarative. + type: boolean + remediation: + description: Remediation holds the remediation configuration for + when the Helm upgrade action for the HelmRelease fails. The + default is to not perform any action. + properties: + ignoreTestFailures: + description: IgnoreTestFailures tells the controller to skip + remediation when the Helm tests are run after an upgrade + action but fail. Defaults to 'Test.IgnoreFailures'. + type: boolean + remediateLastFailure: + description: RemediateLastFailure tells the controller to + remediate the last failure, when no retries remain. Defaults + to 'false' unless 'Retries' is greater than 0. + type: boolean + retries: + description: Retries is the number of retries that should + be attempted on failures before bailing. Remediation, using + 'Strategy', is performed between each attempt. Defaults + to '0', a negative integer equals to unlimited retries. + type: integer + strategy: + description: Strategy to use for failure remediation. Defaults + to 'rollback'. + enum: + - rollback + - uninstall + type: string + type: object + timeout: + description: Timeout is the time to wait for any individual Kubernetes + operation (like Jobs for hooks) during the performance of a + Helm upgrade action. Defaults to 'HelmReleaseSpec.Timeout'. + type: string + type: object + values: + description: Values holds the values for this Helm release. + x-kubernetes-preserve-unknown-fields: true + valuesFrom: + description: ValuesFrom holds references to resources containing Helm + values for this HelmRelease, and information about how they should + be merged. + items: + description: ValuesReference contains a reference to a resource + containing Helm values, and optionally the key they can be found + at. + properties: + kind: + description: Kind of the values referent, valid values are ('Secret', + 'ConfigMap'). + enum: + - Secret + - ConfigMap + type: string + name: + description: Name of the values referent. Should reside in the + same namespace as the referring resource. + maxLength: 253 + minLength: 1 + type: string + optional: + description: Optional marks this ValuesReference as optional. + When set, a not found error for the values reference is ignored, + but any ValuesKey, TargetPath or transient error will still + result in a reconciliation failure. + type: boolean + targetPath: + description: TargetPath is the YAML dot notation path the value + should be merged at. When set, the ValuesKey is expected to + be a single flat value. Defaults to 'None', which results + in the values getting merged at the root. + type: string + valuesKey: + description: ValuesKey is the data key where the values.yaml + or a specific value can be found at. Defaults to 'values.yaml'. + type: string + required: + - kind + - name + type: object + type: array + required: + - chart + - interval + type: object + status: + description: HelmReleaseStatus defines the observed state of a HelmRelease. + properties: + conditions: + description: Conditions holds the conditions for the HelmRelease. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + failures: + description: Failures is the reconciliation failure count against + the latest desired state. It is reset after a successful reconciliation. + format: int64 + type: integer + helmChart: + description: HelmChart is the namespaced name of the HelmChart resource + created by the controller for the HelmRelease. + type: string + installFailures: + description: InstallFailures is the install failure count against + the latest desired state. It is reset after a successful reconciliation. + format: int64 + type: integer + lastAppliedRevision: + description: LastAppliedRevision is the revision of the last successfully + applied source. + type: string + lastAttemptedRevision: + description: LastAttemptedRevision is the revision of the last reconciliation + attempt. + type: string + lastAttemptedValuesChecksum: + description: LastAttemptedValuesChecksum is the SHA1 checksum of the + values of the last reconciliation attempt. + type: string + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + lastReleaseRevision: + description: LastReleaseRevision is the revision of the last successful + Helm release. + type: integer + observedGeneration: + description: ObservedGeneration is the last observed generation. + format: int64 + type: integer + upgradeFailures: + description: UpgradeFailures is the upgrade failure count against + the latest desired state. It is reset after a successful reconciliation. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-repo.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-repo.yaml new file mode 100644 index 000000000..165561439 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/helm-repo.yaml @@ -0,0 +1,208 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: helmrepositories.source.toolkit.fluxcd.io +spec: + group: source.toolkit.fluxcd.io + names: + kind: HelmRepository + listKind: HelmRepositoryList + plural: helmrepositories + shortNames: + - helmrepo + singular: helmrepository + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.url + name: URL + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: HelmRepository is the Schema for the helmrepositories API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: HelmRepositorySpec defines the reference to a Helm repository. + properties: + interval: + description: The interval at which to check the upstream for updates. + type: string + passCredentials: + description: PassCredentials allows the credentials from the SecretRef + to be passed on to a host that does not match the host as defined + in URL. This may be required if the host of the advertised chart + URLs in the index differ from the defined URL. Enabling this should + be done with caution, as it can potentially result in credentials + getting stolen in a MITM-attack. + type: boolean + secretRef: + description: The name of the secret containing authentication credentials + for the Helm repository. For HTTP/S basic auth the secret must contain + username and password fields. For TLS the secret must contain a + certFile and keyFile, and/or caCert fields. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + suspend: + description: This flag tells the controller to suspend the reconciliation + of this source. + type: boolean + timeout: + default: 60s + description: The timeout of index downloading, defaults to 60s. + type: string + url: + description: The Helm repository URL, a valid URL contains at least + a protocol and host. + type: string + required: + - interval + - url + type: object + status: + description: HelmRepositoryStatus defines the observed state of the HelmRepository. + properties: + artifact: + description: Artifact represents the output of the last successful + repository sync. + properties: + checksum: + description: Checksum is the SHA1 checksum of the artifact. + type: string + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to + the last update of this artifact. + format: date-time + type: string + path: + description: Path is the relative file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable + in the origin source system. It can be a Git commit SHA, Git + tag, a Helm index timestamp, a Helm chart version, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object + conditions: + description: Conditions holds the conditions for the HelmRepository. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + observedGeneration: + description: ObservedGeneration is the last observed generation. + format: int64 + type: integer + url: + description: URL is the download link for the last index fetched. + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/e2e/addon/mock/testdata/fluxcd/resources/crds/kustomize.yaml b/e2e/addon/mock/testdata/fluxcd/resources/crds/kustomize.yaml new file mode 100644 index 000000000..a3464e359 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/crds/kustomize.yaml @@ -0,0 +1,539 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.5.0 + labels: + app.kubernetes.io/instance: flux-system + name: kustomizations.kustomize.toolkit.fluxcd.io +spec: + group: kustomize.toolkit.fluxcd.io + names: + kind: Kustomization + listKind: KustomizationList + plural: kustomizations + shortNames: + - ks + singular: kustomization + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: Kustomization is the Schema for the kustomizations API. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: KustomizationSpec defines the desired state of a kustomization. + properties: + decryption: + description: Decrypt Kubernetes secrets before applying them on the + cluster. + properties: + provider: + description: Provider is the name of the decryption engine. + enum: + - sops + type: string + secretRef: + description: The secret name containing the private OpenPGP keys + used for decryption. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + required: + - provider + type: object + dependsOn: + description: DependsOn may contain a dependency.CrossNamespaceDependencyReference + slice with references to Kustomization resources that must be ready + before this Kustomization can be reconciled. + items: + description: CrossNamespaceDependencyReference holds the reference + to a dependency. + properties: + name: + description: Name holds the name reference of a dependency. + type: string + namespace: + description: Namespace holds the namespace reference of a dependency. + type: string + required: + - name + type: object + type: array + force: + default: false + description: Force instructs the controller to recreate resources + when patching fails due to an immutable field change. + type: boolean + healthChecks: + description: A list of resources to be included in the health assessment. + items: + description: NamespacedObjectKindReference contains enough information + to let you locate the typed referenced object in any namespace + properties: + apiVersion: + description: API version of the referent, if not specified the + Kubernetes preferred version will be used + type: string + kind: + description: Kind of the referent + type: string + name: + description: Name of the referent + type: string + namespace: + description: Namespace of the referent, when not specified it + acts as LocalObjectReference + type: string + required: + - kind + - name + type: object + type: array + images: + description: Images is a list of (image name, new name, new tag or + digest) for changing image names, tags or digests. This can also + be achieved with a patch, but this operator is simpler to specify. + items: + description: Image contains an image name, a new name, a new tag + or digest, which will replace the original name and tag. + properties: + digest: + description: Digest is the value used to replace the original + image tag. If digest is present NewTag value is ignored. + type: string + name: + description: Name is a tag-less image name. + type: string + newName: + description: NewName is the value used to replace the original + name. + type: string + newTag: + description: NewTag is the value used to replace the original + tag. + type: string + required: + - name + type: object + type: array + interval: + description: The interval at which to reconcile the Kustomization. + type: string + kubeConfig: + description: The KubeConfig for reconciling the Kustomization on a + remote cluster. When specified, KubeConfig takes precedence over + ServiceAccountName. + properties: + secretRef: + description: SecretRef holds the name to a secret that contains + a 'value' key with the kubeconfig file as the value. It must + be in the same namespace as the Kustomization. It is recommended + that the kubeconfig is self-contained, and the secret is regularly + updated if credentials such as a cloud-access-token expire. + Cloud specific `cmd-path` auth helpers will not function without + adding binaries and credentials to the Pod that is responsible + for reconciling the Kustomization. + properties: + name: + description: Name of the referent + type: string + required: + - name + type: object + type: object + patches: + description: Strategic merge and JSON patches, defined as inline YAML + objects, capable of targeting objects based on kind, label and annotation + selectors. + items: + description: Patch contains either a StrategicMerge or a JSON6902 + patch, either a file or inline, and the target the patch should + be applied to. + properties: + patch: + description: Patch contains the JSON6902 patch document with + an array of operation objects. + type: string + target: + description: Target points to the resources that the patch document + should be applied to. + properties: + annotationSelector: + description: AnnotationSelector is a string that follows + the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource annotations. + type: string + group: + description: Group is the API group to select resources + from. Together with Version and Kind it is capable of + unambiguously identifying and/or selecting resources. + https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + kind: + description: Kind of the API Group to select resources from. + Together with Group and Version it is capable of unambiguously + identifying and/or selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + labelSelector: + description: LabelSelector is a string that follows the + label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource labels. + type: string + name: + description: Name to match resources with. + type: string + namespace: + description: Namespace to select resources from. + type: string + version: + description: Version of the API Group to select resources + from. Together with Group and Kind it is capable of unambiguously + identifying and/or selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + type: object + type: object + type: array + patchesJson6902: + description: JSON 6902 patches, defined as inline YAML objects. + items: + description: JSON6902Patch contains a JSON6902 patch and the target + the patch should be applied to. + properties: + patch: + description: Patch contains the JSON6902 patch document with + an array of operation objects. + items: + description: JSON6902 is a JSON6902 operation object. https://tools.ietf.org/html/rfc6902#section-4 + properties: + from: + type: string + op: + enum: + - test + - remove + - add + - replace + - move + - copy + type: string + path: + type: string + value: + x-kubernetes-preserve-unknown-fields: true + required: + - op + - path + type: object + type: array + target: + description: Target points to the resources that the patch document + should be applied to. + properties: + annotationSelector: + description: AnnotationSelector is a string that follows + the label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource annotations. + type: string + group: + description: Group is the API group to select resources + from. Together with Version and Kind it is capable of + unambiguously identifying and/or selecting resources. + https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + kind: + description: Kind of the API Group to select resources from. + Together with Group and Version it is capable of unambiguously + identifying and/or selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + labelSelector: + description: LabelSelector is a string that follows the + label selection expression https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api + It matches with the resource labels. + type: string + name: + description: Name to match resources with. + type: string + namespace: + description: Namespace to select resources from. + type: string + version: + description: Version of the API Group to select resources + from. Together with Group and Kind it is capable of unambiguously + identifying and/or selecting resources. https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md + type: string + type: object + required: + - patch + - target + type: object + type: array + patchesStrategicMerge: + description: Strategic merge patches, defined as inline YAML objects. + items: + x-kubernetes-preserve-unknown-fields: true + type: array + path: + description: Path to the directory containing the kustomization.yaml + file, or the set of plain YAMLs a kustomization.yaml should be generated + for. Defaults to 'None', which translates to the root path of the + SourceRef. + type: string + postBuild: + description: PostBuild describes which actions to perform on the YAML + manifest generated by building the kustomize overlay. + properties: + substitute: + additionalProperties: + type: string + description: Substitute holds a map of key/value pairs. The variables + defined in your YAML manifests that match any of the keys defined + in the map will be substituted with the set value. Includes + support for bash string replacement functions e.g. ${var:=default}, + ${var:position} and ${var/substring/replacement}. + type: object + substituteFrom: + description: SubstituteFrom holds references to ConfigMaps and + Secrets containing the variables and their values to be substituted + in the YAML manifests. The ConfigMap and the Secret data keys + represent the var names and they must match the vars declared + in the manifests for the substitution to happen. + items: + description: SubstituteReference contains a reference to a resource + containing the variables name and value. + properties: + kind: + description: Kind of the values referent, valid values are + ('Secret', 'ConfigMap'). + enum: + - Secret + - ConfigMap + type: string + name: + description: Name of the values referent. Should reside + in the same namespace as the referring resource. + maxLength: 253 + minLength: 1 + type: string + required: + - kind + - name + type: object + type: array + type: object + prune: + description: Prune enables garbage collection. + type: boolean + retryInterval: + description: The interval at which to retry a previously failed reconciliation. + When not specified, the controller uses the KustomizationSpec.Interval + value to retry failures. + type: string + serviceAccountName: + description: The name of the Kubernetes service account to impersonate + when reconciling this Kustomization. + type: string + sourceRef: + description: Reference of the source where the kustomization file + is. + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: Kind of the referent + enum: + - GitRepository + - Bucket + type: string + name: + description: Name of the referent + type: string + namespace: + description: Namespace of the referent, defaults to the Kustomization + namespace + type: string + required: + - kind + - name + type: object + suspend: + description: This flag tells the controller to suspend subsequent + kustomize executions, it does not apply to already started executions. + Defaults to false. + type: boolean + targetNamespace: + description: TargetNamespace sets or overrides the namespace in the + kustomization.yaml file. + maxLength: 63 + minLength: 1 + type: string + timeout: + description: Timeout for validation, apply and health checking operations. + Defaults to 'Interval' duration. + type: string + validation: + description: Validate the Kubernetes objects before applying them + on the cluster. The validation strategy can be 'client' (local dry-run), + 'server' (APIServer dry-run) or 'none'. When 'Force' is 'true', + validation will fallback to 'client' if set to 'server' because + server-side validation is not supported in this scenario. + enum: + - none + - client + - server + type: string + required: + - interval + - prune + - sourceRef + type: object + status: + description: KustomizationStatus defines the observed state of a kustomization. + properties: + conditions: + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: + \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + \ // +patchStrategy=merge // +listType=map // +listMapKey=type + \ Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + lastAppliedRevision: + description: The last successfully applied revision. The revision + format for Git sources is /. + type: string + lastAttemptedRevision: + description: LastAttemptedRevision is the revision of the last reconciliation + attempt. + type: string + lastHandledReconcileAt: + description: LastHandledReconcileAt holds the value of the most recent + reconcile request value, so a change can be detected. + type: string + observedGeneration: + description: ObservedGeneration is the last reconciled generation. + format: int64 + type: integer + snapshot: + description: The last successfully applied revision metadata. + properties: + checksum: + description: The manifests sha1 checksum. + type: string + entries: + description: A list of Kubernetes kinds grouped by namespace. + items: + description: Snapshot holds the metadata of namespaced Kubernetes + objects + properties: + kinds: + additionalProperties: + type: string + description: The list of Kubernetes kinds. + type: object + namespace: + description: The namespace of this entry. + type: string + required: + - kinds + type: object + type: array + required: + - checksum + - entries + type: object + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/e2e/addon/mock/testdata/fluxcd/resources/deployment/helm-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/deployment/helm-controller.yaml new file mode 100644 index 000000000..95bceb005 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/deployment/helm-controller.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: helm-controller + namespace: flux-system +spec: + replicas: 1 + selector: + matchLabels: + app: helm-controller + template: + metadata: + annotations: + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: helm-controller + spec: + containers: + - args: + - --events-addr=http://notification-controller/ + - --watch-all-namespaces + - --log-level=info + - --log-encoding=json + - --enable-leader-election + env: + - name: RUNTIME_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: fluxcd/helm-controller:v0.11.1 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: /healthz + port: healthz + name: manager + ports: + - containerPort: 8080 + name: http-prom + - containerPort: 9440 + name: healthz + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: healthz + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 100m + memory: 64Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + volumeMounts: + - mountPath: /tmp + name: temp + serviceAccountName: sa-helm-controller + terminationGracePeriodSeconds: 600 + volumes: + - emptyDir: { } + name: temp diff --git a/e2e/addon/mock/testdata/fluxcd/resources/deployment/kustomize-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/deployment/kustomize-controller.yaml new file mode 100644 index 000000000..b84e14323 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/deployment/kustomize-controller.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: kustomize-controller + namespace: flux-system +spec: + replicas: 1 + selector: + matchLabels: + app: kustomize-controller + template: + metadata: + annotations: + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: kustomize-controller + spec: + containers: + - args: + - --events-addr=http://notification-controller/ + - --watch-all-namespaces + - --log-level=info + - --log-encoding=json + - --enable-leader-election + env: + - name: RUNTIME_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: fluxcd/kustomize-controller:v0.13.1 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: /healthz + port: healthz + name: manager + ports: + - containerPort: 8080 + name: http-prom + - containerPort: 9440 + name: healthz + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: healthz + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 100m + memory: 64Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + volumeMounts: + - mountPath: /tmp + name: temp + securityContext: + fsGroup: 1337 + serviceAccountName: sa-kustomize-controller + terminationGracePeriodSeconds: 60 + volumes: + - emptyDir: { } + name: temp diff --git a/e2e/addon/mock/testdata/fluxcd/resources/deployment/source-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/deployment/source-controller.yaml new file mode 100644 index 000000000..290fd053f --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/deployment/source-controller.yaml @@ -0,0 +1,79 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: flux-source-controller + namespace: flux-system +spec: + replicas: 1 + selector: + matchLabels: + app: source-controller + strategy: + type: Recreate + template: + metadata: + annotations: + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: source-controller + spec: + containers: + - args: + - --events-addr=http://notification-controller/ + - --watch-all-namespaces + - --log-level=info + - --log-encoding=json + - --enable-leader-election + - --storage-path=/data + - --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.cluster.local. + env: + - name: RUNTIME_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: fluxcd/source-controller:v0.15.3 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: /healthz + port: healthz + name: manager + ports: + - containerPort: 9090 + name: http + - containerPort: 8080 + name: http-prom + - containerPort: 9440 + name: healthz + readinessProbe: + httpGet: + path: / + port: http + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 50m + memory: 64Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + volumeMounts: + - mountPath: /data + name: data + - mountPath: /tmp + name: tmp + securityContext: + fsGroup: 1337 + serviceAccountName: sa-source-controller + terminationGracePeriodSeconds: 10 + volumes: + - emptyDir: { } + name: data + - emptyDir: { } + name: tmp diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-cluster-admin.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-cluster-admin.yaml new file mode 100644 index 000000000..c5ee55d16 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-cluster-admin.yaml @@ -0,0 +1,17 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: cluster-reconciler +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: sa-kustomize-controller + namespace: flux-system + - kind: ServiceAccount + name: sa-helm-controller + namespace: flux-system diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-crd-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-crd-controller.yaml new file mode 100644 index 000000000..4066915f4 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/binding-crd-controller.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: crd-controller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cr-crd-controller +subjects: + - kind: ServiceAccount + name: sa-kustomize-controller + namespace: flux-system + - kind: ServiceAccount + name: sa-helm-controller + namespace: flux-system + - kind: ServiceAccount + name: sa-source-controller + namespace: flux-system + - kind: ServiceAccount + name: sa-notification-controller + namespace: flux-system \ No newline at end of file diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/crd-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/crd-controller.yaml new file mode 100644 index 000000000..0b41639ee --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/crd-controller.yaml @@ -0,0 +1,71 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: cr-crd-controller +rules: + - apiGroups: + - source.toolkit.fluxcd.io + resources: + - '*' + verbs: + - '*' + - apiGroups: + - kustomize.toolkit.fluxcd.io + resources: + - '*' + verbs: + - '*' + - apiGroups: + - helm.toolkit.fluxcd.io + resources: + - '*' + verbs: + - '*' + - apiGroups: + - image.toolkit.fluxcd.io + resources: + - '*' + verbs: + - '*' + - apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch + - apiGroups: + - "" + resources: + - configmaps + - configmaps/status + verbs: + - get + - list + - watch + - create + - update + - patch + - delete + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete \ No newline at end of file diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-helm-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-helm-controller.yaml new file mode 100644 index 000000000..04d53c56b --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-helm-controller.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: sa-helm-controller + namespace: flux-system diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-kustomize-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-kustomize-controller.yaml new file mode 100644 index 000000000..b4a25fb02 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-kustomize-controller.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: sa-kustomize-controller + namespace: flux-system diff --git a/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-source-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-source-controller.yaml new file mode 100644 index 000000000..e78dda49f --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/rbac/rbac-source-controller.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/instance: flux-system + name: sa-source-controller + namespace: flux-system diff --git a/e2e/addon/mock/testdata/fluxcd/resources/service/svc-source-controller.yaml b/e2e/addon/mock/testdata/fluxcd/resources/service/svc-source-controller.yaml new file mode 100644 index 000000000..790ed69d6 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/service/svc-source-controller.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: source-controller + namespace: flux-system +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http + selector: + app: source-controller + type: ClusterIP diff --git a/e2e/addon/mock/testdata/fluxcd/resources/service/webhook-receiver.yaml b/e2e/addon/mock/testdata/fluxcd/resources/service/webhook-receiver.yaml new file mode 100644 index 000000000..7988ced1f --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/resources/service/webhook-receiver.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/instance: flux-system + control-plane: controller + name: webhook-receiver + namespace: flux-system +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http-webhook + selector: + app: notification-controller + type: ClusterIP diff --git a/e2e/addon/mock/testdata/fluxcd/template.yaml b/e2e/addon/mock/testdata/fluxcd/template.yaml new file mode 100644 index 000000000..fcc116626 --- /dev/null +++ b/e2e/addon/mock/testdata/fluxcd/template.yaml @@ -0,0 +1,6 @@ +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: fluxcd + namespace: vela-system +spec: diff --git a/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-ack.yaml b/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-ack.yaml new file mode 100644 index 000000000..7458a93ca --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-ack.yaml @@ -0,0 +1,19 @@ +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition +metadata: + name: alibaba-ack + namespace: vela-system + annotations: + definition.oam.dev/description: Terraform configuration for Alibaba Cloud ACK cluster + labels: + type: terraform +spec: + workload: + definition: + apiVersion: terraform.core.oam.dev/v1beta1 + kind: Configuration + schematic: + terraform: + configuration: https://github.com/kubevela-contrib/terraform-modules.git + type: remote + path: alibaba/cs/dedicated-kubernetes diff --git a/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-oss.yaml b/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-oss.yaml new file mode 100644 index 000000000..afcebc0aa --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/definitions/terraform-alibaba-oss.yaml @@ -0,0 +1,42 @@ +apiVersion: core.oam.dev/v1alpha2 +kind: ComponentDefinition +metadata: + name: alibaba-oss + namespace: vela-system + annotations: + definition.oam.dev/description: Terraform configuration for Alibaba Cloud OSS object + # identifier of this cloud resource + cloud-resource/identifier: BUCKET_NAME + # the console url of this cloud resource + cloud-resource/console-url: "https://oss.console.aliyun.com/bucket/oss-{REGION}/{BUCKET_NAME}/overview" + # the outputs which are sensitive. Separate them by a comma if there are more than one + labels: + type: terraform +spec: + workload: + definition: + apiVersion: terraform.core.oam.dev/v1beta1 + kind: Configuration + schematic: + terraform: + configuration: | + resource "alicloud_oss_bucket" "bucket-acl" { + bucket = var.bucket + acl = var.acl + } + output "BUCKET_NAME" { + value = "${alicloud_oss_bucket.bucket-acl.bucket}" + } + output "BUCKET_ENDPOINT" { + value = "${alicloud_oss_bucket.bucket-acl.bucket}.${alicloud_oss_bucket.bucket-acl.extranet_endpoint}" + } + variable "bucket" { + description = "OSS bucket name" + default = "vela-website" + type = string + } + variable "acl" { + description = "OSS bucket ACL, supported 'private', 'public-read', 'public-read-write'" + default = "private" + type = string + } \ No newline at end of file diff --git a/pkg/addon/testdata/terraform-alibaba/metadata.yaml b/e2e/addon/mock/testdata/terraform-alibaba/metadata.yaml similarity index 100% rename from pkg/addon/testdata/terraform-alibaba/metadata.yaml rename to e2e/addon/mock/testdata/terraform-alibaba/metadata.yaml diff --git a/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-account-creds.cue b/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-account-creds.cue new file mode 100644 index 000000000..c0e56fc01 --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-account-creds.cue @@ -0,0 +1,18 @@ +import "strings" + +output: { + type: "raw" + properties: { + apiVersion: "v1" + kind: "Secret" + metadata: { + name: "alibaba-account-creds" + namespace: "vela-system" + } + type: "Opaque" + stringData: credentials: strings.Join([creds1, creds2], "\n") + } +} + +creds1: "accessKeyID: " + parameter.ALICLOUD_ACCESS_KEY +creds2: "accessKeySecret: " + parameter.ALICLOUD_SECRET_KEY diff --git a/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-provider.cue b/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-provider.cue new file mode 100644 index 000000000..c59a28c16 --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/resources/alibaba-provider.cue @@ -0,0 +1,23 @@ +output: { + type: "raw" + properties: { + apiVersion: "terraform.core.oam.dev/v1beta1" + kind: "Provider" + metadata: { + name: "default" + namespace: "default" + } + spec: { + provider: "alibaba" + region: parameter.ALICLOUD_REGION + credentials: { + source: "Secret" + secretRef: { + namespace: "vela-system" + name: "alibaba-account-creds" + key: "credentials" + } + } + } + } +} diff --git a/e2e/addon/mock/testdata/terraform-alibaba/resources/parameter.cue b/e2e/addon/mock/testdata/terraform-alibaba/resources/parameter.cue new file mode 100644 index 000000000..2249b3d02 --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/resources/parameter.cue @@ -0,0 +1,5 @@ +parameter: { + ALICLOUD_ACCESS_KEY: *"" | string + ALICLOUD_SECRET_KEY: *"" | string + ALICLOUD_REGION: *"" | string +} diff --git a/e2e/addon/mock/testdata/terraform-alibaba/template.yaml b/e2e/addon/mock/testdata/terraform-alibaba/template.yaml new file mode 100644 index 000000000..933d7d6b9 --- /dev/null +++ b/e2e/addon/mock/testdata/terraform-alibaba/template.yaml @@ -0,0 +1,5 @@ +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: terraform-alibaba + namespace: vela-system diff --git a/pkg/addon/testdata/terraform/metadata.yaml b/e2e/addon/mock/testdata/terraform/metadata.yaml similarity index 100% rename from pkg/addon/testdata/terraform/metadata.yaml rename to e2e/addon/mock/testdata/terraform/metadata.yaml diff --git a/e2e/addon/mock/testdata/terraform/template.yaml b/e2e/addon/mock/testdata/terraform/template.yaml new file mode 100644 index 000000000..8ebfdc171 --- /dev/null +++ b/e2e/addon/mock/testdata/terraform/template.yaml @@ -0,0 +1,30 @@ +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: terraform + namespace: vela-system +spec: + workflow: + steps: + - name: apply-ns + type: apply-component + properties: + component: ns-terraform-system + - name: apply-resources + type: apply-remaining + components: + - name: ns-terraform-system + type: raw + properties: + apiVersion: v1 + kind: Namespace + metadata: + name: terraform-system + - name: terraform-controller + type: helm + properties: + repoType: helm + url: https://charts.kubevela.net/addons + chart: terraform-controller + version: 0.2.11 + diff --git a/e2e/addon/testdata/test-addon/metadata.yaml b/e2e/addon/mock/testdata/test-addon/metadata.yaml similarity index 100% rename from e2e/addon/testdata/test-addon/metadata.yaml rename to e2e/addon/mock/testdata/test-addon/metadata.yaml diff --git a/e2e/addon/testdata/test-addon/template.yaml b/e2e/addon/mock/testdata/test-addon/template.yaml similarity index 100% rename from e2e/addon/testdata/test-addon/template.yaml rename to e2e/addon/mock/testdata/test-addon/template.yaml diff --git a/e2e/addon/mock/utils/utils.go b/e2e/addon/mock/utils/utils.go new file mode 100644 index 000000000..8c6c6312f --- /dev/null +++ b/e2e/addon/mock/utils/utils.go @@ -0,0 +1,74 @@ +/* +Copyright 2021 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package utils + +import ( + "context" + "fmt" + "strings" + + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/yaml" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + + "github.com/oam-dev/kubevela/pkg/utils/common" +) + +var ( + // Port is mock server's exposed port + Port = 9098 + velaRegistry = ` +apiVersion: v1 +data: + registries: '{ "KubeVela":{ "name": "KubeVela", "oss": { "end_point": "http://REGISTRY_ADDR", + "bucket": "" } } }' +kind: ConfigMap +metadata: + name: vela-addon-registry + namespace: vela-system +` +) + +// ApplyMockServerConfig config mock server as addon registry +func ApplyMockServerConfig() error { + args := common.Args{Schema: common.Scheme} + k8sClient, err := args.GetClient() + if err != nil { + return err + } + ctx := context.Background() + originCm := v1.ConfigMap{} + cm := v1.ConfigMap{} + + registryCmStr := strings.ReplaceAll(velaRegistry, "REGISTRY_ADDR", fmt.Sprintf("127.0.0.1:%d", Port)) + + err = yaml.Unmarshal([]byte(registryCmStr), &cm) + if err != nil { + return err + } + + err = k8sClient.Get(ctx, types.NamespacedName{Name: cm.Name, Namespace: cm.Namespace}, &originCm) + if err != nil && apierrors.IsNotFound(err) { + err = k8sClient.Create(ctx, &cm) + } else { + cm.ResourceVersion = originCm.ResourceVersion + err = k8sClient.Update(ctx, &cm) + } + return err +}