Skip to content

Commit 48e85fc

Browse files
committed
Update build to copy deps into the container for building
1 parent 369cf1a commit 48e85fc

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

roles/operator_build/tasks/build.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,29 @@
3838
ansible.builtin.set_fact:
3939
operator_api_path: "github.com/{{ cifmw_operator_build_org }}/{{ operator.name }}/{{ operator_base_module_name }}"
4040

41+
42+
# Copy the dep into openstack-operator/deps
43+
# This copies the prepared zuul repo into the meta operator dir, which gets copied into the build container
44+
- name: "{{ operator.name }} - Copy dependancy source into meta operator"
45+
ansible.builtin.command: |
46+
git clone {{ operator.src }} deps/{{ operator.name }}
47+
args:
48+
chdir: "{{ cifmw_operator_build_meta_src }}"
49+
when:
50+
- operator.name != cifmw_operator_build_meta_name
51+
4152
# This is telling the openstack operator to look for dependency on a particular branch on github.
4253
# This should be the zuul src path.
54+
# If we switch to using local sources, they need to be copied into the container for the build.
55+
# This can be done by copying the modified operator code into the openstack-operator dir
56+
# The replacement here will then point to ./deps/{{ operator.name }}
4357
- name: "{{ operator.name }} - Update the go.mod file in meta operator for provided PR_SHA" # noqa: name[template]
4458
ansible.builtin.shell: |
45-
go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }}
59+
go mod edit -replace {{ operator_api_path }}=./deps/{{ operator.name }}/{{ operator_base_module_name }}
4660
go mod tidy
4761
if [ -d ./apis ]; then
4862
pushd ./apis/
49-
go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }}
63+
go mod edit -replace {{ operator_api_path }}=./deps/{{ operator.name }}/operator_base_module_name
5064
go mod tidy
5165
popd
5266
fi
@@ -68,21 +82,29 @@
6882
# The PR sha does not need to be pulled from the zuul.projects, since this __should__ match HEAD
6983
- name: "{{ operator.name }} - Set pr_sha to be used as image tag" # noqa: name[template]
7084
ansible.builtin.set_fact:
71-
#pr_sha: "{{ operator.pr_sha | default(git_head_out.stdout | trim) }}"
85+
# pr_sha: "{{ operator.pr_sha | default(git_head_out.stdout | trim) }}"
7286
pr_sha: "{{ git_head_out.stdout | trim }}"
7387

7488
- name: Skip if operator.pr_sha matches HEAD
7589
when: pr_sha != operator.pr_sha | default('')
7690
ansible.builtin.debug:
7791
msg: "Something"
7892

93+
- name: Show the {{ item.name }} - {{ item.value }}
94+
ansible.builtin.debug:
95+
var: item
96+
with_items:
97+
- {name: operator_api_path, value: "{{ operator_api_path | default('') }}" }
98+
- {name: operator_base_module_name, value: "{{ operator_base_module_name | default('') }}" }
99+
- {name: operator.name, value: "{{ operator.name | default('')}}" }
100+
79101
- name: "{{ operator.name }} - Update the go.mod file using latest commit if no PR is provided" # noqa: name[template]
80102
ansible.builtin.shell: |
81-
go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }}
103+
go mod edit -replace {{ operator_api_path }}=./deps/{{ operator.name }}/{{ operator_base_module_name }}
82104
go mod tidy
83105
if [ -d ./apis ]; then
84106
pushd ./apis/
85-
go mod edit -replace {{ operator_api_path }}={{ operator.src }}/{{ operator_base_module_name }}
107+
go mod edit -replace {{ operator_api_path }}=./deps/{{ operator.name }}/{{ operator_base_module_name }}
86108
go mod tidy
87109
popd
88110
fi

0 commit comments

Comments
 (0)