Compare commits

..

15 Commits

Author SHA1 Message Date
Zheng Xi Zhou
8de36ff295 Backport: pass on properties of Terraform typed application to Configuration (#2872)
Pass on properties like writeConnectionSecretRef, Region and providerRef
to Configuration.

Backport #2847

Signed-off-by: Zheng Xi Zhou <zzxwill@gmail.com>
2021-12-03 13:08:54 +08:00
github-actions[bot]
56dfd74ba2 Fix: mark test chart image in a fixed tag to avoid changed by release action (#2874)
Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
(cherry picked from commit d3d3d4dff2)

Co-authored-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
2021-12-03 13:06:15 +08:00
Zheng Xi Zhou
c4c00637bd Fix: backport Terraform releated PR (#2829)
- Fix: upgrade terraform controller to v0.2.10 #2827
- Fix: support naming a terraform provider #2794

Signed-off-by: zzxwill <zzxwill@gmail.com>
2021-11-30 18:47:06 +08:00
github-actions[bot]
493d8bdc5d Fix: sync status of Terraform typed components to application (#2845)
Synchronized the status of an Terraform typed components to .status.
services of the application

Signed-off-by: zzxwill <zzxwill@gmail.com>
(cherry picked from commit 1a13735d7b)

Co-authored-by: zzxwill <zzxwill@gmail.com>
2021-11-30 17:52:57 +08:00
github-actions[bot]
e636d7c48c [Backport release-1.1] Fix: health check appRev label bug (#2822)
* Fix: healthscope failed since appRevision is not set && rollout controller amend appRevision to workload since compRev does not have this one

(cherry picked from commit dd67fa976e)

* Fix: test

(cherry picked from commit 97cf2d1bfd)

Co-authored-by: Yin Da <yd219913@alibaba-inc.com>
2021-11-27 13:07:14 +08:00
github-actions[bot]
1fafe5f05e Fix: don't invoke docker command if not exist (#2814)
Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
(cherry picked from commit b5418f99d6)

Co-authored-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
2021-11-26 15:10:51 +08:00
Zheng Xi Zhou
ed574179d4 Fix: clean Terraform legacy files (#2776)
Cleaned terraform addon releated files
2021-11-23 13:22:26 +08:00
Zheng Xi Zhou
378ab1b81f Fix: install Terraform and apply the support for a provider in a jump (#2774)
- Fix issue: addon name should not include forward-slash "/" cloud-resource   fix #2588
- Install terraform and the provider in one jump. Instead of installing `terraform`
and `terraform-xxx` in two steps
- Terraform ComponenetDefinition won't be applied at once even though not all of them are needed
2021-11-23 10:59:52 +08:00
Zheng Xi Zhou
d16ae2a6f7 Fix: allow external cloud resources to be kept when Application is deleted (#2750)
Provide an option for users whether to keep provisioned cloud resources when Terraform-typed Application is deleted.

Fix #2697
2021-11-22 19:12:42 +08:00
github-actions[bot]
de5f140b08 [Backport release-1.1] Feat: support user defined image registry (#2765)
* Feat: support user defined image registry

(cherry picked from commit afbc661e91)

* Feat: add test app image repo into values

(cherry picked from commit 31da329e77)

Co-authored-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
2021-11-22 10:57:34 +08:00
qiaozp
93faf41ac4 Fix: Align -n command argument (backport #2719) (#2753)
* Fix: Align -n command argument (#2719)

* add namespace flag

fix

fix test

fix tests

* try test

* try test

* fix tests

(cherry picked from commit b38aa1cdf0)

* revert

* fix

* fix test
2021-11-20 12:28:52 +08:00
github-actions[bot]
1d7ace119d Chore(deps): Bump github.com/containerd/containerd from 1.4.11 to 1.4.12 (#2745)
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.4.11 to 1.4.12.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.4.11...v1.4.12)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit 13ed9be6a9)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-19 11:13:57 +08:00
github-actions[bot]
44bdf033ad [Backport release-1.1] Fix: observability installation (#2735)
* fix observability installation

(cherry picked from commit 32646ea3b6)

* fix nil pointer

(cherry picked from commit 29564fe264)

* fix nil pointer

(cherry picked from commit 716d869dc5)

* remove asset, build in trait

(cherry picked from commit acbeeb16e1)

Co-authored-by: qiaozp <chivalry.pp@gmail.com>
2021-11-18 16:09:35 +08:00
github-actions[bot]
69008da5e8 fix istio (#2736)
(cherry picked from commit 4521a66d19)

Co-authored-by: qiaozp <chivalry.pp@gmail.com>
2021-11-18 14:16:13 +08:00
github-actions[bot]
514ef7ff03 Fix: fix workflowstep depends-on-app (#2725)
(cherry picked from commit b161c247d9)

Co-authored-by: yangsoon <songyang.song@alibaba-inc.com>
2021-11-16 22:50:49 +08:00
130 changed files with 3842 additions and 1176 deletions

View File

@@ -155,7 +155,7 @@ e2e-setup:
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
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
@@ -204,10 +204,12 @@ e2e-cleanup:
rm -rf ~/.vela
image-cleanup:
ifneq (, $(shell which docker))
# Delete Docker image
ifneq ($(shell docker images -q $(VELA_CORE_TEST_IMAGE)),)
docker rmi -f $(VELA_CORE_TEST_IMAGE)
endif
endif
end-e2e-core:
sh ./hack/e2e/end_e2e_core.sh
@@ -257,7 +259,7 @@ core-uninstall: manifests
kubectl delete -f charts/vela-core/crds/
# Generate manifests e.g. CRD, RBAC etc.
manifests: installcue kustomize
manifests: installcue kustomize addon
go generate $(foreach t,pkg apis,./$(t)/...)
# TODO(yangsoon): kustomize will merge all CRD into a whole file, it may not work if we want patch more than one CRD in this way
$(KUSTOMIZE) build config/crd -o config/crd/base/core.oam.dev_applications.yaml
@@ -265,7 +267,6 @@ manifests: installcue kustomize
go run ./hack/crd/dispatch/dispatch.go config/crd/base charts/vela-core/crds charts/oam-runtime/crds runtime/ charts/vela-minimal/crds
rm -f config/crd/base/*
./vela-templates/gen_definitions.sh
go run ./vela-templates/gen_addons.go
GOLANGCILINT_VERSION ?= v1.38.0
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
@@ -349,3 +350,7 @@ check-license-header:
def-install:
./hack/utils/installdefinition.sh
# generate addons to auto-gen and charts
addon:
go run ./vela-templates/gen_addons.go

View File

@@ -19,13 +19,11 @@ package common
import (
"encoding/json"
"github.com/oam-dev/terraform-controller/api/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
types "github.com/oam-dev/terraform-controller/api/types/crossplane-runtime"
"github.com/oam-dev/kubevela/apis/core.oam.dev/condition"
"github.com/oam-dev/kubevela/apis/standard.oam.dev/v1alpha1"
)
@@ -117,8 +115,7 @@ type Terraform struct {
// Path is the sub-directory of remote git repository. It's valid when remote is set
Path string `json:"path,omitempty"`
// ProviderReference specifies the reference to Provider
ProviderReference *types.Reference `json:"providerRef,omitempty"`
v1beta1.BaseConfigurationSpec `json:",inline"`
}
// A WorkloadTypeDescriptor refer to a Workload Type

View File

@@ -21,7 +21,6 @@ limitations under the License.
package common
import (
crossplane_runtime "github.com/oam-dev/terraform-controller/api/types/crossplane-runtime"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
@@ -559,11 +558,7 @@ func (in *SubStepsStatus) DeepCopy() *SubStepsStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Terraform) DeepCopyInto(out *Terraform) {
*out = *in
if in.ProviderReference != nil {
in, out := &in.ProviderReference, &out.ProviderReference
*out = new(crossplane_runtime.Reference)
**out = **in
}
in.BaseConfigurationSpec.DeepCopyInto(&out.BaseConfigurationSpec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Terraform.

View File

@@ -188,6 +188,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -201,11 +206,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -215,6 +224,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -472,6 +497,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -485,11 +515,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -499,6 +533,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -193,6 +193,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -206,11 +211,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -220,6 +229,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -458,6 +483,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -471,11 +501,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -485,6 +519,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: create
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- create

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: patch
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- patch

View File

@@ -126,7 +126,7 @@ spec:
{{ end }}
- "--system-definition-namespace={{ .Values.systemDefinitionNamespace }}"
- "--oam-spec-ver={{ .Values.OAMSpecVer }}"
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ quote .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@@ -1,7 +1,7 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "oam-runtime.fullname" . }}-test-connection"
name: {{ include "oam-runtime.fullname" . }}-test-connection
labels:
{{- include "oam-runtime.labels" . | nindent 4 }}
annotations:
@@ -9,7 +9,7 @@ metadata:
spec:
containers:
- name: wget
image: busybox
image: {{ .Values.imageRegistry }}{{ .Values.test.app.repository }}:{{ .Values.test.app.tag }}
command: ['wget']
args: ['{{ include "oam-runtime.fullname" . }}:{{ .Values.healthCheck.port }}']
restartPolicy: Never

View File

@@ -7,6 +7,8 @@ replicaCount: 1
applyOnceOnly: "off"
disableCaps: "all"
imageRegistry: ""
image:
repository: oamdev/vela-core
tag: latest
@@ -98,4 +100,9 @@ concurrentReconciles: 4
dependCheckWait: 30s
# OAMSpecVer is the oam spec version controller want to setup
OAMSpecVer: "v0.2"
OAMSpecVer: "v0.2"
test:
app:
repository: oamdev/busybox
tag: v1

View File

@@ -1232,6 +1232,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1245,11 +1251,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1259,6 +1270,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1639,6 +1667,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1652,11 +1686,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1666,6 +1705,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1944,6 +2000,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1957,11 +2019,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1971,6 +2038,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3372,6 +3456,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3385,11 +3475,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3399,6 +3494,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3672,6 +3784,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3685,11 +3803,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3699,6 +3822,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4061,6 +4201,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4074,11 +4220,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4088,6 +4239,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4329,6 +4497,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4342,11 +4516,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4356,6 +4535,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4617,6 +4813,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4630,11 +4832,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4644,6 +4851,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -179,6 +179,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -192,11 +197,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -206,6 +215,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -467,6 +492,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -480,11 +510,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -494,6 +528,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -222,6 +222,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -235,11 +241,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -249,6 +260,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -510,6 +538,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -523,11 +557,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -537,6 +576,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -791,6 +847,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -804,11 +866,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -818,6 +885,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1053,6 +1137,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -1066,11 +1156,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1080,6 +1175,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -151,6 +151,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -164,11 +169,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -178,6 +187,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -188,6 +188,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -201,11 +206,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -215,6 +224,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -472,6 +497,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -485,11 +515,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -499,6 +533,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -148,6 +148,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -161,11 +166,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -175,6 +184,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -193,6 +193,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -206,11 +211,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -220,6 +229,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -458,6 +483,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -471,11 +501,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -485,6 +519,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -8,7 +8,7 @@ data:
addons.oam.dev/description: istio Controller is a Kubernetes Controller for manage
traffic.
name: istio
namespace: istio-system
namespace: vela-system
spec:
components:
- name: ns-istio-system

View File

@@ -10,106 +10,13 @@ data:
namespace: vela-system
spec:
components:
- name: ns-observability
properties:
apiVersion: v1
kind: Namespace
metadata:
name: observability
type: raw
- name: import-grafana-dashboard-traitdef
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Import dashboards to Grafana
name: import-grafana-dashboard
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"ImportDashboard\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace: parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\turls: parameter.urls\n\t}\n}\nparameter:
{\n\tgrafanaServiceName: string\n\tgrafanaServiceNamespace: *\"default\"
| string\n\tcredentialSecret: string\n\tcredentialSecretNamespace:
*\"default\" | string\n\turls: [...string]\n}\n"
type: raw
- name: pure-ingress-traitdef
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Enable public web traffic for the component
without creating a Service.
name: pure-ingress
namespace: vela-system
spec:
schematic:
cue:
template: "\noutputs: ingress: {\n\tapiVersion: \"networking.k8s.io/v1beta1\"\n\tkind:
\ \"Ingress\"\n\tmetadata:\n\t\tname: context.name\n\tspec: {\n\t\trules:
[{\n\t\t\thost: parameter.domain\n\t\t\thttp: {\n\t\t\t\tpaths: [\n\t\t\t\t\tfor
k, v in parameter.http {\n\t\t\t\t\t\tpath: k\n\t\t\t\t\t\tbackend:
{\n\t\t\t\t\t\t\tserviceName: context.name\n\t\t\t\t\t\t\tservicePort:
v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n\nparameter:
{\n\t// +usage=Specify the domain you want to expose\n\tdomain: string\n\n\t//
+usage=Specify the mapping relationship between the http path and the
workload port\n\thttp: [string]: int\n}\n"
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
healthPolicy: |
isHealth: len(context.outputs.ingress.status.loadBalancer.ingress) > 0
type: raw
- name: register-grafana-datasource-traitdef
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: register-grafana-datasource
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"DatasourceRegistration\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace: parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\tdatasource: {\n\t\t\tname:
\ parameter.name\n\t\t\ttype: parameter.type\n\t\t\taccess:
\ parameter.access\n\t\t\tservice: parameter.service\n\t\t\tnamespace:
parameter.namespace\n\t\t}\n\t}\n}\n\nparameter: {\n\tgrafanaServiceName:
\ string\n\tgrafanaServiceNamespace: *\"default\" | string\n\tcredentialSecret:
\ string\n\tcredentialSecretNamespace: string\n\tname: string\n\ttype:
\ string\n\taccess: *\"proxy\"
| string\n\tservice: string\n\tnamespace: *\"default\"
| string\n}\n"
type: raw
- name: grafana-registration
properties:
chart: ./chart
git:
branch: master
repoType: git
targetNamespace: observability
targetNamespace: vela-system
url: https://github.com/oam-dev/grafana-registration
values:
replicaCount: 1
@@ -119,7 +26,7 @@ data:
chart: grafana
releaseName: grafana
repoType: helm
targetNamespace: observability
targetNamespace: vela-system
url: https://charts.kubevela.net/addons
version: 6.14.1
traits:
@@ -130,9 +37,9 @@ data:
type: pure-ingress
- properties:
credentialSecret: grafana
credentialSecretNamespace: observability
credentialSecretNamespace: vela-system
grafanaServiceName: grafana
grafanaServiceNamespace: observability
grafanaServiceNamespace: vela-system
urls:
- https://charts.kubevela.net/addons/dashboards/kubevela_core_logging.json
- https://charts.kubevela.net/addons/dashboards/kubevela_core_monitoring.json
@@ -145,18 +52,18 @@ data:
chart: loki-stack
releaseName: loki
repoType: helm
targetNamespace: observability
targetNamespace: vela-system
url: https://charts.kubevela.net/addons
version: 2.4.1
traits:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
credentialSecretNamespace: vela-system
grafanaServiceName: grafana
grafanaServiceNamespace: observability
grafanaServiceNamespace: vela-system
name: loki
namespace: observability
namespace: vela-system
service: loki
type: loki
type: register-grafana-datasource
@@ -166,7 +73,7 @@ data:
chart: prometheus
releaseName: prometheus
repoType: helm
targetNamespace: observability
targetNamespace: vela-system
url: https://charts.kubevela.net/addons
values:
alertmanager:
@@ -184,11 +91,11 @@ data:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
credentialSecretNamespace: vela-system
grafanaServiceName: grafana
grafanaServiceNamespace: observability
grafanaServiceNamespace: vela-system
name: prometheus
namespace: observability
namespace: vela-system
service: prometheus-server
type: prometheus
type: register-grafana-datasource
@@ -197,7 +104,7 @@ data:
properties:
chart: kube-state-metrics
repoType: helm
targetNamespace: observability
targetNamespace: vela-system
url: https://charts.kubevela.net/addons
values:
image:
@@ -212,22 +119,6 @@ data:
name: fluxcd
namespace: vela-system
type: depends-on-app
- name: apply-ns
properties:
component: ns-observability
type: apply-component
- name: apply-trait-1
properties:
component: import-grafana-dashboard-traitdef
type: apply-component
- name: apply-trait-2
properties:
component: pure-ingress-traitdef
type: apply-component
- name: apply-trait-3
properties:
component: register-grafana-datasource-traitdef
type: apply-component
- name: apply-resources
type: apply-remaining
status:

View File

@@ -0,0 +1,70 @@
apiVersion: v1
data:
application: |
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for Alibaba Cloud
addons.oam.dev/name: terraform-alibaba
name: terraform-alibaba
namespace: vela-system
spec:
components:
- name: alibaba-account-creds-[[ index .Args "providerName" ]]
properties:
apiVersion: v1
kind: Secret
metadata:
name: alibaba-account-creds-[[ index .Args "providerName" ]]
namespace: vela-system
stringData:
credentials: |
accessKeyID: [[ index .Args "ALICLOUD_ACCESS_KEY" ]]
accessKeySecret: [[ index .Args "ALICLOUD_SECRET_KEY" ]]
securityToken: [[ index .Args "ALICLOUD_SECURITY_TOKEN" ]]
type: Opaque
type: raw
- name: alibaba-[[ index .Args "providerName" ]]
properties:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Provider
metadata:
name: '[[ index .Args "providerName" ]]'
namespace: default
spec:
credentials:
secretRef:
key: credentials
name: alibaba-account-creds-[[ index .Args "providerName" ]]
namespace: vela-system
source: Secret
provider: alibaba
region: '[[ index .Args "ALICLOUD_REGION" ]]'
type: raw
workflow:
steps:
- name: ""
properties:
name: terraform
namespace: vela-system
type: depends-on-app
- name: ""
type: apply-application
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
kind: ConfigMap
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for Alibaba Cloud
addons.oam.dev/name: terraform-alibaba
labels:
addons.oam.dev/type: terraform-alibaba
name: terraform-alibaba
namespace: {{.Values.systemDefinitionNamespace}}

View File

@@ -0,0 +1,70 @@
apiVersion: v1
data:
application: |
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for AWS
addons.oam.dev/name: terraform-aws
name: terraform-aws
namespace: vela-system
spec:
components:
- name: aws-account-creds
properties:
apiVersion: v1
kind: Secret
metadata:
name: aws-account-creds
namespace: vela-system
stringData:
credentials: |
awsAccessKeyID: [[ index .Args "AWS_ACCESS_KEY_ID" ]]
awsSecretAccessKey: [[ index .Args "AWS_SECRET_ACCESS_KEY" ]]
awsSessionToken: [[ index .Args "AWS_SESSION_TOKEN" ]]
type: Opaque
type: raw
- name: aws
properties:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Provider
metadata:
name: aws
namespace: default
spec:
credentials:
secretRef:
key: credentials
name: aws-account-creds
namespace: vela-system
source: Secret
provider: aws
region: '[[ index .Args "AWS_DEFAULT_REGION" ]]'
type: raw
workflow:
steps:
- name: ""
properties:
name: terraform
namespace: vela-system
type: depends-on-app
- name: ""
type: apply-application
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
kind: ConfigMap
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for AWS
addons.oam.dev/name: terraform-aws
labels:
addons.oam.dev/type: terraform-aws
name: terraform-aws
namespace: {{.Values.systemDefinitionNamespace}}

View File

@@ -0,0 +1,70 @@
apiVersion: v1
data:
application: |
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for Azure
addons.oam.dev/name: terraform-azure
name: terraform-azure
namespace: vela-system
spec:
components:
- name: azure-account-creds
properties:
apiVersion: v1
kind: Secret
metadata:
name: azure-account-creds
namespace: vela-system
stringData:
credentials: |
armClientID: [[ index .Args "ARM_CLIENT_ID" ]]
armClientSecret: [[ index .Args "ARM_CLIENT_SECRET" ]]
armSubscriptionID: [[ index .Args "ARM_SUBSCRIPTION_ID" ]]
armTenantID: [[ index .Args "ARM_TENANT_ID" ]]
type: Opaque
type: raw
- name: azure
properties:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Provider
metadata:
name: azure
namespace: default
spec:
credentials:
secretRef:
key: credentials
name: azure-account-creds
namespace: vela-system
source: Secret
provider: azure
type: raw
workflow:
steps:
- name: ""
properties:
name: terraform
namespace: vela-system
type: depends-on-app
- name: ""
type: apply-application
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
kind: ConfigMap
metadata:
annotations:
addons.oam.dev/description: Kubernetes Terraform Controller for Azure
addons.oam.dev/name: terraform-azure
labels:
addons.oam.dev/type: terraform-azure
name: terraform-azure
namespace: {{.Values.systemDefinitionNamespace}}

View File

@@ -11,20 +11,35 @@ data:
namespace: vela-system
spec:
components:
- name: ns-terraform-system
properties:
apiVersion: v1
kind: Namespace
metadata:
name: terraform-system
type: raw
- name: terraform-controller
properties:
chart: terraform-controller
repoType: helm
url: https://charts.kubevela.net/addons
version: 0.2.6
version: 0.2.10
type: helm
- name: alibaba-redis
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
Redis
labels:
type: terraform
name: alibaba-redis
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules/alibaba/redis
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-ack
properties:
apiVersion: core.oam.dev/v1beta1
@@ -48,6 +63,29 @@ data:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-ask
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
Serverless Kubernetes (ASK)
labels:
type: terraform
name: alibaba-ask
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules.git
path: alibaba/cs/serverless-kubernetes
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-eip
properties:
apiVersion: core.oam.dev/v1alpha2
@@ -76,6 +114,8 @@ data:
kind: ComponentDefinition
metadata:
annotations:
cloud-resource/console-url: https://oss.console.aliyun.com/bucket/oss-{ALICLOUD_REGION}/{BUCKET_NAME}/overview
cloud-resource/identifier: BUCKET_NAME
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
OSS object
labels:
@@ -103,6 +143,9 @@ data:
kind: ComponentDefinition
metadata:
annotations:
cloud-resource/console-url: https://rdsnext.console.aliyun.com/detail/{DB_ID}/basicInfo?&region={ALICLOUD_REGION}
cloud-resource/identifier: DB_ID
cloud-resource/sensitive-outputs: DB_PASSWORD
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
RDS object
labels:
@@ -126,6 +169,10 @@ data:
security_ips = ["0.0.0.0/0",]
}
output "DB_ID" {
value = module.rds.db_instance_id
}
output "DB_NAME" {
value = module.rds.this_db_instance_name
}
@@ -173,6 +220,98 @@ data:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-sls-project
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
SLS Project
labels:
type: terraform
name: alibaba-sls-project
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules.git
path: alibaba/sls/project
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-sls-store
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
SLS Store
labels:
type: terraform
name: alibaba-sls-store
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules.git
path: alibaba/sls/store
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-vpc
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
VPC
labels:
type: terraform
name: alibaba-vpc
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules.git
path: alibaba/vpc
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: alibaba-vswitch
properties:
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Alibaba Cloud
VSwitch
labels:
type: terraform
name: alibaba-vswitch
namespace: vela-system
spec:
schematic:
terraform:
configuration: https://github.com/kubevela-contrib/terraform-modules.git
path: alibaba/vswitch
type: remote
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: aws-s3
properties:
apiVersion: core.oam.dev/v1alpha2
@@ -329,19 +468,119 @@ data:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
- name: azure-storage-account
properties:
apiVersion: core.oam.dev/v1alpha2
kind: ComponentDefinition
metadata:
annotations:
definition.oam.dev/description: Terraform configuration for Azure Blob Storage
Account
provider: azure
labels:
type: terraform
name: azure-storage-account
namespace: vela-system
spec:
schematic:
terraform:
configuration: |
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "rsg" {
count = var.create_rsg ? 1 : 0
name = var.resource_group_name
location = var.location
}
resource "azurerm_storage_account" "sa" {
name = var.name
resource_group_name = var.create_rsg ? azurerm_resource_group.rsg[0].name : var.resource_group_name
location = var.location
account_tier = "Standard"
account_replication_type = "GRS"
enable_https_traffic_only = true
dynamic "static_website" {
for_each = var.static_website
content {
index_document = static_website.value["index_document"]
error_404_document = static_website.value["error_404_document"]
}
}
tags = var.tags
}
variable "create_rsg" {
description = "Conditional if resource group should be created. Defaults to 'true'."
type = bool
default = true
}
variable "resource_group_name" {
description = "Name of resource group. Defaults to 'rsg'."
type = string
default = "rsg"
}
variable "name" {
description = "Name of storage account. Defaults to 'storageaccount'."
type = string
default = "storageaccount"
}
variable "location" {
description = "Location of storage account. Defaults to 'West Europe'."
type = string
default = "West Europe"
}
variable "tags" {
description = "Tags for storage account. Defaults to '{}'."
type = map(string)
default = {}
}
variable "static_website" {
description = "Static website configuration. Defaults to disabled."
type = list(map(string))
default = [{
index_document = null
error_404_document = null
}]
}
output "BLOB_CONNECTION_STRING" {
description = "Blob storage connection string"
sensitive = true
value = azurerm_storage_account.sa.primary_connection_string
}
output "BLOB_WEB_ENDPOINT" {
description = "Blob storage static web endpoint"
value = azurerm_storage_account.sa.primary_web_endpoint
}
providerRef:
name: azure
namespace: default
workload:
definition:
apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
type: raw
workflow:
steps:
- name: checking-depends-on
- name: ""
properties:
name: fluxcd
namespace: vela-system
type: depends-on-app
- name: apply-ns
properties:
component: ns-terraform-system
type: apply-component
- name: apply-resources
type: apply-remaining
- name: ""
type: apply-application
status:
rollout:
batchRollingState: ""

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: create
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- create

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: patch
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- patch

View File

@@ -35,7 +35,7 @@ spec:
{{ if .Values.multicluster.clusterGateway.secureTLS.enabled }}
- "--cert-dir={{ .Values.multicluster.clusterGateway.secureTLS.certPath }}"
{{ end }}
image: {{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
imagePullPolicy: {{ .Values.multicluster.clusterGateway.image.pullPolicy }}
resources:
{{- toYaml .Values.multicluster.clusterGateway.resources | nindent 12 }}
@@ -132,7 +132,7 @@ spec:
spec:
containers:
- name: create
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- create
@@ -175,7 +175,7 @@ spec:
spec:
containers:
- name: patch
image: {{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
imagePullPolicy: {{ .Values.multicluster.clusterGateway.image.pullPolicy }}
command:
- /patch

View File

@@ -27,7 +27,7 @@ spec:
}
}
load: op.#Steps & {
if dependsOn.err != _|_ && dependsOn.value == _|_ {
if dependsOn.err != _|_ {
configMap: op.#Read & {
value: {
apiVersion: "v1"
@@ -37,18 +37,17 @@ spec:
namespace: parameter.namespace
}
}
}
apply: op.#Apply & {
value: {
yaml.Unmarshal(configMap.value.data[parameter.name])
}
}
} @step(1)
template: configMap.value.data["application"]
apply: op.#Apply & {
value: yaml.Unmarshal(template)
} @step(2)
wait: op.#ConditionalWait & {
continue: load.apply.value.status.status == "running"
}
continue: apply.value.status.status == "running"
} @step(3)
}
if dependsOn.value != _|_ {
if dependsOn.err == _|_ {
wait: op.#ConditionalWait & {
continue: dependsOn.value.status.status == "running"
}

View File

@@ -0,0 +1,39 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/import-grafana-dashboard.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Import dashboards to Grafana
name: import-grafana-dashboard
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "ImportDashboard"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
urls: parameter.urls
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: *"default" | string
urls: [...string]
}
workloadRefPath: ""

View File

@@ -0,0 +1,56 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/pure-ingress.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Enable public web traffic for the component without creating a Service.
name: pure-ingress
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata: name: context.name
spec: rules: [{
host: parameter.domain
http: paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}]
}
parameter: {
// +usage=Specify the domain you want to expose
domain: string
// +usage=Specify the mapping relationship between the http path and the workload port
http: [string]: int
}
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
workloadRefPath: ""

View File

@@ -0,0 +1,48 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/register-grafana-datasource.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: register-grafana-datasource
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "DatasourceRegistration"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
datasource: {
name: parameter.name
type: parameter.type
access: parameter.access
service: parameter.service
namespace: parameter.namespace
}
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: string
name: string
type: string
access: *"proxy" | string
service: string
namespace: *"default" | string
}
workloadRefPath: ""

View File

@@ -30,7 +30,7 @@ spec:
args:
- "apiserver"
- "--port={{ .Values.apiServer.port }}"
image: {{ .Values.apiserverImage.repository }}:{{ .Values.apiserverImage.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.apiserverImage.repository }}:{{ .Values.apiserverImage.tag }}
imagePullPolicy: {{ quote .Values.apiserverImage.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@@ -130,7 +130,7 @@ spec:
{{ if .Values.multicluster.enabled }}
- "--enable-cluster-gateway"
{{ end }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ quote .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@@ -10,7 +10,7 @@ spec:
- name: helm-test-express-server
type: webservice
properties:
image: crccheck/hello-world
image: {{ .Values.imageRegistry }}{{ .Values.test.app.repository }}:{{ .Values.test.app.tag }}
port: 8000
traits:
- type: ingress
@@ -30,7 +30,7 @@ spec:
serviceAccountName: kubevela-vela-core
containers:
- name: {{ .Release.Name }}-application-test
image: alpine/k8s:1.18.2
image: {{ .Values.imageRegistry }}{{ .Values.test.k8s.repository }}:{{ .Values.test.k8s.tag }}
imagePullPolicy: IfNotPresent
command:
- /bin/bash

View File

@@ -7,6 +7,8 @@ replicaCount: 1
applyOnceOnly: "off"
disableCaps: ""
imageRegistry: ""
image:
repository: oamdev/vela-core
tag: latest
@@ -130,4 +132,12 @@ multicluster:
memory: 200Mi
secureTLS:
enabled: true
certPath: /etc/k8s-cluster-gateway-certs
certPath: /etc/k8s-cluster-gateway-certs
test:
app:
repository: oamdev/hello-world
tag: v1
k8s:
repository: oamdev/alpine-k8s
tag: 1.18.2

View File

@@ -1232,6 +1232,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1245,11 +1251,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1259,6 +1270,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1639,6 +1667,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1652,11 +1686,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1666,6 +1705,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1944,6 +2000,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1957,11 +2019,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1971,6 +2038,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3372,6 +3456,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3385,11 +3475,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3399,6 +3494,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3672,6 +3784,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3685,11 +3803,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3699,6 +3822,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4061,6 +4201,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4074,11 +4220,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4088,6 +4239,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4329,6 +4497,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4342,11 +4516,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4356,6 +4535,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4617,6 +4813,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4630,11 +4832,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4644,6 +4851,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -222,6 +222,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -235,11 +241,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -249,6 +260,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -510,6 +538,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -523,11 +557,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -537,6 +576,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -791,6 +847,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -804,11 +866,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -818,6 +885,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1053,6 +1137,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -1066,11 +1156,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1080,6 +1175,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -151,6 +151,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -164,11 +169,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -178,6 +187,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -188,6 +188,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -201,11 +206,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -215,6 +224,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -472,6 +497,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -485,11 +515,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -499,6 +533,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -148,6 +148,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -161,11 +166,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -175,6 +184,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -193,6 +193,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -206,11 +211,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -220,6 +229,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -458,6 +483,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -471,11 +501,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -485,6 +519,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: create
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- create

View File

@@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: patch
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- patch

View File

@@ -35,7 +35,7 @@ spec:
{{ if .Values.multicluster.clusterGateway.secureTLS.enabled }}
- "--cert-dir={{ .Values.multicluster.clusterGateway.secureTLS.certPath }}"
{{ end }}
image: {{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
imagePullPolicy: {{ .Values.multicluster.clusterGateway.image.pullPolicy }}
resources:
{{- toYaml .Values.multicluster.clusterGateway.resources | nindent 12 }}
@@ -132,7 +132,7 @@ spec:
spec:
containers:
- name: create
image: {{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }}
imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }}
args:
- create
@@ -175,7 +175,7 @@ spec:
spec:
containers:
- name: patch
image: {{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.multicluster.clusterGateway.image.repository }}:{{ .Values.multicluster.clusterGateway.image.tag }}
imagePullPolicy: {{ .Values.multicluster.clusterGateway.image.pullPolicy }}
command:
- /patch

View File

@@ -27,7 +27,7 @@ spec:
}
}
load: op.#Steps & {
if dependsOn.err != _|_ && dependsOn.value == _|_ {
if dependsOn.err != _|_ {
configMap: op.#Read & {
value: {
apiVersion: "v1"
@@ -37,18 +37,17 @@ spec:
namespace: parameter.namespace
}
}
}
apply: op.#Apply & {
value: {
yaml.Unmarshal(configMap.value.data[parameter.name])
}
}
} @step(1)
template: configMap.value.data["application"]
apply: op.#Apply & {
value: yaml.Unmarshal(template)
} @step(2)
wait: op.#ConditionalWait & {
continue: load.apply.value.status.status == "running"
}
continue: apply.value.status.status == "running"
} @step(3)
}
if dependsOn.value != _|_ {
if dependsOn.err == _|_ {
wait: op.#ConditionalWait & {
continue: dependsOn.value.status.status == "running"
}

View File

@@ -0,0 +1,39 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/import-grafana-dashboard.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Import dashboards to Grafana
name: import-grafana-dashboard
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "ImportDashboard"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
urls: parameter.urls
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: *"default" | string
urls: [...string]
}
workloadRefPath: ""

View File

@@ -0,0 +1,56 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/pure-ingress.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Enable public web traffic for the component without creating a Service.
name: pure-ingress
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata: name: context.name
spec: rules: [{
host: parameter.domain
http: paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}]
}
parameter: {
// +usage=Specify the domain you want to expose
domain: string
// +usage=Specify the mapping relationship between the http path and the workload port
http: [string]: int
}
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
workloadRefPath: ""

View File

@@ -0,0 +1,48 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/register-grafana-datasource.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: register-grafana-datasource
namespace: {{.Values.systemDefinitionNamespace}}
spec:
appliesToWorkloads: []
conflictsWith: []
podDisruptive: false
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "DatasourceRegistration"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
datasource: {
name: parameter.name
type: parameter.type
access: parameter.access
service: parameter.service
namespace: parameter.namespace
}
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: string
name: string
type: string
access: *"proxy" | string
service: string
namespace: *"default" | string
}
workloadRefPath: ""

View File

@@ -30,7 +30,7 @@ spec:
args:
- "apiserver"
- "--bind-addr=0.0.0.0:{{ .Values.apiServer.port }}"
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ quote .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@@ -132,7 +132,7 @@ spec:
{{ if .Values.multicluster.enabled }}
- "--enable-cluster-gateway"
{{ end }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
image: {{ .Values.imageRegistry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ quote .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@@ -10,53 +10,5 @@ spec:
- name: helm-test-express-server
type: webservice
properties:
image: crccheck/hello-world
image: {{ .Values.imageRegistry }}{{ .Values.test.app.repository }}:{{ .Values.test.app.tag }}
port: 8000
# traits:
# - type: ingress
# properties:
# domain: testsvc.example.com
# http:
# "/": 8000
# ---
# apiVersion: v1
# kind: Pod
# metadata:
# name: "{{ .Release.Name }}-application-test"
# annotations:
# "helm.sh/hook": test
# helm.sh/hook-delete-policy: hook-succeeded
# spec:
# serviceAccountName: kubevela-vela-core
# containers:
# - name: {{ .Release.Name }}-application-test
# image: alpine/k8s:1.18.2
# imagePullPolicy: IfNotPresent
# command:
# - /bin/bash
# - -ec
# - |
# set -e
# echo "Waiting application is ready..."
# echo "waiting for application being Ready"
# kubectl -n vela-system wait --for=condition=Ready applications.core.oam.dev helm-test-vela-app --timeout=3m
# echo "application is Ready"
# # wait for deploy being created
# echo "waiting for deployment being available"
# kubectl -n vela-system wait --for=condition=available deployments helm-test-express-server --timeout 3m
# echo "deployment being available"
# # wait for ingress being created
# while ! [ `kubectl -n vela-system get ing helm-test-express-server | grep -v NAME | wc -l` = 1 ]; do
# echo "waiting for ingress being created"
# sleep 1
# done
# echo "Application and its components are created"
# restartPolicy: Never

View File

@@ -7,6 +7,8 @@ replicaCount: 1
applyOnceOnly: "off"
disableCaps: "manualscalertrait,containerizedwokrload,envbinding"
imageRegistry: ""
image:
repository: oamdev/vela-core
tag: latest
@@ -125,4 +127,9 @@ multicluster:
memory: 200Mi
secureTLS:
enabled: true
certPath: /etc/k8s-cluster-gateway-certs
certPath: /etc/k8s-cluster-gateway-certs
test:
app:
repository: oamdev/hello-world
tag: v1

View File

@@ -1,4 +1,4 @@
This repo is the source artifacts for addon `observability`.
- All .cue files are source artifacts from definition of [observability-asset](../../../vela-templates/addons/observability-asset).
- `initializer-observability.yaml` will help developer [observability](../../../vela-templates/addons/observability).
- All files in definitions are source artifacts which is now built-in in `vela-core` helm chart.
- `application-observability.yaml` will help developer [observability](../../../vela-templates/addons/observability).

View File

@@ -1,21 +0,0 @@
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "ImportDashboard"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
urls: parameter.urls
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: *"default" | string
urls: [...string]
}

View File

@@ -1,31 +0,0 @@
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "DatasourceRegistration"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
datasource: {
name: parameter.name
type: parameter.type
access: parameter.access
service: parameter.service
namespace: parameter.namespace
}
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: string
name: string
type: string
access: *"proxy" | string
service: string
namespace: *"default" | string
}

View File

@@ -0,0 +1,13 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-ask-sample
spec:
components:
- name: sample-ask
type: alibaba-ask
properties:
name: kubevela
writeConnectionSecretToRef:
name: ask-conn

View File

@@ -0,0 +1,14 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-rds-sample
spec:
components:
- name: sample-db
type: alibaba-rds
properties:
instance_name: sample-db
account_name: oamtest
password: U34rfwefwefffaked
writeConnectionSecretToRef:
name: db-conn

View File

@@ -0,0 +1,14 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-sls-project-sample
spec:
components:
- name: sample-sls-project
type: alibaba-sls-project
properties:
name: kubevela-1112
description: "Managed by KubeVela"
writeConnectionSecretToRef:
name: sls-project-conn

View File

@@ -0,0 +1,16 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-sls-store-sample
spec:
components:
- name: sample-sls-store
type: alibaba-sls-store
properties:
store_name: kubevela-1111
store_retention_period: 30
store_shard_count: 2
store_max_split_shard_count: 2
writeConnectionSecretToRef:
name: sls-store-conn

View File

@@ -0,0 +1,13 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-vpc-sample
spec:
components:
- name: sample-vpc
type: alibaba-vpc
properties:
vpc_cidr: "172.16.0.0/12"
writeConnectionSecretToRef:
name: vpc-conn

View File

@@ -0,0 +1,15 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-vpc-sample
spec:
components:
- name: sample-vswitch
type: alibaba-vswitch
properties:
vpc_cidr: "172.16.0.0/12"
vswitch_cidr: "172.16.0.0/18"
zone_id: cn-beijing-a
writeConnectionSecretToRef:
name: vswitch-conn

View File

@@ -88,9 +88,8 @@ var ApplicationStatusDeeplyContext = func(context string, applicationName, workl
}, 180*time.Second, 1*time.Second).Should(gomega.BeTrue())
cli := fmt.Sprintf("vela status %s", applicationName)
output, err := e2e.LongTimeExec(cli, 120*time.Second)
_, err = e2e.LongTimeExec(cli, 120*time.Second)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(output).To(gomega.ContainSubstring("Checking health status"))
// TODO(zzxwill) need to check workloadType after app status is refined
})
})

12
e2e/application/vela.yaml Normal file
View File

@@ -0,0 +1,12 @@
createTime: "0001-01-01T00:00:00Z"
name: initmyapp
services:
mysvc:
addRevisionLabel: false
cpu: "0.5"
image: nginx:latest
imagePullPolicy: Always
memory: 200M
port: 80
type: webservice
updateTime: "0001-01-01T00:00:00Z"

View File

@@ -127,7 +127,7 @@ var (
cli := fmt.Sprintf("vela delete %s", applicationName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(output).To(gomega.ContainSubstring("deleted from env"))
gomega.Expect(output).To(gomega.ContainSubstring("already deleted"))
})
})
}

4
go.mod
View File

@@ -10,7 +10,7 @@ require (
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/briandowns/spinner v1.11.1
github.com/containerd/containerd v1.4.11
github.com/containerd/containerd v1.4.12
github.com/coreos/prometheus-operator v0.41.1
github.com/crossplane/crossplane-runtime v0.14.1-0.20210722005935-0b469fcc77cd
github.com/davecgh/go-spew v1.1.1
@@ -36,7 +36,7 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.1
github.com/oam-dev/cluster-gateway v1.1.6
github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28
github.com/oam-dev/terraform-controller v0.2.6
github.com/oam-dev/terraform-controller v0.2.12
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.16.0

11
go.sum
View File

@@ -181,6 +181,7 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
github.com/alessio/shellescape v1.2.2 h1:8LnL+ncxhWT2TR00dfJRT25JWWrhkMZXneHVWnetDZg=
github.com/alessio/shellescape v1.2.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1318/go.mod h1:9CMdKNL3ynIGPpfTcdwTvIm8SGuAZYYC4jFVSSvE1YQ=
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
@@ -310,8 +311,8 @@ github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.11 h1:QCGOUN+i70jEEL/A6JVIbhy4f4fanzAzSR4kNG7SlcE=
github.com/containerd/containerd v1.4.11/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.12 h1:V+SHzYmhng/iju6M5nFrpTTusrhidoxKTwdwLw+u4c4=
github.com/containerd/containerd v1.4.12/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7 h1:6ejg6Lkk8dskcM7wQ28gONkukbQkM4qpj4RnYbpFzrI=
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y=
@@ -673,6 +674,7 @@ github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
@@ -964,6 +966,7 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@@ -1214,8 +1217,8 @@ github.com/oam-dev/stern v1.13.1 h1:Gt7xMBmQjRueHVFjRo5CHDTVhiYrssjlmvPwRiZtq7c=
github.com/oam-dev/stern v1.13.1/go.mod h1:0pLjZt0amXE/ErF16Rdrgd98H2owN8Hmn3/7CX5+AeA=
github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 h1:tD8HiFKnt0jnwdTWjeqUnfnUYLD/+Nsmj8ZGIxqDWiU=
github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28/go.mod h1:Mu8i0/DdplvnjwRbAYPsc8+LRR27n/mp8VWdkN10GzE=
github.com/oam-dev/terraform-controller v0.2.6 h1:aoEj4sfxDMBdTkM5uKYmjVFOgjhYeYBm0xzdRb4+Xu0=
github.com/oam-dev/terraform-controller v0.2.6/go.mod h1:xFSCd3Nwuh6P1HEpx5jDnLzN35T9hoH53zdojDYE6LI=
github.com/oam-dev/terraform-controller v0.2.12 h1:WIcpV4JWVOiN52DOjwiOTvy4+snSWzX2ltFAnXP1QqE=
github.com/oam-dev/terraform-controller v0.2.12/go.mod h1:DbdquoYxiWoZnYpRsHH/HKdR1REYdwRQycYJuC1CUdQ=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=

View File

@@ -1232,6 +1232,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1245,11 +1251,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1259,6 +1270,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1639,6 +1667,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1652,11 +1686,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1666,6 +1705,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1944,6 +2000,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -1957,11 +2019,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1971,6 +2038,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3372,6 +3456,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3385,11 +3475,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3399,6 +3494,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -3672,6 +3784,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -3685,11 +3803,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -3699,6 +3822,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4061,6 +4201,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4074,11 +4220,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4088,6 +4239,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4329,6 +4497,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4342,11 +4516,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4356,6 +4535,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -4617,6 +4813,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote
git repository. It's valid when remote is set
@@ -4630,11 +4832,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region.
It will override the region in the region field
of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -4644,6 +4851,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required
to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -179,6 +179,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -192,11 +197,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -206,6 +215,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -467,6 +492,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -480,11 +510,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -494,6 +528,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -222,6 +222,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -235,11 +241,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -249,6 +260,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -510,6 +538,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -523,11 +557,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -537,6 +576,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -791,6 +847,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -804,11 +866,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -818,6 +885,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -1053,6 +1137,12 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether
provisioned cloud resources will be deleted when
CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git
repository. It's valid when remote is set
@@ -1066,11 +1156,16 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It
will override the region in the region field of
ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -1080,6 +1175,23 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies
the namespace and name of a Secret to which any
connection details for this managed resource should
be written. Connection details frequently include
the endpoint, username, and password required to
connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -151,6 +151,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -164,11 +169,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -178,6 +187,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -188,6 +188,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -201,11 +206,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -215,6 +224,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -472,6 +497,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -485,11 +515,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -499,6 +533,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -148,6 +148,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -161,11 +166,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -175,6 +184,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -193,6 +193,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -206,11 +211,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -220,6 +229,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object
@@ -458,6 +483,11 @@ spec:
configuration:
description: Configuration is Terraform Configuration
type: string
deleteResource:
default: true
description: DeleteResource will determine whether provisioned
cloud resources will be deleted when CR is deleted
type: boolean
path:
description: Path is the sub-directory of remote git repository.
It's valid when remote is set
@@ -471,11 +501,15 @@ spec:
type: string
namespace:
default: default
description: Namespace of the secret.
description: Namespace of the referenced object.
type: string
required:
- name
type: object
region:
description: Region is cloud provider's region. It will override
the region in the region field of ProviderReference
type: string
type:
default: hcl
description: Type specifies which Terraform configuration
@@ -485,6 +519,22 @@ spec:
- json
- remote
type: string
writeConnectionSecretToRef:
description: WriteConnectionSecretToReference specifies the
namespace and name of a Secret to which any connection details
for this managed resource should be written. Connection
details frequently include the endpoint, username, and password
required to connect to the managed resource.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
type: object
required:
- configuration
type: object

View File

@@ -50,14 +50,20 @@ import (
// constant error information
const (
errInvalidValueType = "require %q type parameter value"
errTerraformConfigurationIsNotSet = "terraform configuration is not set"
errFailToConvertTerraformComponentProperties = "failed to convert Terraform component properties"
errTerraformNameOfWriteConnectionSecretToRefNotSet = "the name of writeConnectionSecretToRef of terraform component is not set"
errInvalidValueType = "require %q type parameter value"
errTerraformConfigurationIsNotSet = "terraform configuration is not set"
errFailToConvertTerraformComponentProperties = "failed to convert Terraform component properties"
errConvertTerraformBaseConfigurationSpec = "failed to convert properties to Terraform Configuration spec"
)
// WriteConnectionSecretToRefKey is used to create a secret for cloud resource connection
const WriteConnectionSecretToRefKey = "writeConnectionSecretToRef"
const (
// WriteConnectionSecretToRefKey is used to create a secret for cloud resource connection
WriteConnectionSecretToRefKey = "writeConnectionSecretToRef"
// RegionKey is the region of a Cloud Provider
RegionKey = "region"
// ProviderRefKey is the reference of a Provider
ProviderRefKey = "providerRef"
)
// Workload is component
type Workload struct {
@@ -658,8 +664,14 @@ func generateTerraformConfigurationWorkload(wl *Workload, ns string) (*unstructu
}
configuration := terraformapi.Configuration{
TypeMeta: metav1.TypeMeta{APIVersion: "terraform.core.oam.dev/v1beta1", Kind: "Configuration"},
ObjectMeta: metav1.ObjectMeta{Name: wl.Name, Namespace: ns},
TypeMeta: metav1.TypeMeta{APIVersion: "terraform.core.oam.dev/v1beta1", Kind: "Configuration"},
ObjectMeta: metav1.ObjectMeta{
Name: wl.Name,
Namespace: ns,
},
}
if wl.FullTemplate.ComponentDefinition != nil {
configuration.ObjectMeta.Annotations = wl.FullTemplate.ComponentDefinition.Annotations
}
switch wl.FullTemplate.Terraform.Type {
@@ -672,19 +684,24 @@ func generateTerraformConfigurationWorkload(wl *Workload, ns string) (*unstructu
configuration.Spec.Path = wl.FullTemplate.Terraform.Path
}
if wl.FullTemplate.Terraform.ProviderReference != nil {
configuration.Spec.ProviderReference = wl.FullTemplate.Terraform.ProviderReference
}
// 1. parse writeConnectionSecretToRef
if err := json.Unmarshal(params, &configuration.Spec); err != nil {
if err := json.Unmarshal(params, &configuration); err != nil {
return nil, errors.Wrap(err, errFailToConvertTerraformComponentProperties)
}
if configuration.Spec.WriteConnectionSecretToReference != nil {
if configuration.Spec.WriteConnectionSecretToReference.Name == "" {
return nil, errors.New(errTerraformNameOfWriteConnectionSecretToRefNotSet)
}
var spec terraformapi.BaseConfigurationSpec
if err := json.Unmarshal(params, &spec); err != nil {
return nil, errors.Wrap(err, errConvertTerraformBaseConfigurationSpec)
}
if spec.ProviderReference != nil && !reflect.DeepEqual(configuration.Spec.ProviderReference, spec.ProviderReference) {
configuration.Spec.ProviderReference = spec.ProviderReference
}
if spec.Region != "" && configuration.Spec.Region != spec.Region {
configuration.Spec.Region = spec.Region
}
if spec.WriteConnectionSecretToReference != nil && spec.WriteConnectionSecretToReference.Name != "" &&
!reflect.DeepEqual(configuration.Spec.WriteConnectionSecretToReference, spec.WriteConnectionSecretToReference) {
configuration.Spec.WriteConnectionSecretToReference = spec.WriteConnectionSecretToReference
// set namespace for writeConnectionSecretToRef, developer needn't manually set it
if configuration.Spec.WriteConnectionSecretToReference.Namespace == "" {
configuration.Spec.WriteConnectionSecretToReference.Namespace = ns
@@ -702,11 +719,14 @@ func generateTerraformConfigurationWorkload(wl *Workload, ns string) (*unstructu
return nil, errors.Wrap(err, errFailToConvertTerraformComponentProperties)
}
delete(variableMap, WriteConnectionSecretToRefKey)
delete(variableMap, RegionKey)
delete(variableMap, ProviderRefKey)
data, err := json.Marshal(variableMap)
if err != nil {
return nil, errors.Wrap(err, errFailToConvertTerraformComponentProperties)
}
configuration.Spec.Variable = &runtime.RawExtension{Raw: data}
raw := util.Object2RawExtension(&configuration)
return util.RawExtension2Unstructured(raw)

View File

@@ -608,12 +608,12 @@ variable "password" {
},
Spec: terraformapi.ConfigurationSpec{
HCL: configuration,
Variable: raw,
WriteConnectionSecretToReference: &terraformtypes.SecretReference{Name: "db", Namespace: "default"},
HCL: configuration,
Variable: raw,
},
Status: terraformapi.ConfigurationStatus{},
}
workload.Spec.WriteConnectionSecretToReference = &terraformtypes.SecretReference{Name: "db", Namespace: "default"}
expectCompManifest := &oamtypes.ComponentManifest{
Name: compName,
@@ -920,13 +920,6 @@ func TestGenerateTerraformConfigurationWorkload(t *testing.T) {
args args
want want
}{
"json workload with invalid secret": {
args: args{
json: "abc",
params: map[string]interface{}{"acl": "private", "writeConnectionSecretToRef": map[string]interface{}{"name": "", "namespace": ""}},
},
want: want{err: errors.New(errTerraformNameOfWriteConnectionSecretToRefNotSet)}},
"json workload with secret": {
args: args{
@@ -998,10 +991,10 @@ func TestGenerateTerraformConfigurationWorkload(t *testing.T) {
},
}
configSpec = terraformapi.ConfigurationSpec{
HCL: tc.args.hcl,
Variable: raw,
WriteConnectionSecretToReference: tc.args.writeConnectionSecretToRef,
HCL: tc.args.hcl,
Variable: raw,
}
configSpec.WriteConnectionSecretToReference = tc.args.writeConnectionSecretToRef
}
if tc.args.json != "" {
template = &Template{
@@ -1011,10 +1004,10 @@ func TestGenerateTerraformConfigurationWorkload(t *testing.T) {
},
}
configSpec = terraformapi.ConfigurationSpec{
JSON: tc.args.json,
Variable: raw,
WriteConnectionSecretToReference: tc.args.writeConnectionSecretToRef,
JSON: tc.args.json,
Variable: raw,
}
configSpec.WriteConnectionSecretToReference = tc.args.writeConnectionSecretToRef
}
if tc.args.remote != "" {
template = &Template{
@@ -1024,10 +1017,10 @@ func TestGenerateTerraformConfigurationWorkload(t *testing.T) {
},
}
configSpec = terraformapi.ConfigurationSpec{
Remote: tc.args.remote,
Variable: raw,
WriteConnectionSecretToReference: tc.args.writeConnectionSecretToRef,
Remote: tc.args.remote,
Variable: raw,
}
configSpec.WriteConnectionSecretToReference = tc.args.writeConnectionSecretToRef
}
if tc.args.hcl == "" && tc.args.json == "" && tc.args.remote == "" {
template = &Template{
@@ -1035,9 +1028,9 @@ func TestGenerateTerraformConfigurationWorkload(t *testing.T) {
}
configSpec = terraformapi.ConfigurationSpec{
Variable: raw,
WriteConnectionSecretToReference: tc.args.writeConnectionSecretToRef,
Variable: raw,
}
configSpec.WriteConnectionSecretToReference = tc.args.writeConnectionSecretToRef
}
if tc.args.providerRef != nil {
template.Terraform.ProviderReference = tc.args.providerRef

View File

@@ -78,6 +78,9 @@ func (p *Parser) GenerateAppFile(ctx context.Context, app *v1beta1.Application)
appName := app.Name
appfile := p.newAppfile(appName, ns, app)
if app.Status.LatestRevision != nil {
appfile.AppRevisionName = app.Status.LatestRevision.Name
}
var wds []*Workload
for _, comp := range app.Spec.Components {

View File

@@ -184,8 +184,10 @@ func (h *AppHandler) collectHealthStatus(wl *appfile.Workload, appRev *v1beta1.A
}
if configuration.Status.Apply.State != terraformtypes.Available {
status.Healthy = false
isHealth = false
} else {
status.Healthy = true
isHealth = true
}
status.Message = configuration.Status.Apply.Message
} else {

View File

@@ -221,13 +221,24 @@ func (h *handler) setWorkloadBaseInfo() {
h.sourceWorkload.SetNamespace(h.rollout.Namespace)
}
var appRev string
if len(h.rollout.GetLabels()) > 0 {
appRev = h.rollout.GetLabels()[oam.LabelAppRevision]
}
h.targetWorkload.SetName(h.compName)
util.AddLabels(h.targetWorkload, map[string]string{oam.LabelAppComponentRevision: h.targetRevName})
util.AddLabels(h.targetWorkload, map[string]string{
oam.LabelAppComponentRevision: h.targetRevName,
oam.LabelAppRevision: appRev,
})
util.AddAnnotations(h.targetWorkload, map[string]string{oam.AnnotationSkipGC: "true"})
if h.sourceWorkload != nil {
h.sourceWorkload.SetName(h.compName)
util.AddLabels(h.sourceWorkload, map[string]string{oam.LabelAppComponentRevision: h.sourceRevName})
util.AddLabels(h.sourceWorkload, map[string]string{
oam.LabelAppComponentRevision: h.sourceRevName,
oam.LabelAppRevision: appRev,
})
}
}

View File

@@ -60,6 +60,7 @@ var _ = Describe("Test rollout related handler func", func() {
srcWorkload.SetAPIVersion("apps/v1")
srcWorkload.SetKind("Deployment")
compName := "comp-test"
appRevName := "app-revision-v2"
h := handler{
reconciler: &reconciler{
Client: k8sClient,
@@ -67,6 +68,9 @@ var _ = Describe("Test rollout related handler func", func() {
rollout: &v1alpha1.Rollout{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Labels: map[string]string{
oam.LabelAppRevision: appRevName,
},
}},
targetWorkload: tarWorkload,
sourceWorkload: srcWorkload,
@@ -82,10 +86,10 @@ var _ = Describe("Test rollout related handler func", func() {
Expect(h.targetWorkload.GetNamespace()).Should(BeEquivalentTo(namespace))
Expect(h.sourceWorkload.GetNamespace()).Should(BeEquivalentTo(namespace))
tarLabel := h.targetWorkload.GetLabels()
Expect(len(tarLabel)).Should(BeEquivalentTo(2))
Expect(tarLabel[oam.LabelAppRevision]).Should(BeEquivalentTo(appRevName))
Expect(tarLabel[oam.LabelAppComponentRevision]).Should(BeEquivalentTo("comp-test-v2"))
srcLabel := h.sourceWorkload.GetLabels()
Expect(len(srcLabel)).Should(BeEquivalentTo(2))
Expect(srcLabel[oam.LabelAppRevision]).Should(BeEquivalentTo(appRevName))
Expect(srcLabel[oam.LabelAppComponentRevision]).Should(BeEquivalentTo("comp-test-v1"))
Expect(h.assembleWorkload(ctx)).Should(BeNil())

View File

@@ -31,7 +31,6 @@ import (
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/builtin"
"github.com/oam-dev/kubevela/pkg/oam"
cmdutil "github.com/oam-dev/kubevela/pkg/utils/util"
@@ -142,7 +141,7 @@ func (app *AppFile) ExecuteAppfileTasks(io cmdutil.IOStreams) error {
}
// BuildOAMApplication renders Appfile into Application, Scopes and other K8s Resources.
func (app *AppFile) BuildOAMApplication(env *types.EnvMeta, io cmdutil.IOStreams, tm template.Manager, silence bool) (*v1beta1.Application, []oam.Object, error) {
func (app *AppFile) BuildOAMApplication(namespace string, io cmdutil.IOStreams, tm template.Manager, silence bool) (*v1beta1.Application, []oam.Object, error) {
if err := app.ExecuteAppfileTasks(io); err != nil {
if strings.Contains(err.Error(), "'image' : not found") {
return nil, nil, ErrImageNotDefined
@@ -152,7 +151,7 @@ func (app *AppFile) BuildOAMApplication(env *types.EnvMeta, io cmdutil.IOStreams
// auxiliaryObjects currently include OAM Scope Custom Resources and ConfigMaps
var auxiliaryObjects []oam.Object
servApp := new(v1beta1.Application)
servApp.SetNamespace(env.Namespace)
servApp.SetNamespace(namespace)
servApp.SetName(app.Name)
servApp.Spec.Components = []common.ApplicationComponent{}
if !silence {

View File

@@ -132,7 +132,7 @@ func TestBuildOAMApplication2(t *testing.T) {
for _, tcase := range testCases {
tcase.expectApp.Namespace = expectNs
o, _, err := tcase.appFile.BuildOAMApplication(&types.EnvMeta{Namespace: expectNs}, cmdutil.IOStreams{
o, _, err := tcase.appFile.BuildOAMApplication(expectNs, cmdutil.IOStreams{
In: os.Stdin,
Out: os.Stdout,
}, tm, false)
@@ -378,7 +378,7 @@ outputs: ingress: {
}
}
application, objects, err := app.BuildOAMApplication(&types.EnvMeta{Namespace: "default"}, io, tm, false)
application, objects, err := app.BuildOAMApplication("default", io, tm, false)
if c.want.err != nil {
assert.Equal(t, c.want.err, err)
return

View File

@@ -24,27 +24,26 @@ import (
"text/template"
"time"
common2 "github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/Masterminds/sprig"
"github.com/gosuri/uitable"
terraformv1beta1 "github.com/oam-dev/terraform-controller/api/v1beta1"
"github.com/pkg/errors"
"github.com/spf13/cobra"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
kerrors "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/yaml"
types2 "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/dynamic"
yaml2 "k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/controller-runtime/pkg/client"
common2 "github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/oam"
"github.com/oam-dev/kubevela/pkg/oam/discoverymapper"
"github.com/oam-dev/kubevela/pkg/oam/util"
"github.com/oam-dev/kubevela/pkg/utils/apply"
"github.com/oam-dev/kubevela/pkg/utils/common"
cmdutil "github.com/oam-dev/kubevela/pkg/utils/util"
@@ -53,6 +52,14 @@ import (
const (
// DescAnnotation records the description of addon
DescAnnotation = "addons.oam.dev/description"
// DependsOnWorkFlowStepName is workflow step name which is used to check dependsOn app
DependsOnWorkFlowStepName = "depends-on-app"
// AddonTerraformProviderNamespace is the namespace of addon terraform provider
AddonTerraformProviderNamespace = "default"
// AddonTerraformProviderNameArgument is the argument name of addon terraform provider
AddonTerraformProviderNameArgument = "providerName"
)
var statusUninstalled = "uninstalled"
@@ -94,7 +101,7 @@ func NewAddonCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command
}
cmd.AddCommand(
NewAddonListCommand(),
NewAddonEnableCommand(ioStreams),
NewAddonEnableCommand(c, ioStreams),
NewAddonDisableCommand(ioStreams),
)
return cmd
@@ -118,13 +125,19 @@ func NewAddonListCommand() *cobra.Command {
}
// NewAddonEnableCommand create addon enable command
func NewAddonEnableCommand(ioStream cmdutil.IOStreams) *cobra.Command {
func NewAddonEnableCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra.Command {
ctx := context.Background()
return &cobra.Command{
Use: "enable",
Short: "enable an addon",
Long: "enable an addon in cluster",
Example: "vela addon enable <addon-name>",
RunE: func(cmd *cobra.Command, args []string) error {
k8sClient, err := c.GetClient()
if err != nil {
return err
}
if len(args) < 1 {
return fmt.Errorf("must specify addon name")
}
@@ -133,7 +146,7 @@ func NewAddonEnableCommand(ioStream cmdutil.IOStreams) *cobra.Command {
if err != nil {
return err
}
err = enableAddon(name, addonArgs)
err = enableAddon(ctx, k8sClient, name, addonArgs)
if err != nil {
return err
}
@@ -190,23 +203,31 @@ func listAddons() error {
table := uitable.New()
table.AddRow("NAME", "DESCRIPTION", "STATUS")
for _, addon := range addons {
// Addon terraform should be invisible to end-users. It will be installed by other addons like `terraform-alibaba`
if addon.name == "terraform" {
continue
}
table.AddRow(addon.name, addon.description, addon.getStatus())
}
fmt.Println(table.String())
return nil
}
func enableAddon(name string, args map[string]string) error {
func enableAddon(ctx context.Context, k8sClient client.Client, name string, args map[string]string) error {
repo, err := NewAddonRepo()
if err != nil {
return err
}
addon, err := repo.getAddon(name)
if err != nil {
return err
}
if strings.HasPrefix(name, "terraform-") {
args, _ = getTerraformProviderArgumentValue(name, args)
}
addon.setArgs(args)
err = addon.enable()
err = addon.enable(ctx, k8sClient, name, args)
return err
}
@@ -333,25 +354,10 @@ type Addon struct {
data string
// Args is map for renderInitializer
Args map[string]string
application *unstructured.Unstructured
gvk *schema.GroupVersionKind
application *v1beta1.Application
}
func (a *Addon) getGVK() (*schema.GroupVersionKind, error) {
if a.gvk == nil {
if a.application == nil {
_, err := a.renderApplication()
if err != nil {
return nil, err
}
}
gvk := schema.FromAPIVersionAndKind(a.application.GetAPIVersion(), a.application.GetKind())
a.gvk = &gvk
}
return a.gvk, nil
}
func (a *Addon) renderApplication() (*unstructured.Unstructured, error) {
func (a *Addon) renderApplication() (*v1beta1.Application, error) {
if a.Args == nil {
a.Args = map[string]string{}
}
@@ -364,24 +370,35 @@ func (a *Addon) renderApplication() (*unstructured.Unstructured, error) {
if err != nil {
return nil, errors.Wrap(err, "application template render fail")
}
dec := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme)
obj := &unstructured.Unstructured{}
_, gvk, err := dec.Decode(buf.Bytes(), nil, obj)
err = yaml2.NewYAMLOrJSONDecoder(&buf, buf.Len()).Decode(&a.application)
if err != nil {
return nil, err
}
a.application = obj
a.gvk = gvk
return a.application, nil
}
func (a *Addon) enable() error {
func (a *Addon) enable(ctx context.Context, k8sClient client.Client, name string, args map[string]string) error {
applicator := apply.NewAPIApplicator(clt)
ctx := context.Background()
obj, err := a.renderApplication()
if err != nil {
return err
}
if strings.HasPrefix(name, "terraform-") {
providerName, existed, err := checkWhetherTerraformProviderExist(ctx, k8sClient, name, args)
if err != nil && !apimeta.IsNoMatchError(err) {
return err
}
if existed {
return errors.Errorf("terraform provider %s with name %s already exists", name, providerName)
}
obj.Name = fmt.Sprintf("%s-%s", obj.Name, providerName)
}
err = a.installDependsOn(ctx, k8sClient, args)
if err != nil {
return errors.Wrap(err, "Error occurs when install dependent addon")
}
err = applicator.Apply(ctx, obj)
if err != nil {
return errors.Wrapf(err, "Error occurs when apply addon application: %s\n", a.name)
@@ -393,7 +410,7 @@ func (a *Addon) enable() error {
return nil
}
func waitApplicationRunning(obj *unstructured.Unstructured) error {
func waitApplicationRunning(obj *v1beta1.Application) error {
ctx := context.Background()
period := 20 * time.Second
timeout := 10 * time.Minute
@@ -412,40 +429,12 @@ func waitApplicationRunning(obj *unstructured.Unstructured) error {
})
}
func (a *Addon) disable() error {
dynamicClient, err := dynamic.NewForConfig(clientArgs.Config)
if err != nil {
return err
}
mapper, err := discoverymapper.New(clientArgs.Config)
if err != nil {
return err
}
obj, err := a.renderApplication()
if err != nil {
return err
}
gvk, err := a.getGVK()
if err != nil {
return err
}
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return err
}
var resourceREST dynamic.ResourceInterface
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
// namespaced resources should specify the namespace
resourceREST = dynamicClient.Resource(mapping.Resource).Namespace(obj.GetNamespace())
} else {
// for cluster-wide resources
resourceREST = dynamicClient.Resource(mapping.Resource)
}
deletePolicy := metav1.DeletePropagationForeground
deleteOptions := metav1.DeleteOptions{
PropagationPolicy: &deletePolicy,
}
fmt.Println("Deleting all resources...")
err = resourceREST.Delete(context.TODO(), obj.GetName(), deleteOptions)
err = clt.Delete(context.TODO(), obj, client.PropagationPolicy(metav1.DeletePropagationForeground))
if err != nil {
return err
}
@@ -468,7 +457,86 @@ func (a *Addon) setArgs(args map[string]string) {
a.Args = args
}
func (a *Addon) installDependsOn(ctx context.Context, k8sClient client.Client, args map[string]string) error {
if a.application.Spec.Workflow == nil || a.application.Spec.Workflow.Steps == nil {
return nil
}
repo, err := NewAddonRepo()
if err != nil {
return err
}
for _, step := range a.application.Spec.Workflow.Steps {
if step.Type == DependsOnWorkFlowStepName {
props, err := util.RawExtension2Map(step.Properties)
if err != nil {
return err
}
dependsOnAddonName, _ := props["name"].(string)
fmt.Printf("Installing dependent addon: %s\n", dependsOnAddonName)
addon, err := repo.getAddon(dependsOnAddonName)
if err != nil {
return err
}
if addon.getStatus() != statusInstalled {
err = addon.enable(ctx, k8sClient, dependsOnAddonName, args)
if err != nil {
return err
}
}
}
}
return nil
}
// TransAddonName will turn addon's name from xxx/yyy to xxx-yyy
func TransAddonName(name string) string {
return strings.ReplaceAll(name, "/", "-")
}
func getTerraformProviderNames(ctx context.Context, k8sClient client.Client) ([]string, error) {
var names []string
providerList := &terraformv1beta1.ProviderList{}
err := k8sClient.List(ctx, providerList, client.InNamespace(AddonTerraformProviderNamespace))
if err != nil {
if apimeta.IsNoMatchError(err) || kerrors.IsNotFound(err) {
return nil, nil
}
return nil, err
}
for _, provider := range providerList.Items {
names = append(names, provider.Name)
}
return names, nil
}
// Get the value of argument AddonTerraformProviderNameArgument
func getTerraformProviderArgumentValue(addonName string, args map[string]string) (map[string]string, string) {
providerName, ok := args[AddonTerraformProviderNameArgument]
if !ok {
switch addonName {
case "terraform-alibaba":
providerName = "default"
case "terraform-aws":
providerName = "aws"
case "terraform-azure":
providerName = "azure"
}
args[AddonTerraformProviderNameArgument] = providerName
}
return args, providerName
}
func checkWhetherTerraformProviderExist(ctx context.Context, k8sClient client.Client, addonName string, args map[string]string) (string, bool, error) {
_, providerName := getTerraformProviderArgumentValue(addonName, args)
providerNames, err := getTerraformProviderNames(ctx, k8sClient)
if err != nil {
return "", false, err
}
for _, name := range providerNames {
if providerName == name {
return providerName, true, nil
}
}
return providerName, false, nil
}

View File

@@ -16,9 +16,53 @@ limitations under the License.
package cli
import (
"github.com/spf13/cobra"
"github.com/oam-dev/kubevela/pkg/utils/common"
)
// constants used in `svc` command
const (
App = "app"
Service = "svc"
Namespace = "namespace"
// FlagDescription command flag to specify the description of the definition
FlagDescription = "desc"
// FlagDryRun command flag to disable actual changes and only display intend changes
FlagDryRun = "dry-run"
// FlagTemplateYAML command flag to specify which existing template YAML file to use
FlagTemplateYAML = "template-yaml"
// FlagOutput command flag to specify which file to save
FlagOutput = "output"
// FlagMessage command flag to specify which file to save
FlagMessage = "message"
// FlagType command flag to specify which definition type to use
FlagType = "type"
// FlagNamespace command flag to specify which namespace to use
FlagNamespace = "namespace"
// FlagInteractive command flag to specify the use of interactive process
FlagInteractive = "interactive"
)
func addNamespaceArg(cmd *cobra.Command) {
cmd.Flags().StringP(Namespace, "n", "", "specify the namespace to use")
}
// GetFlagNamespaceOrEnv will get env and namespace flag, namespace flag takes the priority
func GetFlagNamespaceOrEnv(cmd *cobra.Command, args common.Args) (string, error) {
namespace, err := cmd.Flags().GetString(Namespace)
if err != nil {
return "", err
}
if namespace != "" {
return namespace, nil
}
velaEnv, err := GetFlagEnvOrCurrent(cmd, args)
if err != nil {
return "", err
}
return velaEnv.Namespace, nil
}

View File

@@ -47,22 +47,6 @@ import (
)
const (
// FlagDescription command flag to specify the description of the definition
FlagDescription = "desc"
// FlagDryRun command flag to disable actual changes and only display intend changes
FlagDryRun = "dry-run"
// FlagTemplateYAML command flag to specify which existing template YAML file to use
FlagTemplateYAML = "template-yaml"
// FlagOutput command flag to specify which file to save
FlagOutput = "output"
// FlagMessage command flag to specify which file to save
FlagMessage = "message"
// FlagType command flag to specify which definition type to use
FlagType = "type"
// FlagNamespace command flag to specify which namespace to use
FlagNamespace = "namespace"
// FlagInteractive command flag to specify the use of interactive process
FlagInteractive = "interactive"
// HelmChartNamespacePlaceholder is used as a placeholder for rendering definitions into helm chart format
HelmChartNamespacePlaceholder = "###HELM_NAMESPACE###"
// HelmChartFormatEnvName is the name of the environment variable to enable render helm chart format YAML
@@ -315,7 +299,7 @@ func NewDefinitionGetCommand(c common.Args) *cobra.Command {
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
if err != nil {
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
return errors.Wrapf(err, "failed to get `%s`", Namespace)
}
k8sClient, err := c.GetClient()
if err != nil {
@@ -336,7 +320,7 @@ func NewDefinitionGetCommand(c common.Args) *cobra.Command {
},
}
cmd.Flags().StringP(FlagType, "t", "", "Specify which definition type to get. If empty, all types will be searched. Valid types: "+strings.Join(common2.ValidDefinitionTypes(), ", "))
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, all namespaces will be searched.")
cmd.Flags().StringP(Namespace, "n", "", "Specify which namespace to get. If empty, all namespaces will be searched.")
return cmd
}
@@ -358,7 +342,7 @@ func NewDefinitionListCommand(c common.Args) *cobra.Command {
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
if err != nil {
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
return errors.Wrapf(err, "failed to get `%s`", Namespace)
}
k8sClient, err := c.GetClient()
if err != nil {
@@ -386,7 +370,7 @@ func NewDefinitionListCommand(c common.Args) *cobra.Command {
},
}
cmd.Flags().StringP(FlagType, "t", "", "Specify which definition type to list. If empty, all types will be searched. Valid types: "+strings.Join(common2.ValidDefinitionTypes(), ", "))
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to list. If empty, all namespaces will be searched.")
cmd.Flags().StringP(Namespace, "n", "", "Specify which namespace to list. If empty, all namespaces will be searched.")
return cmd
}
@@ -409,7 +393,7 @@ func NewDefinitionEditCommand(c common.Args) *cobra.Command {
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
if err != nil {
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
return errors.Wrapf(err, "failed to get `%s`", Namespace)
}
k8sClient, err := c.GetClient()
if err != nil {
@@ -470,7 +454,7 @@ func NewDefinitionEditCommand(c common.Args) *cobra.Command {
},
}
cmd.Flags().StringP(FlagType, "t", "", "Specify which definition type to get. If empty, all types will be searched. Valid types: "+strings.Join(common2.ValidDefinitionTypes(), ", "))
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, all namespaces will be searched.")
cmd.Flags().StringP(Namespace, "n", "", "Specify which namespace to get. If empty, all namespaces will be searched.")
return cmd
}
@@ -606,7 +590,7 @@ func NewDefinitionApplyCommand(c common.Args) *cobra.Command {
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
if err != nil {
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
return errors.Wrapf(err, "failed to get `%s`", Namespace)
}
k8sClient, err := c.GetClient()
if err != nil {
@@ -660,7 +644,7 @@ func NewDefinitionApplyCommand(c common.Args) *cobra.Command {
},
}
cmd.Flags().BoolP(FlagDryRun, "", false, "only build definition from CUE into CRB object without applying it to kubernetes clusters")
cmd.Flags().StringP(FlagNamespace, "n", "vela-system", "Specify which namespace to apply.")
cmd.Flags().StringP(Namespace, "n", "vela-system", "Specify which namespace to apply.")
return cmd
}
@@ -680,7 +664,7 @@ func NewDefinitionDelCommand(c common.Args) *cobra.Command {
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
if err != nil {
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
return errors.Wrapf(err, "failed to get `%s`", Namespace)
}
k8sClient, err := c.GetClient()
if err != nil {
@@ -725,7 +709,7 @@ func NewDefinitionDelCommand(c common.Args) *cobra.Command {
},
}
cmd.Flags().StringP(FlagType, "t", "", "Specify the definition type of target. Valid types: "+strings.Join(common2.ValidDefinitionTypes(), ", "))
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace the definition locates.")
cmd.Flags().StringP(Namespace, "n", "", "Specify which namespace the definition locates.")
return cmd
}

View File

@@ -46,17 +46,18 @@ func NewDeleteCommand(c common2.Args, ioStreams cmdutil.IOStreams) *cobra.Comman
cmd.SetOut(ioStreams.Out)
cmd.RunE = func(cmd *cobra.Command, args []string) error {
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
newClient, err := c.GetClient()
if err != nil {
return err
}
o := &common.DeleteOptions{
C: c,
}
o.Client = newClient
o.Env, err = GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
C: c,
Namespace: namespace,
Client: newClient,
}
if len(args) < 1 {
return errors.New("must specify name for the app")
@@ -89,5 +90,6 @@ func NewDeleteCommand(c common2.Args, ioStreams cmdutil.IOStreams) *cobra.Comman
return nil
}
cmd.PersistentFlags().StringP(Service, "", "", "delete only the specified service in this app")
addNamespaceArg(cmd)
return cmd
}

View File

@@ -72,11 +72,11 @@ func NewDryRunCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
velaEnv, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
buff, err := DryRunApplication(o, c, velaEnv.Namespace)
buff, err := DryRunApplication(o, c, namespace)
if err != nil {
return err
}
@@ -87,6 +87,7 @@ func NewDryRunCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command
cmd.Flags().StringVarP(&o.ApplicationFile, "file", "f", "./app.yaml", "application file name")
cmd.Flags().StringVarP(&o.DefinitionFile, "definition", "d", "", "specify a definition file or directory, it will only be used in dry-run rather than applied to K8s cluster")
addNamespaceArg(cmd)
cmd.SetOut(ioStreams.Out)
return cmd
}

View File

@@ -134,6 +134,7 @@ func NewExecCommand(c common.Args, ioStreams util.IOStreams) *cobra.Command {
cmd.Flags().Duration(podRunningTimeoutFlag, defaultPodExecTimeout,
"The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running",
)
cmd.Flags().StringP(Namespace, "n", "", "Specify which namespace to get. If empty, uses namespace in env.")
return cmd
}
@@ -143,12 +144,18 @@ func (o *VelaExecOptions) Init(ctx context.Context, c *cobra.Command, argsIn []s
o.Cmd = c
o.Args = argsIn
env, err := GetFlagEnvOrCurrent(o.Cmd, o.VelaC)
namespace, err := c.Flags().GetString(Namespace)
if err != nil {
return err
return errors.Wrapf(err, "failed to get `%s`", FlagNamespace)
}
o.Env = env
app, err := appfile.LoadApplication(env.Namespace, o.Args[0], o.VelaC)
if namespace == "" {
env, err := GetFlagEnvOrCurrent(o.Cmd, o.VelaC)
if err != nil {
return err
}
namespace = env.Namespace
}
app, err := appfile.LoadApplication(namespace, o.Args[0], o.VelaC)
if err != nil {
return err
}

View File

@@ -37,15 +37,14 @@ func NewExportCommand(c common2.Args, ioStream cmdutil.IOStreams) *cobra.Command
types.TagCommandType: types.TypeStart,
},
RunE: func(cmd *cobra.Command, args []string) error {
velaEnv, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
o := &common.AppfileOptions{
IO: ioStream,
Env: velaEnv,
IO: ioStream,
}
_, data, err := o.Export(*appFilePath, velaEnv.Namespace, true, c)
_, data, err := o.Export(*appFilePath, namespace, true, c)
if err != nil {
return err
}
@@ -55,6 +54,7 @@ func NewExportCommand(c common2.Args, ioStream cmdutil.IOStreams) *cobra.Command
}
cmd.SetOut(ioStream.Out)
addNamespaceArg(cmd)
cmd.Flags().StringVarP(appFilePath, "file", "f", "", "specify file path for appfile")
return cmd
}

View File

@@ -26,15 +26,15 @@ import (
"cuelang.org/go/cue"
"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
"github.com/oam-dev/kubevela/apis/types"
common2 "github.com/oam-dev/kubevela/pkg/utils/common"
"github.com/oam-dev/kubevela/pkg/utils/env"
cmdutil "github.com/oam-dev/kubevela/pkg/utils/util"
"github.com/oam-dev/kubevela/references/appfile"
"github.com/oam-dev/kubevela/references/appfile/api"
@@ -45,8 +45,8 @@ import (
type appInitOptions struct {
client client.Client
cmdutil.IOStreams
Env *types.EnvMeta
c common2.Args
Namespace string
c common2.Args
app *api.Application
appName string
@@ -68,15 +68,17 @@ func NewInitCommand(c common2.Args, ioStreams cmdutil.IOStreams) *cobra.Command
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
var err error
o.Namespace, err = GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
newClient, err := c.GetClient()
if err != nil {
return err
}
o.client = newClient
o.Env, err = GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
o.IOStreams.Info("Welcome to use KubeVela CLI! Please describe your application.")
o.IOStreams.Info()
if err = o.CheckEnv(); err != nil {
@@ -108,24 +110,25 @@ func NewInitCommand(c common2.Args, ioStreams cmdutil.IOStreams) *cobra.Command
}
ctx := context.Background()
err = common.BuildRun(ctx, o.app, o.client, o.Env, o.IOStreams)
err = common.BuildRun(ctx, o.app, o.client, o.Namespace, o.IOStreams)
if err != nil {
return err
}
deployStatus, err := printTrackingDeployStatus(c, o.IOStreams, o.appName, o.Env)
deployStatus, err := printTrackingDeployStatus(c, o.IOStreams, o.appName, o.Namespace)
if err != nil {
return err
}
if deployStatus != compStatusDeployed {
return nil
}
return printAppStatus(context.Background(), newClient, ioStreams, o.appName, o.Env, cmd, c)
return printAppStatus(context.Background(), newClient, ioStreams, o.appName, o.Namespace, cmd, c)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeStart,
},
}
cmd.Flags().BoolVar(&o.renderOnly, "render-only", false, "Rendering vela.yaml in current dir and do not deploy")
addNamespaceArg(cmd)
cmd.SetOut(ioStreams.Out)
return cmd
}
@@ -144,11 +147,22 @@ func (o *appInitOptions) Naming() error {
// CheckEnv checks environment, e.g., domain and email.
func (o *appInitOptions) CheckEnv() error {
if o.Env.Namespace == "" {
o.Env.Namespace = "default"
if o.Namespace == "" {
o.Namespace = "default"
}
if err := env.CreateEnv(o.Env.Name, o.Env); err != nil {
return errors.Wrap(err, "app init create namespace err")
var ns v1.Namespace
ctx := context.Background()
err := o.client.Get(ctx, client.ObjectKey{
Name: o.Namespace,
}, &ns)
if apierrors.IsNotFound(err) {
ns.Name = o.Namespace
err = o.client.Create(ctx, &ns)
if err != nil {
return err
}
} else if err != nil {
return err
}
return nil
}
@@ -181,7 +195,7 @@ func formatAndGetUsage(p *types.Parameter) string {
// Workload asks user to choose workload type from installed workloads
func (o *appInitOptions) Workload() error {
workloads, err := plugins.LoadInstalledCapabilityWithType(o.Env.Namespace, o.c, types.TypeComponentDefinition)
workloads, err := plugins.LoadInstalledCapabilityWithType(o.Namespace, o.c, types.TypeComponentDefinition)
if err != nil {
return err
}
@@ -303,7 +317,7 @@ func (o *appInitOptions) Workload() error {
// other type not supported
}
}
o.app, err = common.BaseComplete(o.Env, o.c, o.workloadName, o.appName, fs, o.workloadType)
o.app, err = common.BaseComplete(o.Namespace, o.c, o.workloadName, o.appName, fs, o.workloadType)
return err
}

View File

@@ -73,11 +73,11 @@ func NewLiveDiffCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
velaEnv, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
buff, err := LiveDiffApplication(o, c, velaEnv.Namespace)
buff, err := LiveDiffApplication(o, c, namespace)
if err != nil {
return err
}
@@ -90,6 +90,7 @@ func NewLiveDiffCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
cmd.Flags().StringVarP(&o.DefinitionFile, "definition", "d", "", "specify a file or directory containing capability definitions, they will only be used in dry-run rather than applied to K8s cluster")
cmd.Flags().StringVarP(&o.Revision, "Revision", "r", "", "specify an application Revision name, by default, it will compare with the latest Revision")
cmd.Flags().IntVarP(&o.Context, "context", "c", -1, "output number lines of context around changes, by default show all unchanged lines")
addNamespaceArg(cmd)
cmd.SetOut(ioStreams.Out)
return cmd
}

View File

@@ -44,28 +44,21 @@ func NewListCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
newClient, err := c.GetClient()
if err != nil {
return err
}
namespace, err := cmd.Flags().GetString(Namespace)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if namespace == "" {
namespace = env.Namespace
}
return printApplicationList(ctx, newClient, namespace, ioStreams)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeApp,
},
}
cmd.PersistentFlags().StringP(Namespace, "n", "", "specify the namespace the application want to list, default is the current env namespace")
addNamespaceArg(cmd)
return cmd
}

View File

@@ -58,10 +58,6 @@ func newTrackingSpinnerWithDelay(suffix string, interval time.Duration) *spinner
spinner.WithSuffix(suffixColor.Sprintf(" %s", suffix)))
}
func newTrackingSpinner(suffix string) *spinner.Spinner {
return newTrackingSpinnerWithDelay(suffix, 500*time.Millisecond)
}
func applySpinnerNewSuffix(s *spinner.Spinner, suffix string) {
suffixColor := color.New(color.Bold, color.FgGreen)
s.Suffix = suffixColor.Sprintf(" %s", suffix)

View File

@@ -74,14 +74,14 @@ func NewCapabilityShowCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra
}
ctx := context.Background()
capabilityName := args[0]
velaEnv, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if webSite {
return startReferenceDocsSite(ctx, velaEnv.Namespace, c, ioStreams, capabilityName)
return startReferenceDocsSite(ctx, namespace, c, ioStreams, capabilityName)
}
return ShowReferenceConsole(ctx, c, ioStreams, capabilityName, velaEnv.Namespace)
return ShowReferenceConsole(ctx, c, ioStreams, capabilityName, namespace)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeStart,
@@ -89,6 +89,7 @@ func NewCapabilityShowCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra
}
cmd.Flags().BoolVarP(&webSite, "web", "", false, " start web doc site")
addNamespaceArg(cmd)
cmd.SetOut(ioStreams.Out)
return cmd
}

View File

@@ -18,7 +18,6 @@ package cli
import (
"context"
"fmt"
"os"
"strings"
"time"
@@ -32,11 +31,9 @@ import (
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/oam/util"
"github.com/oam-dev/kubevela/pkg/utils/common"
cmdutil "github.com/oam-dev/kubevela/pkg/utils/util"
"github.com/oam-dev/kubevela/references/appfile"
"github.com/oam-dev/kubevela/references/appfile/api"
)
// HealthStatus represents health status strings.
@@ -70,22 +67,17 @@ const (
compStatusDeploying CompStatus = iota
compStatusDeployFail
compStatusDeployed
compStatusHealthChecking
compStatusHealthCheckDone
compStatusUnknown
)
// Error msg used in `status` command
const (
ErrNotLoadAppConfig = "cannot load the application"
ErrFmtNotInitialized = "service: %s not ready"
ErrServiceNotFound = "service %s not found in app"
ErrNotLoadAppConfig = "cannot load the application"
)
const (
trackingInterval time.Duration = 1 * time.Second
deployTimeout time.Duration = 10 * time.Second
healthCheckBufferTime time.Duration = 120 * time.Second
trackingInterval time.Duration = 1 * time.Second
deployTimeout time.Duration = 10 * time.Second
)
// NewAppStatusCommand creates `status` command for showing status
@@ -100,38 +92,37 @@ func NewAppStatusCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Comm
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
argsLength := len(args)
if argsLength == 0 {
ioStreams.Errorf("Hint: please specify an application")
os.Exit(1)
}
appName := args[0]
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
ioStreams.Errorf("Error: failed to get Env: %s", err)
return err
}
newClient, err := c.GetClient()
if err != nil {
return err
}
return printAppStatus(ctx, newClient, ioStreams, appName, env, cmd, c)
return printAppStatus(ctx, newClient, ioStreams, appName, namespace, cmd, c)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeApp,
},
}
cmd.Flags().StringP("svc", "s", "", "service name")
addNamespaceArg(cmd)
cmd.SetOut(ioStreams.Out)
return cmd
}
func printAppStatus(ctx context.Context, c client.Client, ioStreams cmdutil.IOStreams, appName string, env *types.EnvMeta, cmd *cobra.Command, velaC common.Args) error {
app, err := appfile.LoadApplication(env.Namespace, appName, velaC)
func printAppStatus(_ context.Context, c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string, cmd *cobra.Command, velaC common.Args) error {
app, err := appfile.LoadApplication(namespace, appName, velaC)
if err != nil {
return err
}
namespace := env.Namespace
cmd.Printf("About:\n\n")
table := newUITable()
@@ -141,7 +132,7 @@ func printAppStatus(ctx context.Context, c client.Client, ioStreams cmdutil.IOSt
cmd.Printf("%s\n\n", table.String())
cmd.Printf("Services:\n\n")
return loopCheckStatus(ctx, c, ioStreams, appName, env)
return loopCheckStatus(c, ioStreams, appName, namespace)
}
func loadRemoteApplication(c client.Client, ns string, name string) (*v1beta1.Application, error) {
@@ -153,35 +144,41 @@ func loadRemoteApplication(c client.Client, ns string, name string) (*v1beta1.Ap
return app, err
}
func loopCheckStatus(ctx context.Context, c client.Client, ioStreams cmdutil.IOStreams, appName string, env *types.EnvMeta) error {
remoteApp, err := loadRemoteApplication(c, env.Namespace, appName)
func getComponentType(app *v1beta1.Application, name string) string {
for _, c := range app.Spec.Components {
if c.Name == name {
return c.Type
}
}
return "webservice"
}
func loopCheckStatus(c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string) error {
remoteApp, err := loadRemoteApplication(c, namespace, appName)
if err != nil {
return err
}
for _, comp := range remoteApp.Spec.Components {
for _, comp := range remoteApp.Status.Services {
compName := comp.Name
healthStatus, healthInfo, err := healthCheckLoop(ctx, c, compName, appName, env)
if err != nil {
ioStreams.Info(healthInfo)
return err
ioStreams.Infof(white.Sprintf(" - Name: %s Env: %s\n", compName, comp.Env))
ioStreams.Infof(" Type: %s\n", getComponentType(remoteApp, compName))
healthColor := getHealthStatusColor(comp.Healthy)
healthInfo := strings.ReplaceAll(comp.Message, "\n", "\n\t") // format healthInfo output
healthstats := "healthy"
if !comp.Healthy {
healthstats = "unhealthy"
}
ioStreams.Infof(white.Sprintf(" - Name: %s\n", compName))
ioStreams.Infof(" Type: %s\n", comp.Type)
healthColor := getHealthStatusColor(healthStatus)
healthInfo = strings.ReplaceAll(healthInfo, "\n", "\n\t") // format healthInfo output
ioStreams.Infof(" %s %s\n", healthColor.Sprint(healthStatus), healthColor.Sprint(healthInfo))
ioStreams.Infof(" %s %s\n", healthColor.Sprint(healthstats), healthColor.Sprint(healthInfo))
// load it again after health check
remoteApp, err = loadRemoteApplication(c, env.Namespace, appName)
remoteApp, err = loadRemoteApplication(c, namespace, appName)
if err != nil {
return err
}
// workload Must found
ioStreams.Infof(" Traits:\n")
workloadStatus, _ := getWorkloadStatusFromApp(remoteApp, compName)
for _, tr := range workloadStatus.Traits {
for _, tr := range comp.Traits {
if tr.Message != "" {
if tr.Healthy {
ioStreams.Infof(" - %s%s: %s", emojiSucceed, white.Sprint(tr.Type), tr.Message)
@@ -190,58 +187,20 @@ func loopCheckStatus(ctx context.Context, c client.Client, ioStreams cmdutil.IOS
}
continue
}
var message string
for _, v := range comp.Traits {
if v.Type == tr.Type {
traitData, _ := util.RawExtension2Map(v.Properties)
for k, v := range traitData {
message += fmt.Sprintf("%v=%v\n\t\t", k, v)
}
break
}
}
ioStreams.Infof(" - %s%s: %s", emojiSucceed, white.Sprint(tr.Type), message)
}
ioStreams.Info("")
ioStreams.Infof(" Last Deployment:\n")
ioStreams.Infof(" Created at: %v\n", remoteApp.CreationTimestamp)
}
return nil
}
func healthCheckLoop(ctx context.Context, c client.Client, compName, appName string, env *types.EnvMeta) (HealthStatus, string, error) {
// Health Check Loop For Workload
var healthInfo string
var healthStatus HealthStatus
var err error
sHealthCheck := newTrackingSpinner("Checking health status ...")
sHealthCheck.Start()
defer sHealthCheck.Stop()
HealthCheckLoop:
for {
time.Sleep(trackingInterval)
var healthcheckStatus CompStatus
healthcheckStatus, healthStatus, healthInfo, err = trackHealthCheckingStatus(ctx, c, compName, appName, env)
if err != nil {
healthInfo = red.Sprintf("Health checking failed!")
return "", healthInfo, err
}
if healthcheckStatus == compStatusHealthCheckDone {
break HealthCheckLoop
}
}
return healthStatus, healthInfo, nil
}
func printTrackingDeployStatus(c common.Args, ioStreams cmdutil.IOStreams, appName string, env *types.EnvMeta) (CompStatus, error) {
func printTrackingDeployStatus(c common.Args, ioStreams cmdutil.IOStreams, appName string, namespace string) (CompStatus, error) {
sDeploy := newTrackingSpinnerWithDelay("Checking Status ...", trackingInterval)
sDeploy.Start()
defer sDeploy.Stop()
TrackDeployLoop:
for {
time.Sleep(trackingInterval)
deployStatus, failMsg, err := TrackDeployStatus(c, appName, env)
deployStatus, failMsg, err := TrackDeployStatus(c, appName, namespace)
if err != nil {
return compStatusUnknown, err
}
@@ -263,8 +222,8 @@ TrackDeployLoop:
}
// TrackDeployStatus will only check AppConfig is deployed successfully,
func TrackDeployStatus(c common.Args, appName string, env *types.EnvMeta) (CompStatus, string, error) {
appObj, err := appfile.LoadApplication(env.Namespace, appName, c)
func TrackDeployStatus(c common.Args, appName string, namespace string) (CompStatus, string, error) {
appObj, err := appfile.LoadApplication(namespace, appName, c)
if err != nil {
return compStatusUnknown, "", err
}
@@ -289,86 +248,9 @@ func TrackDeployStatus(c common.Args, appName string, env *types.EnvMeta) (CompS
return compStatusDeploying, "", nil
}
// trackHealthCheckingStatus will check health status from health scope
func trackHealthCheckingStatus(ctx context.Context, c client.Client, compName, appName string, env *types.EnvMeta) (CompStatus, HealthStatus, string, error) {
app, err := loadRemoteApplication(c, env.Namespace, appName)
if err != nil {
return compStatusUnknown, HealthStatusNotDiagnosed, "", err
func getHealthStatusColor(s bool) *color.Color {
if s {
return green
}
if len(app.Status.Conditions) < 1 {
// still reconciling
return compStatusUnknown, HealthStatusUnknown, "", nil
}
// check whether referenced a HealthScope
var healthScopeName string
for _, v := range app.Spec.Components {
if len(v.Scopes) > 0 {
healthScopeName = v.Scopes[api.DefaultHealthScopeKey]
}
}
var healthStatus HealthStatus
if healthScopeName != "" {
var healthScope v1alpha2.HealthScope
if err = c.Get(ctx, client.ObjectKey{Namespace: env.Namespace, Name: healthScopeName}, &healthScope); err != nil {
return compStatusUnknown, HealthStatusUnknown, "", err
}
var wlhc *v1alpha2.WorkloadHealthCondition
for _, v := range healthScope.Status.WorkloadHealthConditions {
if v.ComponentName == compName {
wlhc = v
}
}
if wlhc == nil {
cTime := app.GetCreationTimestamp()
if time.Since(cTime.Time) <= deployTimeout {
return compStatusHealthChecking, HealthStatusUnknown, "", nil
}
if len(healthScope.Spec.AppRefs) == 0 && len(healthScope.Spec.WorkloadReferences) == 0 {
return compStatusHealthCheckDone, HealthStatusHealthy, "no workload or app found in health scope", nil
}
return compStatusUnknown, HealthStatusUnknown, "", fmt.Errorf("cannot get health condition from the health scope: %s", healthScope.Name)
}
healthStatus = wlhc.HealthStatus
if healthStatus == HealthStatusHealthy {
return compStatusHealthCheckDone, healthStatus, wlhc.Diagnosis, nil
}
if healthStatus == HealthStatusUnhealthy {
cTime := app.GetCreationTimestamp()
if time.Since(cTime.Time) <= healthCheckBufferTime {
return compStatusHealthChecking, HealthStatusUnknown, "", nil
}
return compStatusHealthCheckDone, healthStatus, wlhc.Diagnosis, nil
}
}
return compStatusHealthCheckDone, HealthStatusNotDiagnosed, "", nil
}
func getWorkloadStatusFromApp(app *v1beta1.Application, compName string) (commontypes.ApplicationComponentStatus, bool) {
foundWlStatus := false
wlStatus := commontypes.ApplicationComponentStatus{}
if app == nil {
return wlStatus, foundWlStatus
}
for _, v := range app.Status.Services {
if v.Name == compName {
wlStatus = v
foundWlStatus = true
break
}
}
return wlStatus, foundWlStatus
}
func getHealthStatusColor(s HealthStatus) *color.Color {
var c *color.Color
switch s {
case HealthStatusHealthy:
c = green
case HealthStatusUnknown, HealthStatusNotDiagnosed:
c = yellow
default:
c = red
}
return c
return yellow
}

View File

@@ -46,7 +46,7 @@ func NewUpCommand(c common2.Args, ioStream cmdutil.IOStreams) *cobra.Command {
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
velaEnv, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
@@ -70,16 +70,17 @@ func NewUpCommand(c common2.Args, ioStream cmdutil.IOStreams) *cobra.Command {
}
} else {
o := &common.AppfileOptions{
Kubecli: kubecli,
IO: ioStream,
Env: velaEnv,
Kubecli: kubecli,
IO: ioStream,
Namespace: namespace,
}
return o.Run(*appFilePath, velaEnv.Namespace, c)
return o.Run(*appFilePath, o.Namespace, c)
}
return nil
},
}
cmd.SetOut(ioStream.Out)
cmd.Flags().StringVarP(appFilePath, "file", "f", "", "specify file path for appfile")
addNamespaceArg(cmd)
return cmd
}

View File

@@ -25,7 +25,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/apis/types"
common2 "github.com/oam-dev/kubevela/pkg/utils/common"
"github.com/oam-dev/kubevela/pkg/utils/util"
"github.com/oam-dev/kubevela/references/common"
@@ -33,13 +32,10 @@ import (
func TestUp(t *testing.T) {
ioStream := util.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}
env := types.EnvMeta{
Name: "up",
Namespace: "env-up",
}
namespace := "up-ns"
o := common.AppfileOptions{
IO: ioStream,
Env: &env,
IO: ioStream,
Namespace: namespace,
}
app := &v1beta1.Application{}
app.Name = "app-up"

View File

@@ -60,17 +60,10 @@ func NewWorkflowSuspendCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra
if len(args) < 1 {
return fmt.Errorf("must specify application name")
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if namespace == "" {
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
namespace = env.Namespace
}
app, err := appfile.LoadApplication(namespace, args[0], c)
if err != nil {
return err
@@ -93,7 +86,7 @@ func NewWorkflowSuspendCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra
return nil
},
}
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, uses namespace in env.")
addNamespaceArg(cmd)
return cmd
}
@@ -108,17 +101,10 @@ func NewWorkflowResumeCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra.
if len(args) < 1 {
return fmt.Errorf("must specify application name")
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if namespace == "" {
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
namespace = env.Namespace
}
app, err := appfile.LoadApplication(namespace, args[0], c)
if err != nil {
return err
@@ -151,7 +137,7 @@ func NewWorkflowResumeCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra.
return nil
},
}
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, uses namespace in env.")
addNamespaceArg(cmd)
return cmd
}
@@ -166,17 +152,10 @@ func NewWorkflowTerminateCommand(c common.Args, ioStream cmdutil.IOStreams) *cob
if len(args) < 1 {
return fmt.Errorf("must specify application name")
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if namespace == "" {
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
namespace = env.Namespace
}
app, err := appfile.LoadApplication(namespace, args[0], c)
if err != nil {
return err
@@ -199,7 +178,7 @@ func NewWorkflowTerminateCommand(c common.Args, ioStream cmdutil.IOStreams) *cob
return nil
},
}
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, uses namespace in env.")
addNamespaceArg(cmd)
return cmd
}
@@ -214,17 +193,10 @@ func NewWorkflowRestartCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra
if len(args) < 1 {
return fmt.Errorf("must specify application name")
}
namespace, err := cmd.Flags().GetString(FlagNamespace)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
if namespace == "" {
env, err := GetFlagEnvOrCurrent(cmd, c)
if err != nil {
return err
}
namespace = env.Namespace
}
app, err := appfile.LoadApplication(namespace, args[0], c)
if err != nil {
return err
@@ -247,7 +219,7 @@ func NewWorkflowRestartCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra
return nil
},
}
cmd.Flags().StringP(FlagNamespace, "n", "", "Specify which namespace to get. If empty, uses namespace in env.")
addNamespaceArg(cmd)
return cmd
}

View File

@@ -38,17 +38,18 @@ func NewWorkloadsCommand(c common2.Args, ioStreams cmdutil.IOStreams) *cobra.Com
return c.SetConfig()
},
RunE: func(cmd *cobra.Command, args []string) error {
env, err := GetFlagEnvOrCurrent(cmd, c)
namespace, err := GetFlagNamespaceOrEnv(cmd, c)
if err != nil {
return err
}
return printWorkloadList(env.Namespace, c, ioStreams)
return printWorkloadList(namespace, c, ioStreams)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeCap,
},
}
cmd.SetOut(ioStreams.Out)
addNamespaceArg(cmd)
return cmd
}

View File

@@ -63,9 +63,9 @@ type applicationMetaList []apis.ApplicationMeta
// AppfileOptions is some configuration that modify options for an Appfile
type AppfileOptions struct {
Kubecli client.Client
IO cmdutil.IOStreams
Env *types.EnvMeta
Kubecli client.Client
IO cmdutil.IOStreams
Namespace string
}
// BuildResult is the export struct from AppFile yaml or AppFile object
@@ -105,11 +105,11 @@ type Option struct {
// DeleteOptions is options for delete
type DeleteOptions struct {
AppName string
CompName string
Client client.Client
Env *types.EnvMeta
C common.Args
Namespace string
AppName string
CompName string
Client client.Client
C common.Args
}
// ListApplications lists all applications
@@ -211,7 +211,7 @@ func RetrieveApplicationStatusByName(ctx context.Context, c client.Reader, appli
func (o *DeleteOptions) DeleteApp() (string, error) {
ctx := context.Background()
var app = new(corev1beta1.Application)
err := o.Client.Get(ctx, client.ObjectKey{Name: o.AppName, Namespace: o.Env.Namespace}, app)
err := o.Client.Get(ctx, client.ObjectKey{Name: o.AppName, Namespace: o.Namespace}, app)
if err != nil {
if apierrors.IsNotFound(err) {
return fmt.Sprintf("app \"%s\" already deleted", o.AppName), nil
@@ -228,7 +228,7 @@ func (o *DeleteOptions) DeleteApp() (string, error) {
healthScopeName, ok := cmp.Scopes[api.DefaultHealthScopeKey]
if ok {
var healthScope corev1alpha2.HealthScope
if err := o.Client.Get(ctx, client.ObjectKey{Namespace: o.Env.Namespace, Name: healthScopeName}, &healthScope); err != nil {
if err := o.Client.Get(ctx, client.ObjectKey{Namespace: o.Namespace, Name: healthScopeName}, &healthScope); err != nil {
if apierrors.IsNotFound(err) {
continue
}
@@ -239,7 +239,7 @@ func (o *DeleteOptions) DeleteApp() (string, error) {
}
}
}
return fmt.Sprintf("app \"%s\" deleted from env \"%s\"", o.AppName, o.Env.Name), nil
return fmt.Sprintf("app \"%s\" already deleted from namespace \"%s\"", o.AppName, o.Namespace), nil
}
// DeleteComponent will delete one component including server side.
@@ -248,7 +248,7 @@ func (o *DeleteOptions) DeleteComponent(io cmdutil.IOStreams) (string, error) {
if o.AppName == "" {
return "", errors.New("app name is required")
}
app, err := appfile.LoadApplication(o.Env.Namespace, o.AppName, o.C)
app, err := appfile.LoadApplication(o.Namespace, o.AppName, o.C)
if err != nil {
return "", err
}
@@ -371,7 +371,7 @@ func (o *AppfileOptions) ExportFromAppFile(app *api.AppFile, namespace string, q
appHandler := appfile.NewApplication(app, tm)
// new
retApplication, scopes, err := appHandler.BuildOAMApplication(o.Env, o.IO, appHandler.Tm, quiet)
retApplication, scopes, err := appHandler.BuildOAMApplication(o.Namespace, o.IO, appHandler.Tm, quiet)
if err != nil {
return nil, nil, err
}
@@ -441,7 +441,7 @@ func (o *AppfileOptions) Run(filePath, namespace string, c common.Args) error {
// BaseAppFileRun starts an application according to Appfile
func (o *AppfileOptions) BaseAppFileRun(result *BuildResult, args common.Args) error {
kubernetesComponent, err := appfile.ApplyTerraform(result.application, o.Kubecli, o.IO, o.Env.Namespace, args)
kubernetesComponent, err := appfile.ApplyTerraform(result.application, o.Kubecli, o.IO, o.Namespace, args)
if err != nil {
return err
}

View File

@@ -21,15 +21,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/utils/util"
"github.com/oam-dev/kubevela/references/appfile"
"github.com/oam-dev/kubevela/references/appfile/api"
)
// BuildRun will build application and deploy from Appfile
func BuildRun(ctx context.Context, app *api.Application, client client.Client, env *types.EnvMeta, io util.IOStreams) error {
o, scopes, err := app.BuildOAMApplication(env, io, app.Tm, true)
func BuildRun(ctx context.Context, app *api.Application, client client.Client, namespace string, io util.IOStreams) error {
o, scopes, err := app.BuildOAMApplication(namespace, io, app.Tm, true)
if err != nil {
return err
}

View File

@@ -25,28 +25,14 @@ import (
"cuelang.org/go/cue"
"github.com/spf13/pflag"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/utils/util"
"github.com/oam-dev/kubevela/references/appfile"
"github.com/oam-dev/kubevela/references/appfile/api"
"github.com/oam-dev/kubevela/references/plugins"
)
// RunOptions include all options for run
type RunOptions struct {
Env *types.EnvMeta
WorkloadName string
KubeClient client.Client
App *api.Application
AppName string
Staging bool
util.IOStreams
}
// InitApplication will load Application from cluster
func InitApplication(env *types.EnvMeta, c common.Args, workloadName string, appGroup string) (*api.Application, error) {
func InitApplication(namespace string, c common.Args, workloadName string, appGroup string) (*api.Application, error) {
var appName string
if appGroup != "" {
appName = appGroup
@@ -56,7 +42,7 @@ func InitApplication(env *types.EnvMeta, c common.Args, workloadName string, app
// TODO(wonderflow): we should load the existing application from cluster and convert to appfile
// app, err := appfile.LoadApplication(env.Namespace, appName, c)
// compatible application not found
app, err := appfile.NewEmptyApplication(env.Namespace, c)
app, err := appfile.NewEmptyApplication(namespace, c)
if err != nil {
return nil, err
}
@@ -66,8 +52,8 @@ func InitApplication(env *types.EnvMeta, c common.Args, workloadName string, app
}
// BaseComplete will construct an Application from cli parameters.
func BaseComplete(env *types.EnvMeta, c common.Args, workloadName string, appName string, flagSet *pflag.FlagSet, workloadType string) (*api.Application, error) {
app, err := InitApplication(env, c, workloadName, appName)
func BaseComplete(namespace string, c common.Args, workloadName string, appName string, flagSet *pflag.FlagSet, workloadType string) (*api.Application, error) {
app, err := InitApplication(namespace, c, workloadName, appName)
if err != nil {
return nil, err
}
@@ -79,7 +65,7 @@ func BaseComplete(env *types.EnvMeta, c common.Args, workloadName string, appNam
// Not exist
tp = workloadType
}
template, err := plugins.LoadCapabilityByName(tp, env.Namespace, c)
template, err := plugins.LoadCapabilityByName(tp, namespace, c)
if err != nil {
return nil, err
}

Some files were not shown because too many files have changed in this diff Show More