-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Ansible Operator parameter case conversion optional (#3245)
* Add parameter to turn off case conversion * Add unit tests * Add e2e test for case conversion * Fix tests; add changelog fragment * Add docs for snakeCaseParameters * Reorganize code to avoid unnecessary loop * fix alignment issue
- Loading branch information
Showing
11 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
entries: | ||
- description: > | ||
The `snakeCaseParameters` option has been added to the `watches.yaml` for | ||
Ansible-based Operators. This allows the user to configure whether parameters | ||
in the resource spec are automatically converted from camelCase to snake_case. | ||
The default is `true`, so there is no behavior change for existing operators, | ||
but it can now be disabled. | ||
kind: "addition" | ||
breaking: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/ansible/deploy/crds/test.example.com_casetest_crd.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: casetests.test.example.com | ||
spec: | ||
group: test.example.com | ||
names: | ||
kind: CaseTest | ||
listKind: CaseTestList | ||
plural: casetests | ||
singular: casetest | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
x-kubernetes-preserve-unknown-fields: true | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: Create the test.example.com/v1alpha1.CaseTest | ||
k8s: | ||
state: present | ||
definition: | ||
apiVersion: test.example.com/v1alpha1 | ||
kind: CaseTest | ||
metadata: | ||
name: case-test | ||
namespace: '{{ namespace }}' | ||
spec: | ||
camelCaseVar: "true" | ||
wait: yes | ||
wait_timeout: 300 | ||
wait_condition: | ||
type: Running | ||
reason: Successful | ||
status: "True" | ||
register: case_test | ||
|
||
- name: Assert sentinel ConfigMap has been created for Molecule Test | ||
assert: | ||
that: cm.data.shouldBeCamel == 'true' | ||
vars: | ||
cm: "{{ q('k8s', api_version='v1', kind='ConfigMap', namespace=namespace, resource_name='case-test').0 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- hosts: localhost | ||
gather_facts: no | ||
collections: | ||
- community.kubernetes | ||
|
||
tasks: | ||
- name: Create configmap | ||
k8s: | ||
definition: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: '{{ meta.name }}' | ||
namespace: '{{ meta.namespace }}' | ||
data: | ||
shouldBeCamel: '{{ camelCaseVar | default("false") }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,3 @@ | |
data: | ||
'{{ item.key }}': '{{ item.value | b64decode }}' | ||
with_dict: '{{ __secret.data }}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters