Skip to content

Commit

Permalink
Add ability to fork instead of create a project
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Oct 16, 2023
1 parent 711caf1 commit 4897e5c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
1 change: 1 addition & 0 deletions obal/data/roles/copr_project/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
copr_project_chroots: []
copr_project_fork_from:
25 changes: 25 additions & 0 deletions obal/data/roles/copr_project/tasks/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: 'Create Copr project'
copr_project:
user: "{{ copr_project_user }}"
project: "{{ copr_project_name }}"
chroots: "{{ copr_project_chroots | map(attribute='name') | list }}"
description: "{{ copr_project_description | default(omit) }}"
delete_after_days: "{{ copr_project_delete_after_days | default(omit) }}"
unlisted_on_homepage: "{{ copr_project_unlisted_on_homepage | default(omit) }}"
config_file: "{{ copr_project_copr_config | default(omit) }}"
register: create_output

- name: Configure chroots
copr_chroot:
user: "{{ copr_project_user }}"
project: "{{ copr_project_name }}"
chroot: "{{ chroot.name }}"
external_repos: "{{ chroot.external_repos | default(omit) }}"
buildroot_packages: "{{ chroot.buildroot_packages | default(omit) }}"
modules: "{{ chroot.modules | default(omit) }}"
config_file: "{{ copr_project_copr_config | default(omit) }}"
comps_file: "{{ chroot.comps_file | default(omit) }}"
loop: "{{ copr_project_chroots }}"
loop_control:
loop_var: chroot
8 changes: 8 additions & 0 deletions obal/data/roles/copr_project/tasks/fork.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Fork Copr project
copr_fork:
src_user: "{{ copr_project_user }}"
src_project: "{{ copr_project_fork_from }}"
dest_user: "{{ copr_project_user }}"
dest_project: "{{ copr_project_name }}"
config_file: "{{ copr_project_copr_config | default(omit) }}"
27 changes: 4 additions & 23 deletions obal/data/roles/copr_project/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
---
- name: 'Create Copr project'
copr_project:
user: "{{ copr_project_user }}"
project: "{{ copr_project_name }}"
chroots: "{{ copr_project_chroots | map(attribute='name') | list }}"
description: "{{ copr_project_description | default(omit) }}"
delete_after_days: "{{ copr_project_delete_after_days | default(omit) }}"
unlisted_on_homepage: "{{ copr_project_unlisted_on_homepage | default(omit) }}"
config_file: "{{ copr_project_copr_config | default(omit) }}"
register: create_output
- when: copr_project_fork_from
include_tasks: fork.yml

- name: Configure chroots
copr_chroot:
user: "{{ copr_project_user }}"
project: "{{ copr_project_name }}"
chroot: "{{ chroot.name }}"
external_repos: "{{ chroot.external_repos | default(omit) }}"
buildroot_packages: "{{ chroot.buildroot_packages | default(omit) }}"
modules: "{{ chroot.modules | default(omit) }}"
config_file: "{{ copr_project_copr_config | default(omit) }}"
comps_file: "{{ chroot.comps_file | default(omit) }}"
loop: "{{ copr_project_chroots }}"
loop_control:
loop_var: chroot
- when: not copr_project_fork_from
include_tasks: create.yml
10 changes: 10 additions & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,3 +849,13 @@ def test_copr_project_many_chroots():

]
assert_mockbin_log(expected_log)


@obal_cli_test(repotype='copr')
def test_copr_project_fork():
assert_obal_success(['copr-project', 'client', '-e copr_project_fork_from=client-test'])

expected_log = [
"copr-cli fork example/client-test example/foreman-client"
]
assert_mockbin_log(expected_log)

0 comments on commit 4897e5c

Please sign in to comment.