github.com/oam-dev/kubevela@v1.9.11/e2e/addon/mock/testdata/fluxcd/definitions/helm-release-def.yaml (about) 1 apiVersion: core.oam.dev/v1beta1 2 kind: ComponentDefinition 3 metadata: 4 name: helm 5 namespace: vela-system 6 annotations: 7 definition.oam.dev/description: "helm release is a group of K8s resources from either git repository or helm repo" 8 spec: 9 workload: 10 type: autodetects.core.oam.dev 11 schematic: 12 cue: 13 template: | 14 output: { 15 apiVersion: "source.toolkit.fluxcd.io/v1beta1" 16 metadata: { 17 name: context.name 18 } 19 if parameter.repoType == "git" { 20 kind: "GitRepository" 21 spec: { 22 url: parameter.url 23 if parameter.git.branch != _|_ { 24 ref: branch: parameter.git.branch 25 } 26 _secret 27 _sourceCommonArgs 28 } 29 } 30 if parameter.repoType == "oss" { 31 kind: "Bucket" 32 spec: { 33 endpoint: parameter.url 34 bucketName: parameter.oss.bucketName 35 provider: parameter.oss.provider 36 if parameter.oss.region != _|_ { 37 region: parameter.oss.region 38 } 39 _secret 40 _sourceCommonArgs 41 } 42 } 43 if parameter.repoType == "helm" { 44 kind: "HelmRepository" 45 spec: { 46 url: parameter.url 47 _secret 48 _sourceCommonArgs 49 } 50 } 51 } 52 53 outputs: release: { 54 apiVersion: "helm.toolkit.fluxcd.io/v2beta1" 55 kind: "HelmRelease" 56 metadata: { 57 name: context.name 58 } 59 spec: { 60 timeout: parameter.installTimeout 61 interval: parameter.pullInterval 62 chart: { 63 spec: { 64 chart: parameter.chart 65 version: parameter.version 66 sourceRef: { 67 if parameter.repoType == "git" { 68 kind: "GitRepository" 69 } 70 if parameter.repoType == "helm" { 71 kind: "HelmRepository" 72 } 73 if parameter.repoType == "oss" { 74 kind: "Bucket" 75 } 76 name: context.name 77 namespace: context.namespace 78 } 79 interval: parameter.pullInterval 80 } 81 } 82 if parameter.targetNamespace != _|_ { 83 targetNamespace: parameter.targetNamespace 84 } 85 if parameter.releaseName != _|_ { 86 releaseName: parameter.releaseName 87 } 88 if parameter.values != _|_ { 89 values: parameter.values 90 } 91 } 92 } 93 94 _secret: { 95 if parameter.secretRef != _|_ { 96 secretRef: { 97 name: parameter.secretRef 98 } 99 } 100 } 101 102 _sourceCommonArgs: { 103 interval: parameter.pullInterval 104 if parameter.timeout != _|_ { 105 timeout: parameter.timeout 106 } 107 } 108 109 parameter: { 110 repoType: *"helm" | "git" | "oss" 111 // +usage=The interval at which to check for repository/bucket and relese updates, default to 5m 112 pullInterval: *"5m" | string 113 // +usage=The Git or Helm repository URL, OSS endpoint, accept HTTP/S or SSH address as git url, 114 url: string 115 // +usage=The name of the secret containing authentication credentials 116 secretRef?: string 117 // +usage=The timeout for operations like download index/clone repository, optional 118 timeout?: string 119 // +usage=The timeout for operation `helm install`, optional 120 installTimeout: *"10m" | string 121 122 git?: { 123 // +usage=The Git reference to checkout and monitor for changes, defaults to master branch 124 branch: string 125 } 126 oss?: { 127 // +usage=The bucket's name, required if repoType is oss 128 bucketName: string 129 // +usage="generic" for Minio, Amazon S3, Google Cloud Storage, Alibaba Cloud OSS, "aws" for retrieve credentials from the EC2 service when credentials not specified, default "generic" 130 provider: *"generic" | "aws" 131 // +usage=The bucket region, optional 132 region?: string 133 } 134 135 // +usage=1.The relative path to helm chart for git/oss source. 2. chart name for helm resource 3. relative path for chart package(e.g. ./charts/podinfo-1.2.3.tgz) 136 chart: string 137 // +usage=Chart version 138 version: *"*" | string 139 // +usage=The namespace for helm chart, optional 140 targetNamespace?: string 141 // +usage=The release name 142 releaseName?: string 143 // +usage=Chart values 144 values?: #nestedmap 145 } 146 147 #nestedmap: { 148 ... 149 } 150 status: 151 # helmRelease's `ready` condition must be the first one 152 healthPolicy: 'isHealth: len(context.outputs.release.status.conditions) != 0 && context.outputs.release.status.conditions[0]["status"]=="True"' 153 customStatus: |- 154 repoMessage: string 155 releaseMessage: string 156 if context.output.status == _|_ { 157 repoMessage: "Fetching repository" 158 releaseMessage: "Wating repository ready" 159 } 160 if context.output.status != _|_ { 161 repoStatus: context.output.status 162 if repoStatus.conditions[0]["type"] != "Ready" { 163 repoMessage: "Fetch repository fail" 164 } 165 if repoStatus.conditions[0]["type"] == "Ready" { 166 repoMessage: "Fetch repository successfully" 167 } 168 169 if context.outputs.release.status == _|_ { 170 releaseMessage: "Creating helm release" 171 } 172 if context.outputs.release.status != _|_ { 173 if context.outputs.release.status.conditions[0]["message"] == "Release reconciliation succeeded" { 174 releaseMessage: "Create helm release successfully" 175 } 176 if context.outputs.release.status.conditions[0]["message"] != "Release reconciliation succeeded" { 177 releaseMessage: "Create helm release fail, message: " + context.outputs.release.status.conditions[0]["message"] 178 } 179 } 180 181 } 182 message: repoMessage + ", " + releaseMessage