mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-19 15:14:40 +09:00
Adds a Terraform module registry package type implementing the [module registry protocol](https://developer.hashicorp.com/terraform/internals/module-registry-protocol), so `terraform init` and Terragrunt `tfr://` can resolve modules from Gitea: ```hcl module "vpc" { source = "gitea.example.com/owner/vpc/aws" version = "~> 1.0" } ``` - Modules are uploaded with `PUT /api/packages/-/terraform/modules/{owner}/{name}/{provider}/{version}` as a `.tar.gz` with the module at its root, stored verbatim and immutable. - `X-Terraform-Get` is a short-lived signed URL because Terraform sends no credentials when downloading the archive. - The package page shows install snippets, README, the root module's inputs, outputs and providers, and `modules/*` submodules. - Metadata is read by a small in-tree HCL scanner instead of `hashicorp/hcl/v2`, which would add 5 modules and ~1.4 MB to the binary. Docs: https://gitea.com/gitea/docs/pulls/433 --------- Signed-off-by: Michael Lopez <mickael.lopez@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package terraform_module
|
|
|
|
type Metadata struct {
|
|
Readme string `json:"readme,omitempty"`
|
|
Root *Module `json:"root,omitempty"`
|
|
Submodules map[string]*Submodule `json:"submodules,omitempty"`
|
|
}
|
|
|
|
// Submodule is a module packaged in the archive's modules/<name> directory
|
|
type Submodule struct {
|
|
Readme string `json:"readme,omitempty"`
|
|
Module *Module `json:"module,omitempty"`
|
|
}
|
|
|
|
type Module struct {
|
|
Inputs []*Input `json:"inputs,omitempty"`
|
|
Outputs []*Output `json:"outputs,omitempty"`
|
|
Providers []*Provider `json:"providers,omitempty"`
|
|
}
|
|
|
|
type Input struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type,omitempty"`
|
|
Description string `json:"description,omitempty"`
|
|
Default string `json:"default,omitempty"`
|
|
Required bool `json:"required"`
|
|
}
|
|
|
|
type Output struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
type Provider struct {
|
|
Name string `json:"name"`
|
|
Source string `json:"source,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
}
|