Skip to content

Commit

Permalink
chore: Update translate to patches
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Kosiewski <[email protected]>
  • Loading branch information
ThomasK33 committed Oct 7, 2024
1 parent 7d59652 commit 17cf73d
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 99 deletions.
122 changes: 69 additions & 53 deletions chart/tests/role_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ tests:
rbac:
role:
overwriteRules:
- apiGroups: [ "" ]
resources: [ "configmaps" ]
verbs: [ "create" ]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create"]
asserts:
- hasDocuments:
count: 1
Expand All @@ -30,9 +30,9 @@ tests:
path: rules
count: 1
content:
apiGroups: [ "" ]
resources: [ "configmaps" ]
verbs: [ "create" ]
apiGroups: [""]
resources: ["configmaps"]
verbs: ["create"]

- it: check plugin extra rules
set:
Expand All @@ -41,17 +41,17 @@ tests:
rbac:
role:
extraRules:
- apiGroups: [ "" ]
resources: [ "test123" ]
verbs: [ "test123" ]
- apiGroups: [""]
resources: ["test123"]
verbs: ["test123"]
plugins:
test:
rbac:
role:
extraRules:
- apiGroups: [ "" ]
resources: [ "test" ]
verbs: [ "test" ]
- apiGroups: [""]
resources: ["test"]
verbs: ["test"]
asserts:
- hasDocuments:
count: 1
Expand All @@ -62,26 +62,26 @@ tests:
path: rules
count: 1
content:
apiGroups: [ "" ]
resources: [ "test123" ]
verbs: [ "test123" ]
apiGroups: [""]
resources: ["test123"]
verbs: ["test123"]
- contains:
path: rules
count: 1
content:
apiGroups: [ "" ]
resources: [ "test" ]
verbs: [ "test" ]
apiGroups: [""]
resources: ["test"]
verbs: ["test"]

- it: check generic sync
set:
experimental:
genericSync:
role:
extraRules:
- apiGroups: [ "" ]
resources: [ "test" ]
verbs: [ "test" ]
- apiGroups: [""]
resources: ["test"]
verbs: ["test"]
asserts:
- hasDocuments:
count: 1
Expand All @@ -92,9 +92,9 @@ tests:
path: rules
count: 1
content:
apiGroups: [ "" ]
resources: [ "test" ]
verbs: [ "test" ]
apiGroups: [""]
resources: ["test"]
verbs: ["test"]

- it: check extra rules
set:
Expand All @@ -114,9 +114,9 @@ tests:
path: rules
count: 1
content:
apiGroups: [ "" ]
resources: [ "test" ]
verbs: [ "test" ]
apiGroups: [""]
resources: ["test"]
verbs: ["test"]

- it: check defaults
release:
Expand Down Expand Up @@ -171,9 +171,9 @@ tests:
- contains:
path: rules
content:
apiGroups: [ "metrics.k8s.io" ]
resources: [ "pods" ]
verbs: [ "get", "list" ]
apiGroups: ["metrics.k8s.io"]
resources: ["pods"]
verbs: ["get", "list"]

