diff --git a/ci/downstream.sh b/ci/downstream.sh index 9e61037..4f26b2c 100755 --- a/ci/downstream.sh +++ b/ci/downstream.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -eu # Script to dual-home the upstream and downstream Collection in a single repo # @@ -32,6 +32,7 @@ f_text_sub() { # Switch FQCN and dependent components OKD_sed_files="${_build_dir}/README.md ${_build_dir}/CHANGELOG.rst ${_build_dir}/changelogs/config.yaml ${_build_dir}/ci/downstream.sh ${_build_dir}/galaxy.yml" + # shellcheck disable=SC2068 for okd_file in ${OKD_sed_files[@]}; do sed -i.bak "s/OKD/OpenShift/g" "${okd_file}"; done sed -i.bak "s/============================/==================================/" "${_build_dir}/CHANGELOG.rst" @@ -155,6 +156,8 @@ f_handle_doc_fragments_workaround() do local module_py="plugins/modules/${doc_fragment_mod}.py" f_log_info "Processing doc fragments for ${module_py}" + # We need following variable for ansible-doc only + # shellcheck disable=SC2097,SC2098 ANSIBLE_COLLECTIONS_PATH="${install_collections_dir}" \ ANSIBLE_COLLECTIONS_PATHS="${ANSIBLE_COLLECTIONS_PATH}:${install_collections_dir}" \ ansible-doc -j "redhat.openshift.${doc_fragment_mod}" > "${temp_fragments_json}" @@ -166,9 +169,8 @@ f_handle_doc_fragments_workaround() fi "${PYTHON}" "${_start_dir}/ci/downstream_fragments.py" "redhat.openshift.${doc_fragment_mod}" "${temp_fragments_json}" sed -n '/STARTREMOVE/q;p' "${module_py}" > "${temp_start}" - sed '0,/ENDREMOVE/d' "${module_py}" > "${temp_end}" + sed '1,/ENDREMOVE/d' "${module_py}" > "${temp_end}" cat "${temp_start}" "${rendered_fragments}" "${temp_end}" > "${module_py}" - cat "${module_py}" done rm -f "${rendered_fragments}" rm -fr "${install_collections_dir}" diff --git a/ci/downstream_fragments.py b/ci/downstream_fragments.py index 8bf9793..bd58293 100755 --- a/ci/downstream_fragments.py +++ b/ci/downstream_fragments.py @@ -1,8 +1,11 @@ #!/usr/bin/env python +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import json -import yaml import sys +import yaml with open("./rendereddocfragments.txt", 'w') as df_fd: with open(sys.argv[2], 'r') as fd: @@ -22,5 +25,3 @@ with open("./rendereddocfragments.txt", 'w') as df_fd: df_fd.write("RETURN = '''\n") df_fd.write(yaml.dump(json_docs[sys.argv[1]]['return'], default_flow_style=False)) df_fd.write("'''\n\n") - - diff --git a/ci/incluster_integration.sh b/ci/incluster_integration.sh index 88212a2..571eef9 100755 --- a/ci/incluster_integration.sh +++ b/ci/incluster_integration.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -eu set -x @@ -11,17 +11,18 @@ NAMESPACE=${NAMESPACE:-default} # and set the IMAGE_FORMAT environment variable so that it properly # resolves to your image. For example, quay.io/mynamespace/$component # would resolve to quay.io/mynamespace/molecule-test-runner +# shellcheck disable=SC2034 component='molecule-test-runner' -eval IMAGE=$IMAGE_FORMAT +eval IMAGE="$IMAGE_FORMAT" PULL_POLICY=${PULL_POLICY:-IfNotPresent} -if ! oc get namespace $NAMESPACE +if ! oc get namespace "$NAMESPACE" then - oc create namespace $NAMESPACE + oc create namespace "$NAMESPACE" fi -oc project $NAMESPACE +oc project "$NAMESPACE" oc adm policy add-cluster-role-to-user cluster-admin -z default oc adm policy who-can create projectrequests @@ -52,7 +53,7 @@ spec: EOF function check_success { - oc wait --for=condition=complete job/molecule-integration-test --timeout 5s -n $NAMESPACE \ + oc wait --for=condition=complete job/molecule-integration-test --timeout 5s -n "$NAMESPACE" \ && oc logs job/molecule-integration-test \ && echo "Molecule integration tests ran successfully" \ && return 0 @@ -60,7 +61,7 @@ function check_success { } function check_failure { - oc wait --for=condition=failed job/molecule-integration-test --timeout 5s -n $NAMESPACE \ + oc wait --for=condition=failed job/molecule-integration-test --timeout 5s -n "$NAMESPACE" \ && oc logs job/molecule-integration-test \ && echo "Molecule integration tests failed, see logs for more information..." \ && return 0