majuna/app/terraform/list/gitlab.py
Iain Learmonth a935055083 lists/git: always refresh when updating git repos
looks like errors can occur when the latest commit
isn't what is expected
2022-05-18 12:00:18 +01:00

47 lines
1.2 KiB
Python

from app.terraform.list import ListAutomation
class ListGitlabAutomation(ListAutomation):
short_name = "list_gitlab"
description = "Update mirror lists in GitLab repositories"
provider = "gitlab"
always_refresh = True
template_parameters = [
"gitlab_token",
"gitlab_author_email",
"gitlab_author_name",
"gitlab_commit_message"
]
template = """
terraform {
required_providers {
gitlab = {
source = "gitlabhq/gitlab"
version = "~> 3.12.0"
}
}
}
provider "gitlab" {
token = "{{ gitlab_token }}"
}
{% for list in lists %}
data "gitlab_project" "project_{{ list.id }}" {
id = "{{ list.container }}"
}
resource "gitlab_repository_file" "file_{{ list.id }}" {
project = data.gitlab_project.project_{{ list.id }}.id
file_path = "{{ list.filename }}"
branch = "{{ list.branch }}"
content = base64encode(file("{{ list.format }}.{{ list.encoding }}"))
author_email = "{{ gitlab_author_email }}"
author_name = "{{ gitlab_author_name }}"
commit_message = "{{ gitlab_commit_message }}"
}
{% endfor %}
"""