- it: external secret test
set:
Expand All @@ -197,7 +197,8 @@ tests:
content:
apiGroups: ["external-secrets.io"]
resources: ["externalsecrets"]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- it: external secret test store sync
set:
integrations:
Expand All @@ -222,7 +223,8 @@ tests:
content:
apiGroups: ["external-secrets.io"]
resources: ["secretstores"]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- it: kubeVirt test
set:
integrations:
Expand All @@ -241,26 +243,38 @@ tests:
path: rules
content:
apiGroups: ["kubevirt.io"]
resources: ["virtualmachines", "virtualmachines/status", "virtualmachineinstances", "virtualmachineinstances/status", "virtualmachineinstancemigrations", "virtualmachineinstancemigrations/status"]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
resources:
[
"virtualmachines",
"virtualmachines/status",
"virtualmachineinstances",
"virtualmachineinstances/status",
"virtualmachineinstancemigrations",
"virtualmachineinstancemigrations/status",
]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- contains:
path: rules
content:
apiGroups: [ "cdi.kubevirt.io" ]
resources: [ "datavolumes", "datavolumes/status" ]
verbs: [ "create", "delete", "patch", "update", "get", "list", "watch" ]
apiGroups: ["cdi.kubevirt.io"]
resources: ["datavolumes", "datavolumes/status"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- contains:
path: rules
content:
apiGroups: [ "clone.kubevirt.io" ]
resources: [ "virtualmachineclones", "virtualmachineclones/status" ]
verbs: [ "create", "delete", "patch", "update", "get", "list", "watch" ]
apiGroups: ["clone.kubevirt.io"]
resources: ["virtualmachineclones", "virtualmachineclones/status"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- contains:
path: rules
content:
apiGroups: [ "pool.kubevirt.io" ]
resources: [ "virtualmachinepools", "virtualmachinepools/status" ]
verbs: [ "create", "delete", "patch", "update", "get", "list", "watch" ]
apiGroups: ["pool.kubevirt.io"]
resources: ["virtualmachinepools", "virtualmachinepools/status"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]

- it: crd sync
set:
Expand Down Expand Up @@ -288,24 +302,26 @@ tests:
- contains:
path: rules
content:
apiGroups: [ "my-group-2" ]
resources: [ "test" ]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
apiGroups: ["my-group-2"]
resources: ["test"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]
- contains:
path: rules
content:
apiGroups: [ "my-group-3.com" ]
resources: [ "tests" ]
verbs: ["create", "delete", "patch", "update", "get", "list", "watch"]
apiGroups: ["my-group-3.com"]
resources: ["tests"]
verbs:
["create", "delete", "patch", "update", "get", "list", "watch"]

- it: translate
- it: patches
set:
sync:
toHost:
customResources:
test.my-group-2:
enabled: true
translate:
patches:
- path: "test"
expression: "test"
release:
Expand All @@ -314,14 +330,14 @@ tests:
asserts:
- notFailedTemplate: {}

- it: translate 2
- it: patches 2
set:
sync:
toHost:
customResources:
test.my-group-2:
enabled: true
translate:
patches:
- path: "test"
reference:
apiVersion: "v1"
Expand Down
8 changes: 4 additions & 4 deletions chart/tests/statefulset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,11 @@ tests:
customResources:
test.cert-manager.io:
enabled: true
translate:
patches:
- path: spec.dnsNames[*]
expression: "value.startsWith('www.') ? value.slice(4) : value"
reverseExpression: '"www."+value'
asserts:
- equal:
path: kind
value: StatefulSet
- equal:
path: kind
value: StatefulSet
24 changes: 12 additions & 12 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1016,18 +1016,18 @@
"additionalProperties": false,
"type": "object"
},
"EnableSwitchWithTranslate": {
"EnableSwitchWithPatches": {
"properties": {
"enabled": {
"type": "boolean",
"description": "Enabled defines if this option should be enabled."
},
"translate": {
"patches": {
"items": {
"$ref": "#/$defs/TranslatePatch"
},
"type": "array",
"description": "Translate the patch according to the given patches."
"description": "Patches patch the resource according to the provided specification."
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -2910,12 +2910,12 @@
"type": "boolean",
"description": "All defines if all resources of that type should get synced or only the necessary ones that are needed."
},
"translate": {
"patches": {
"items": {
"$ref": "#/$defs/TranslatePatch"
},
"type": "array",
"description": "Translate the patch according to the given patches."
"description": "Patches patch the resource according to the provided specification."
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -3047,12 +3047,12 @@
"$ref": "#/$defs/SyncRewriteHosts",
"description": "RewriteHosts is a special option needed to rewrite statefulset containers to allow the correct FQDN. virtual cluster will add\na small container to each stateful set pod that will initially rewrite the /etc/hosts file to match the FQDN expected by\nthe virtual cluster."
},
"translate": {
"patches": {
"items": {
"$ref": "#/$defs/TranslatePatch"
},
"type": "array",
"description": "Translate the patch according to the given patches."
"description": "Patches patch the resource according to the provided specification."
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -3101,11 +3101,11 @@
"description": "ConfigMaps defines if config maps created within the virtual cluster should get synced to the host cluster."
},
"ingresses": {
"$ref": "#/$defs/EnableSwitchWithTranslate",
"$ref": "#/$defs/EnableSwitchWithPatches",
"description": "Ingresses defines if ingresses created within the virtual cluster should get synced to the host cluster."
},
"services": {
"$ref": "#/$defs/EnableSwitchWithTranslate",
"$ref": "#/$defs/EnableSwitchWithPatches",
"description": "Services defines if services created within the virtual cluster should get synced to the host cluster."
},
"endpoints": {
Expand All @@ -3117,7 +3117,7 @@
"description": "NetworkPolicies defines if network policies created within the virtual cluster should get synced to the host cluster."
},
"persistentVolumeClaims": {
"$ref": "#/$defs/EnableSwitchWithTranslate",
"$ref": "#/$defs/EnableSwitchWithPatches",
"description": "PersistentVolumeClaims defines if persistent volume claims created within the virtual cluster should get synced to the host cluster."
},
"persistentVolumes": {
Expand Down Expand Up @@ -3161,12 +3161,12 @@
"type": "boolean",
"description": "Enabled defines if this option should be enabled."
},
"translate": {
"patches": {
"items": {
"$ref": "#/$defs/TranslatePatch"
},
"type": "array",
"description": "Translate the patch according to the given patches."
"description": "Patches patch the resource according to the provided specification."
}
},
"additionalProperties": false,
Expand Down
3 changes: 3 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ sync:
toHost:
# Services defines if services created within the virtual cluster should get synced to the host cluster.
services:
# Enabled defines if this option should be enabled.
enabled: true
# Endpoints defines if endpoints created within the virtual cluster should get synced to the host cluster.
endpoints:
enabled: true
# PersistentVolumeClaims defines if persistent volume claims created within the virtual cluster should get synced to the host cluster.
persistentVolumeClaims:
# Enabled defines if this option should be enabled.
enabled: true
# ConfigMaps defines if config maps created within the virtual cluster should get synced to the host cluster.
configMaps:
Expand Down Expand Up @@ -55,6 +57,7 @@ sync:
memory: 64Mi
# Ingresses defines if ingresses created within the virtual cluster should get synced to the host cluster.
ingresses:
# Enabled defines if this option should be enabled.
enabled: false
# PriorityClasses defines if priority classes created within the virtual cluster should get synced to the host cluster.
priorityClasses:
Expand Down
Loading

0 comments on commit 17cf73d

Please sign in to comment.