Aggregate all gitea repos and check against them

We are currently attempting to create repos which already exist. This
fails.

The reason for this is we set the gitea_org_repos fact for each org
overriding the last org. This means only the last org processed has any
projects in this list. We then check against this list when creating
projects so that we only create projects if they aren't in the list.
Meaning any project for repos not in the last org attempts to get
recreated.

We can address this by keeping a global list of repos regardless of org
then checking against that.

An alternative solution would be to process projects for each org
separately. Or to have gitea give us the global list so we don't have to
build it ourselves.

Change-Id: Id9a480634918dad2160a4e040a41ce6226ae67d8
This commit is contained in:
Clark Boylan 2019-03-01 20:49:30 -08:00
parent c0b64767a2
commit 0fe4c04172
2 changed files with 2 additions and 2 deletions

View File

@ -53,4 +53,4 @@
register: gitea_org_repo_list
- name: Parse org repo list
set_fact:
gitea_org_repos: "{{ gitea_org_repo_list.json | map(attribute='name') | list }}"
gitea_repos: "{{ gitea_org_repo_list.json | map(attribute='full_name') | list + gitea_repos | default([]) }}"

View File

@ -6,7 +6,7 @@
org: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\1') }}"
repo: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\2') }}"
- name: Create repo
when: repo not in gitea_org_repos
when: project.project not in gitea_repos
uri:
url: "{{ gitea_url }}/api/v1/org/{{ org }}/repos"
user: root