From 502053abeffe1e3c3dde7b15fc4ca42ba651bafa Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 4 Jul 2026 22:41:12 +1000 Subject: [PATCH] feat: manage local docker registries ArtifactAPI now serves local docker repos as real container registries and the provider exposes an artifactapi_local_docker resource, but this config had no way to declare one. - Add a local_docker variable, module resource, config loader wiring, and terragrunt input, mirroring the other local_* kinds. - Declare a docker-internal registry. - Expand the README to cover the local_* and virtual kinds. Depends on a terraform-provider-artifactapi release exposing artifactapi_local_docker (and a matching .terraform.lock.hcl bump) before apply. --- README.md | 10 +++++++++- config/config.hcl | 5 +++++ config/local_docker/docker-internal.yaml | 1 + .../artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl | 1 + modules/artifactapi/main.tf | 7 +++++++ modules/artifactapi/variables.tf | 8 ++++++++ 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 config/local_docker/docker-internal.yaml diff --git a/README.md b/README.md index c91c0fd..017ca62 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # terraform-artifactapi -Terraform configuration for managing ArtifactAPI remote and virtual repositories \ No newline at end of file +Terraform configuration for managing ArtifactAPI remote, local, and virtual repositories. + +Repositories are declared as YAML files under `config//.yaml`, where the +filename is the repository name. `make plan` / `make apply` (via Terragrunt) reconcile +them against the ArtifactAPI instance. + +Kinds: `remote_*` (caching proxies of an upstream), `local_*` (real registries hosted +directly — `local_docker`, `local_pypi`, `local_rpm`, `local_terraform`), and `virtual` +(merged views over members of one package type). diff --git a/config/config.hcl b/config/config.hcl index b7b90f1..4e41c58 100644 --- a/config/config.hcl +++ b/config/config.hcl @@ -57,6 +57,11 @@ locals { trimsuffix(basename(file_path), ".yaml") => content if startswith(file_path, "local_rpm/") } + local_docker = { + for file_path, content in local.all_configs : + trimsuffix(basename(file_path), ".yaml") => content + if startswith(file_path, "local_docker/") + } virtual = { for file_path, content in local.all_configs : trimsuffix(basename(file_path), ".yaml") => content diff --git a/config/local_docker/docker-internal.yaml b/config/local_docker/docker-internal.yaml new file mode 100644 index 0000000..6479f31 --- /dev/null +++ b/config/local_docker/docker-internal.yaml @@ -0,0 +1 @@ +description: "Internal container image registry" diff --git a/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl b/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl index 5d1258a..b01bbb0 100644 --- a/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl +++ b/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl @@ -27,5 +27,6 @@ inputs = { local_terraform = local.config.local_terraform local_pypi = local.config.local_pypi local_rpm = local.config.local_rpm + local_docker = local.config.local_docker virtual = local.config.virtual } diff --git a/modules/artifactapi/main.tf b/modules/artifactapi/main.tf index f68b0bf..fd895a4 100644 --- a/modules/artifactapi/main.tf +++ b/modules/artifactapi/main.tf @@ -110,6 +110,13 @@ resource "artifactapi_local_rpm" "this" { description = each.value.description } +resource "artifactapi_local_docker" "this" { + for_each = var.local_docker + + name = each.key + description = each.value.description +} + resource "artifactapi_virtual" "this" { for_each = var.virtual diff --git a/modules/artifactapi/variables.tf b/modules/artifactapi/variables.tf index 9ec161b..0706d0e 100644 --- a/modules/artifactapi/variables.tf +++ b/modules/artifactapi/variables.tf @@ -120,6 +120,14 @@ variable "local_terraform" { default = {} } +variable "local_docker" { + description = "Map of local Docker repositories (real container registries)" + type = map(object({ + description = optional(string, "") + })) + default = {} +} + variable "virtual" { description = "Map of virtual repositories" type = map(object({