-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from dirgim/operator-bundle-validate
Add the operator bundle data validation role using operator-sdk
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
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
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,4 @@ | ||
work_dir: /tmp/operator-test | ||
operator_work_dir: /tmp/operator-test/operator-files | ||
operator_sdk_bin_path: operator-sdk | ||
check_validation_result: true |
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,31 @@ | ||
--- | ||
- name: "Remove any previous validation results" | ||
shell: "rm -f {{ work_dir }}/validation-*" | ||
|
||
- name: "Output the operator-sdk version" | ||
shell: "{{ operator_sdk_bin_path }} version" | ||
register: sdk_version_result | ||
|
||
- name: "Output the operator-sdk version to a debug file" | ||
copy: | ||
content: "{{ sdk_version_result.stdout }}" | ||
dest: "{{ work_dir }}/validation-version.txt" | ||
when: sdk_version_result.stdout is defined | ||
|
||
- name: "Validate the operator bundle manifest and metadata with operator-sdk bundle validate" | ||
shell: "{{ operator_sdk_bin_path }} bundle validate --verbose {{ operator_work_dir }} > {{ work_dir}}/validation-output.txt 2>&1" | ||
register: sdk_validation_result | ||
ignore_errors: true | ||
|
||
- name: "Output the return code of operator-sdk bundle validate command to a debug file" | ||
copy: | ||
content: "{{ sdk_validation_result.rc }}" | ||
dest: "{{ work_dir }}/validation-rc.txt" | ||
when: sdk_validation_result.rc is defined | ||
|
||
- name: "Fail if the operator didn't satisfy the operator-sdk validation test" | ||
fail: | ||
msg: 'Operator sdk validation test failed, check validation-output.txt for more details' | ||
when: | ||
- check_validation_result|bool | ||
- sdk_validation_result.rc != 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,19 @@ | ||
--- | ||
- name: Validate the operator bundle image data with operator-sdk | ||
hosts: all | ||
become: false | ||
gather_facts: false | ||
|
||
vars: | ||
work_dir: "{{ lookup('env', 'WORKSPACE') }}" | ||
operator_work_dir: "/home/jenkins/agent/test-operator" | ||
testing_bin_path: "/usr/local/bin" | ||
jq_bin_path: "/usr/bin/jq" | ||
yq_bin_path: "/usr/local/bin/yq" | ||
operator_sdk_bin_path: "/usr/local/bin/operator-sdk" | ||
check_validation_result: false | ||
|
||
tasks: | ||
- name: "Validate the operator bundle image data with operator-sdk" | ||
include_role: | ||
name: validate_operator_bundle |