forked from k8s-operatorhub/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 3.83 KB
/
operator_convert.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "Operator Convert"
on:
workflow_dispatch:
inputs:
operators:
description: 'List of operators divided by space (aqua dell-csi-operator). Value all is also supported'
required: true
default: 'aqua dell-csi-operator'
target_branch:
description: 'Target branch'
required: true
#default: 'main'
default: 'manifest-to-bundle'
playbook_repo:
description: 'Playbook repo'
required: true
default: 'https://github.com/redhat-openshift-ecosystem/operator-test-playbooks'
playbook_branch:
description: 'Playbook branch'
required: true
default: 'upstream-community'
env:
OPP_OPERATORS: ${{ github.event.inputs.operators }}
OPP_ANSIBLE_PULL_REPO: "${{ github.event.inputs.playbook_repo }}"
OPP_ANSIBLE_PULL_BRANCH: "${{ github.event.inputs.playbook_branch }}"
ANSIBLE_FORCE_COLOR: 1
ANSIBLE_DISPLAY_SKIPPED_HOSTS: 0
ANSIBLE_STDOUT_CALLBACK: "yaml"
OPP_TARGET_BRANCH: "${{ github.event.inputs.target_branch }}"
OPP_PRODUCTION_TYPE: "k8s"
jobs:
convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.FRAMEWORK_MERGE }}
- name: Conversion
run: |
set -x
PROJECT_DIR=$(pwd)
FAKE_RC=false
git config --local user.email "41898282+framework-automation[bot]@users.noreply.github.com" || $FAKE_RC
git config --local user.name "framework-automation" || $FAKE_RC
if [[ $OPP_TARGET_BRANCH != "main" ]];then
git switch -C $OPP_TARGET_BRANCH
git reset --hard main
fi
if [[ $OPP_OPERATORS == "all" ]];then
echo "Searching for all operators ..."
OPP_OPERATORS=$(find operators/ -name "*package.yaml" | cut -d '/' -f 2 | tr '\n' ' ')
fi
PLAYBOOK_DIR="/tmp/operator-test-playbooks"
git clone $OPP_ANSIBLE_PULL_REPO -b $OPP_ANSIBLE_PULL_BRANCH $PLAYBOOK_DIR
ANSIBLE_TAGS="reset_tools,operator_info"
ANSIBLE_ARGS=
[ "$OPP_PRODUCTION_TYPE" == "ocp" ] && ANSIBLE_ARGS="-e supported_cluster_versions=v4.10,v4.11,v4.12,v4.13,v4.14"
for op in $OPP_OPERATORS;do
# TODO: Check if it is package manifest already
[ ! -d $PROJECT_DIR/operators/$op ] && { echo "Operator '$op' was not found, skipping ...";continue; } || true
IS_PACKAGEMANIFEST=$(find $PROJECT_DIR/operators/$op -name "*package.yaml")
[ -z $IS_PACKAGEMANIFEST ] && { echo "Operator '$op' is in bundle format already, skipping ...";continue; } || true
cd $PLAYBOOK_DIR
ansible-playbook -i localhost, -e ansible_connection=local -e run_upstream=true -e run_prepare_catalog_repo_upstream=false -e run_remove_catalog_repo=false upstream/local.yml --tags $ANSIBLE_TAGS \
-e operator_dir=$PROJECT_DIR/operators/$op -e cluster_type=$OPP_PRODUCTION_TYPE -e strict_cluster_version_labels=true -e strict_k8s_bundles=true -e automatic_cluster_version_label=true \
-e oi_index_skip=true $ANSIBLE_ARGS
ANSIBLE_TAGS="operator_info"
cd $PROJECT_DIR
echo "Moving bundle for '$op' ..."
[ -e $PROJECT_DIR/operators/$op/ci.yaml ] && mv $PROJECT_DIR/operators/$op/ci.yaml /tmp/operator-test/operators/$op/ || echo "ci.yaml file does not exist, skipping ..."
rm -rf $PROJECT_DIR/operators/$op
mv /tmp/operator-test/operators/$op $PROJECT_DIR/operators/$op
find $PROJECT_DIR/operators/$op -name 'bundle.Dockerfile' -delete
cd $PROJECT_DIR
git add . || $FAKE_RC
git commit -m "Operator '$op' converted from packagemanifest to bundle format" -a || $FAKE_RC
git push origin $OPP_TARGET_BRANCH -f || $FAKE_RC
done