-
Notifications
You must be signed in to change notification settings - Fork 16
Task/csi 3503 add verification scrips only #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
626d54e
afcb83e
1dbf067
4842511
9a306b8
a511e92
368a389
97ed4dd
5f63716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ WORKDIR $WORKDIR | |
COPY Makefile . | ||
|
||
RUN go get github.com/onsi/ginkgo/[email protected] \ | ||
&& go get github.com/mikefarah/yq/v4 \ | ||
&& make kustomize \ | ||
&& make controller-gen | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,78 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
#!/bin/bash -e | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||
# Copyright 2019 IBM Corp. | ||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||||||||
# you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||||||||
# You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||
# http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||
# Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||||||
# distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||||||
# See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||||||
# limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
source hack/project_info.sh | ||||||||||||||||||||||||||||||||||||||||||||||
roles_yaml_path=config/rbac/role.yaml | ||||||||||||||||||||||||||||||||||||||||||||||
crd_yaml_path=config/crd/bases/csi.ibm.com_ibmblockcsis.yaml | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
check_generation (){ | ||||||||||||||||||||||||||||||||||||||||||||||
echo "check generation" | ||||||||||||||||||||||||||||||||||||||||||||||
project_dirname=ibm-block-csi-operator | ||||||||||||||||||||||||||||||||||||||||||||||
cd .. | ||||||||||||||||||||||||||||||||||||||||||||||
cp -r $project_dirname ./$project_dirname-expected | ||||||||||||||||||||||||||||||||||||||||||||||
cd $project_dirname-expected/ | ||||||||||||||||||||||||||||||||||||||||||||||
make update | ||||||||||||||||||||||||||||||||||||||||||||||
cd .. | ||||||||||||||||||||||||||||||||||||||||||||||
diff -qr --exclude=bin $project_dirname $project_dirname-expected/ | ||||||||||||||||||||||||||||||||||||||||||||||
rm -rf $project_dirname-expected/ | ||||||||||||||||||||||||||||||||||||||||||||||
cd $project_dirname | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+23
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
would this work? less |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
verify_yaml_doc_in_multidoc_yaml(){ | ||||||||||||||||||||||||||||||||||||||||||||||
yamls_dictionary=${1#*=} | ||||||||||||||||||||||||||||||||||||||||||||||
eval "declare -A yaml_kinds_by_origin_yaml_path="${yamls_dictionary} | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://stackoverflow.com/a/3467959
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried without it and I didn't manage to find a solution, the variable pass between the functions interrupted it, you sent an example without a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||
for orignial_yaml in ${!yaml_kinds_by_origin_yaml_path[@]}; do | ||||||||||||||||||||||||||||||||||||||||||||||
export resource_type=${yaml_kinds_by_origin_yaml_path[${orignial_yaml}]} | ||||||||||||||||||||||||||||||||||||||||||||||
diff <(yq e '... comments=""' $orignial_yaml) <(yq eval '(. | select(.kind == env(resource_type)))' $operator_yaml_path) | ||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
verify_full_operator_yaml_is_aligned(){ | ||||||||||||||||||||||||||||||||||||||||||||||
echo "check full operator yaml alignment" | ||||||||||||||||||||||||||||||||||||||||||||||
declare -A yaml_kinds_by_origin_yaml_path=( | ||||||||||||||||||||||||||||||||||||||||||||||
[$roles_yaml_path]="ClusterRole" | ||||||||||||||||||||||||||||||||||||||||||||||
[$crd_yaml_path]="CustomResourceDefinition" | ||||||||||||||||||||||||||||||||||||||||||||||
["config/rbac/service_account.yaml"]="ServiceAccount" | ||||||||||||||||||||||||||||||||||||||||||||||
["config/rbac/role_binding.yaml"]="ClusterRoleBinding" | ||||||||||||||||||||||||||||||||||||||||||||||
["config/manager/manager.yaml"]="Deployment" | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+48
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need the kinds hardcoded? can't we find them dynamically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will open a ticket There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to add |
||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||
verify_yaml_doc_in_multidoc_yaml "$(declare -p yaml_kinds_by_origin_yaml_path)" | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
verify_no_roles_diff (){ | ||||||||||||||||||||||||||||||||||||||||||||||
echo "check roles alignment" | ||||||||||||||||||||||||||||||||||||||||||||||
are_manifest_files_exist_in_current_csi_version | ||||||||||||||||||||||||||||||||||||||||||||||
csv_files=$(get_csv_files) | ||||||||||||||||||||||||||||||||||||||||||||||
for csv_file in $csv_files; do | ||||||||||||||||||||||||||||||||||||||||||||||
diff <(yq e .rules $roles_yaml_path) <(yq e .spec.install.spec.clusterPermissions[0].rules $csv_file) | ||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
verify_no_crds_diff (){ | ||||||||||||||||||||||||||||||||||||||||||||||
echo "check crds alignment" | ||||||||||||||||||||||||||||||||||||||||||||||
are_manifest_files_exist_in_current_csi_version | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code dup |
||||||||||||||||||||||||||||||||||||||||||||||
crd_files=$(get_bundle_crds) | ||||||||||||||||||||||||||||||||||||||||||||||
for crd_file in $crd_files; do | ||||||||||||||||||||||||||||||||||||||||||||||
diff $crd_yaml_path $crd_file | ||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
check_generation | ||||||||||||||||||||||||||||||||||||||||||||||
verify_full_operator_yaml_is_aligned | ||||||||||||||||||||||||||||||||||||||||||||||
verify_no_roles_diff | ||||||||||||||||||||||||||||||||||||||||||||||
verify_no_crds_diff |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash -e | ||
|
||
# | ||
# Copyright 2019 IBM Corp. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
operator_yaml_path=deploy/installer/generated/ibm-block-csi-operator.yaml | ||
|
||
get_current_csi_version (){ | ||
current_csi_version=$(cat version/version.go | grep -i driverversion | awk -F = '{print $2}') | ||
echo ${current_csi_version//\"} | ||
} | ||
|
||
current_csi_version=$(get_current_csi_version) | ||
|
||
are_manifest_files_exist_in_current_csi_version (){ | ||
if ! compgen -G "${PWD}/deploy/olm-catalog/*/$current_csi_version" > /dev/null; then | ||
exit 0 | ||
fi | ||
} | ||
|
||
get_csv_files (){ | ||
ls deploy/olm-catalog/ibm-block-csi-operator-community/$current_csi_version/manifests/ibm-block-csi-operator.v$current_csi_version.clusterserviceversion.yaml | ||
ls deploy/olm-catalog/ibm-block-csi-operator/$current_csi_version/manifests/ibm-block-csi-operator.clusterserviceversion.yaml | ||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider moving the olm-catalog path to a common "const" |
||
} | ||
|
||
get_bundle_crds (){ | ||
ls deploy/olm-catalog/ibm-block-csi-operator-community/$current_csi_version/manifests/csi.ibm.com_ibmblockcsis.yaml | ||
ls deploy/olm-catalog/ibm-block-csi-operator/$current_csi_version/manifests/csi.ibm.com_ibmblockcsis.yaml | ||
} |
Uh oh!
There was an error while loading. Please reload this page.