Initial import
This commit is contained in:
commit
09f0b0672d
64 changed files with 3735 additions and 0 deletions
54
app/terraform/list/gitlab.py
Normal file
54
app/terraform/list/gitlab.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from app import app
|
||||
from app.terraform.list import ListAutomation
|
||||
|
||||
|
||||
class ListGitlabAutomation(ListAutomation):
|
||||
short_name = "list_gitlab"
|
||||
provider = "gitlab"
|
||||
|
||||
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 }}.json"))
|
||||
author_email = "{{ gitlab_author_email }}"
|
||||
author_name = "{{ gitlab_author_name }}"
|
||||
commit_message = "{{ gitlab_commit_message }}"
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with app.app_context():
|
||||
auto = ListGitlabAutomation()
|
||||
auto.generate_terraform()
|
||||
auto.terraform_init()
|
||||
auto.terraform_apply()
|
Loading…
Add table
Add a link
Reference in a new issue