diff --git a/app/cli/automate.py b/app/cli/automate.py index 3bf4ee0..d035840 100644 --- a/app/cli/automate.py +++ b/app/cli/automate.py @@ -27,6 +27,7 @@ from app.terraform.bridge.hcloud import BridgeHcloudAutomation from app.terraform.bridge.ovh import BridgeOvhAutomation from app.terraform.list.github import ListGithubAutomation from app.terraform.list.gitlab import ListGitlabAutomation +from app.terraform.list.http_post import ListHttpPostAutomation from app.terraform.list.s3 import ListS3Automation from app.terraform.proxy.meta import ProxyMetaAutomation from app.terraform.proxy.azure_cdn import ProxyAzureCdnAutomation @@ -54,6 +55,7 @@ jobs = { EotkAWSAutomation, ListGithubAutomation, ListGitlabAutomation, + ListHttpPostAutomation, ListS3Automation, ProxyAzureCdnAutomation, ProxyCloudfrontAutomation, diff --git a/app/models/base.py b/app/models/base.py index 542d7d6..f106ec5 100644 --- a/app/models/base.py +++ b/app/models/base.py @@ -57,6 +57,7 @@ class MirrorList(AbstractConfiguration): providers_supported = { "github": "GitHub", "gitlab": "GitLab", + "http_post": "HTTP POST", "s3": "AWS S3", } @@ -85,6 +86,8 @@ class MirrorList(AbstractConfiguration): return f"https://raw.githubusercontent.com/{self.container}/{self.branch}/{self.filename}" if self.provider == "s3": return f"s3://{self.container}/{self.filename}" + if self.provider == "http_post": + return self.container return "Unknown provider" @classmethod diff --git a/app/terraform/list/http_post.py b/app/terraform/list/http_post.py new file mode 100644 index 0000000..9eed40e --- /dev/null +++ b/app/terraform/list/http_post.py @@ -0,0 +1,33 @@ +from app.terraform.list import ListAutomation + + +class ListHttpPostAutomation(ListAutomation): + short_name = "list_http_post" + description = "Update mirror lists by HTTP POST" + provider = "http_post" + + template_parameters = [] + + template = """ + terraform { + {{ backend_config }} + required_providers { + http = { + version = "~> 3.2.0" + } + } + } + + {% for list in lists %} + + data "http" "post_{{ list.id }}" { + url = "{{ list.container }}" + method = "POST" + request_body = file("{{ list.format }}.{{ list.pool.pool_name }}.{{ list.encoding }}") + + request_headers = { + Update-Key = "{{ list.filename }}" + } + } + {% endfor %} + """