Skip to content

Commit

Permalink
feat: add branch reference as variable in gitrepository
Browse files Browse the repository at this point in the history
  • Loading branch information
oscaromeu committed Aug 27, 2023
1 parent 0db68d2 commit 044cde3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions bootstrap/tasks/validation/github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@
that: result.json.full_name == bootstrap_github_username + '/' + bootstrap_github_repository_name
success_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} exists
fail_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} does not exist

- name: Query Github repo branch
ansible.builtin.uri:
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}/branches/{{ bootstrap_github_repository_branch }}
timeout: 5
return_content: true
body_format: json
register: result

- name: Check if repo branch exists
ansible.builtin.assert:
that: result.json.name == bootstrap_github_repository_branch
success_msg: Github repo branch {{ bootstrap_github_repository_branch }} exists
fail_msg: Github repo branch {{ bootstrap_github_repository_branch }} does not exist
1 change: 1 addition & 0 deletions bootstrap/tasks/validation/vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- bootstrap_cluster_cidr
- bootstrap_flux_github_webhook_token
- bootstrap_github_repository_name
- bootstrap_github_repository_branch
- bootstrap_github_username
- bootstrap_external_ingress_addr
- bootstrap_internal_ingress_addr
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/templates/kubernetes/flux/config/cluster.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
interval: 30m
ref:
branch: main
branch: {{ bootstrap_github_repository_branch }}
url: "https://github.com/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}.git"
ignore: |
# exclude all
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/vars/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
bootstrap_github_username:
# Github repository (e.g. flux-cluster-template)
bootstrap_github_repository_name:
# Github repository branch (e.g. main)
bootstrap_github_repository_branch:
# Age Public Key (e.g. age15uzrw396e67z9wdzsxzdk7ka0g2gr3l460e0slaea563zll3hdfqwqxdta)
bootstrap_age_public_key:
# Choose your timezone (e.g. America/New_York)
Expand Down

0 comments on commit 044cde3

Please sign in to comment.