Skip to content

Commit

Permalink
chore(common): Convert some lists to dicts (and also add list spawner…
Browse files Browse the repository at this point in the history
…) (#616)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning

**➕ App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
  • Loading branch information
stavros-k authored Nov 25, 2023
1 parent 6f907a2 commit 9a1f204
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 259 deletions.
62 changes: 30 additions & 32 deletions library/common-test/ci/backupstoragelocation-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,33 @@ manifestManager:
# Parameters for the BackupStorageLocation(s). Configure multiple by adding other element(s) to the backupStorageLocation slice.
# See https://velero.io/docs/v1.6/api-types/backupstoragelocation/
backupStorageLocation:
# name is the name of the backup storage location where backups should be stored. If a name is not provided,
# a backup storage location will be created with the name "default". Optional.
- name: test
enabled: true
# provider is the name for the backup storage location provider.
provider: aws
objectStorage:
# bucket is the name of the bucket to store backups in. Required.
bucket: test
credential:
# AWS/s3 credentials to be put into secret (mandatory if provider == aws/s3)
aws:
id: fdgsdfghsdfgh
key: dfgdfhsdfgh
# Additional provider-specific configuration. See link above
# for details of required/optional fields for your provider.
config: {}
# region:
# s3ForcePathStyle:
# s3Url:
# kmsKeyId:
# resourceGroup:
# The ID of the subscription containing the storage account, if different from the cluster’s subscription. (Azure only)
# subscriptionId:
# storageAccount:
# publicUrl:
# Name of the GCP service account to use for this backup storage location. Specify the
# service account here if you want to use workload identity instead of providing the key file.(GCP only)
# serviceAccount:
# Option to skip certificate validation or not if insecureSkipTLSVerify is set to be true, the client side should set the
# flag. For Velero client Command like velero backup describe, velero backup logs needs to add the flag --insecure-skip-tls-verify
# insecureSkipTLSVerify:
test:
enabled: true
# provider is the name for the backup storage location provider.
provider: aws
objectStorage:
# bucket is the name of the bucket to store backups in. Required.
bucket: test
credential:
# AWS/s3 credentials to be put into secret (mandatory if provider == aws/s3)
aws:
id: fdgsdfghsdfgh
key: dfgdfhsdfgh
# Additional provider-specific configuration. See link above
# for details of required/optional fields for your provider.
config: {}
# region:
# s3ForcePathStyle:
# s3Url:
# kmsKeyId:
# resourceGroup:
# The ID of the subscription containing the storage account, if different from the cluster’s subscription. (Azure only)
# subscriptionId:
# storageAccount:
# publicUrl:
# Name of the GCP service account to use for this backup storage location. Specify the
# service account here if you want to use workload identity instead of providing the key file.(GCP only)
# serviceAccount:
# Option to skip certificate validation or not if insecureSkipTLSVerify is set to be true, the client side should set the
# flag. For Velero client Command like velero backup describe, velero backup logs needs to add the flag --insecure-skip-tls-verify
# insecureSkipTLSVerify:
25 changes: 12 additions & 13 deletions library/common-test/ci/volumesnapshotlocation-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ manifestManager:
# Parameters for the VolumeSnapshotLocation(s). Configure multiple by adding other element(s) to the volumeSnapshotLocation slice.
# See https://velero.io/docs/v1.6/api-types/volumesnapshotlocation/
volumeSnapshotLocation:
# name is the name of the volume snapshot location where snapshots are being taken. Required.
- name: test
enabled: true
# provider is the name for the volume snapshot provider.
provider: aws
credential:
# AWS/s3 credentials to be put into secret (mandatory if provider == aws/s3)
aws:
id: fdgsdfghsdfgh
key: dfgdfhsdfgh
# Additional provider-specific configuration. See link above
# for details of required/optional fields for your provider.
config: {}
test:
enabled: true
# provider is the name for the volume snapshot provider.
provider: aws
credential:
# AWS/s3 credentials to be put into secret (mandatory if provider == aws/s3)
aws:
id: fdgsdfghsdfgh
key: dfgdfhsdfgh
# Additional provider-specific configuration. See link above
# for details of required/optional fields for your provider.
config: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
suite: velero backupStorageLocationList test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec with aws provider and credential
set:
backupStorageLocationList:
- name: my-snap1
enabled: true
provider: aws
credential:
aws:
id: my-id
key: my-key
objectStorage:
bucket: my-bucket
asserts:
- documentIndex: &secretDoc 0
isKind:
of: Secret
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: stringData
value:
cloud: |-
[default]
aws_access_key_id=my-id
aws_secret_access_key=my-key
- documentIndex: &backStoreLocDoc 1
isKind:
of: BackupStorageLocation
- documentIndex: *backStoreLocDoc
isAPIVersion:
of: velero.io/v1
- documentIndex: *backStoreLocDoc
equal:
path: spec
value:
provider: velero.io/aws
credential:
name: bsl-test-release-name-common-test-my-snap1
key: cloud
accessMode: ReadWrite
objectStorage:
bucket: my-bucket
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
suite: velero volumeSnapshotLocationList spec test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec with aws provider and credential
set:
volumeSnapshotLocationList:
- name: my-snap1
enabled: true
provider: aws
credential:
aws:
id: my-id
key: my-key
asserts:
- documentIndex: &secretDoc 0
isKind:
of: Secret
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: stringData
value:
cloud: |-
[default]
aws_access_key_id=my-id
aws_secret_access_key=my-key
- 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
58 changes: 58 additions & 0 deletions library/common-test/tests/lists/volumeSnapshotClassList_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
suite: volumeSnapshotClassList spec test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec
set:
some_driver: csi-hostpath-snapshots
some_key: parameter1
some_value: value1
volumeSnapshotClassList:
- name: example1
enabled: true
driver: csi-hostpath-snapshots
deletionPolicy: Delete
- name: example2
enabled: true
driver: "{{ .Values.some_driver }}"
parameters:
"{{ .Values.some_key }}": "{{ .Values.some_value }}"
parameter2: 5
asserts:
- documentIndex: &volumeSnapshotDoc 0
isKind:
of: VolumeSnapshotClass
- documentIndex: *volumeSnapshotDoc
isAPIVersion:
of: snapshot.storage.k8s.io/v1
- documentIndex: *volumeSnapshotDoc
equal:
path: driver
value: csi-hostpath-snapshots
- documentIndex: *volumeSnapshotDoc
equal:
path: deletionPolicy
value: Delete
- documentIndex: &otherVolumeSnapshotDoc 1
isKind:
of: VolumeSnapshotClass
- documentIndex: *otherVolumeSnapshotDoc
isAPIVersion:
of: snapshot.storage.k8s.io/v1
- documentIndex: *otherVolumeSnapshotDoc
equal:
path: driver
value: csi-hostpath-snapshots
- documentIndex: *otherVolumeSnapshotDoc
equal:
path: deletionPolicy
value: Retain
- documentIndex: *otherVolumeSnapshotDoc
equal:
path: parameters
value:
parameter1: value1
parameter2: "5"
43 changes: 43 additions & 0 deletions library/common-test/tests/lists/volumeSnapshotList_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
suite: volumeSnapshotList spec test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec
set:
volumeSnapshotsList:
- name: example1
enabled: true
source:
volumeSnapshotContentName: some-name
- name: example2
enabled: true
source:
persistentVolumeClaimName: some-pvc-name
asserts:
- documentIndex: &volumeSnapshotDoc 0
isKind:
of: VolumeSnapshot
- documentIndex: *volumeSnapshotDoc
isAPIVersion:
of: snapshot.storage.k8s.io/v1
- documentIndex: *volumeSnapshotDoc
equal:
path: spec
value:
source:
volumeSnapshotContentName: some-name
- documentIndex: &otherVolumeSnapshotDoc 1
isKind:
of: VolumeSnapshot
- documentIndex: *otherVolumeSnapshotDoc
isAPIVersion:
of: snapshot.storage.k8s.io/v1
- documentIndex: *otherVolumeSnapshotDoc
equal:
path: spec
value:
source:
persistentVolumeClaimName: some-pvc-name
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ tests:
g_annotation1: global_annotation1
g_annotation2: "{{ .Values.annotation2 }}"
backupStorageLocation:
- enabled: true
name: my-snap
my-snap:
enabled: true
labels:
label1: "{{ .Values.label1 }}"
label2: label2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ tests:
- it: should generate correct name
set:
backupStorageLocation:
- enabled: true
name: my-snap1
my-snap1:
enabled: true

objectStorage:
bucket: my-bucket
provider: aws
credential:
aws:
id: my-id
key: my-key
- enabled: true
name: my-snap2
my-snap2:
enabled: true
objectStorage:
bucket: my-bucket
provider: aws
Expand Down
Loading

0 comments on commit 9a1f204

Please sign in to comment.