mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-04 19:21:24 -03:00
add s3 too
This commit is contained in:
@@ -5,7 +5,7 @@ release:
|
||||
name: test-release-name
|
||||
namespace: test-release-namespace
|
||||
tests:
|
||||
- it: should generate correct spec with provided provider and credential
|
||||
- it: should generate correct spec with aws provider and credential
|
||||
set:
|
||||
volumeSnapshotLocation:
|
||||
- enabled: true
|
||||
@@ -31,6 +31,32 @@ tests:
|
||||
name: vsl-test-release-name-common-test-my-snap1
|
||||
key: cloud
|
||||
|
||||
- it: should generate correct spec with s3 provider and credential
|
||||
set:
|
||||
volumeSnapshotLocation:
|
||||
- enabled: true
|
||||
name: my-snap1
|
||||
provider: s3
|
||||
credential:
|
||||
s3:
|
||||
id: my-id
|
||||
key: my-key
|
||||
asserts:
|
||||
- documentIndex: &volSnapLocDoc 1
|
||||
isKind:
|
||||
of: VolumeSnapshotLocation
|
||||
- documentIndex: *volSnapLocDoc
|
||||
isAPIVersion:
|
||||
of: velero.io/v1
|
||||
- documentIndex: *volSnapLocDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
provider: velero.io/aws
|
||||
credential:
|
||||
name: vsl-test-release-name-common-test-my-snap1
|
||||
key: cloud
|
||||
|
||||
- it: should generate correct spec with provided provider and credential
|
||||
set:
|
||||
volumeSnapshotLocation:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{{- define "tc.v1.common.lib.velero.provider.secret" -}}
|
||||
{{- $rootCtx := .rootCtx }}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $prefix := .prefix -}}
|
||||
|
||||
{{- $creds := "" -}} {{/* We can add additinal providers here, and only create the template for the data */}}
|
||||
{{- $creds := "" -}}
|
||||
|
||||
{{/* Make sure provider is a string */}}
|
||||
{{- $provider := $objectData.provider | toString -}}
|
||||
@@ -11,12 +12,16 @@
|
||||
{{- $creds = (include "tc.v1.common.lib.velero.provider.aws.secret" (dict "creds" $objectData.credential.aws) | fromYaml).data -}}
|
||||
{{/* Map provider */}}
|
||||
{{- $_ := set $objectData "provider" "velero.io/aws" -}}
|
||||
{{- else if and (eq $provider "s3") $objectData.credential.s3 -}}
|
||||
{{- $creds = (include "tc.v1.common.lib.velero.provider.aws.secret" (dict "creds" $objectData.credential.s3) | fromYaml).data -}}
|
||||
{{/* Map provider */}}
|
||||
{{- $_ := set $objectData "provider" "velero.io/aws" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If we matched a provider, create the secret */}}
|
||||
{{- if $creds -}}
|
||||
{{- $secretData := (dict
|
||||
"name" (printf "vsl-%s" $objectData.name)
|
||||
"name" (printf "%s-%s" $prefix $objectData.name)
|
||||
"labels" $objectData.labels
|
||||
"annotations" $objectData.annotations
|
||||
"data" (dict "cloud" $creds)
|
||||
@@ -26,7 +31,7 @@
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $rootCtx "objectData" $secretData) -}}
|
||||
|
||||
{{/* Update the credential object with the name and key */}}
|
||||
{{- $_ := set $objectData.credential "name" (printf "vsl-%s" $objectData.name) -}}
|
||||
{{- $_ := set $objectData.credential "name" (printf "%s-%s" $prefix $objectData.name) -}}
|
||||
{{- $_ := set $objectData.credential "key" "cloud" -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
{{- $_ := set $objectData "shortName" $volSnapLoc.name -}}
|
||||
|
||||
{{/* Create secret with creds for provider, if the provider is not matched, it will skip creation */}}
|
||||
{{- include "tc.v1.common.lib.velero.provider.secret" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- include "tc.v1.common.lib.velero.provider.secret" (dict "rootCtx" $ "objectData" $objectData "prefix" "vsl") -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.velero.volumesnapshotlocation.validation" (dict "objectData" $objectData) -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user