MCPcopy Index your code
hub / github.com/devoteamgcloud/petra

github.com/devoteamgcloud/petra @v0.4.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.2 ↗ · + Follow
25 symbols 64 edges 13 files 3 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README


Petra (Private Terraform Registry)

Latest Release Build Status Documentation Linter Release

Petra is a lightweight tool that allows to host your own private Terraform registry using Google Cloud Storage as a storage backend.

Petra is not an official Devoteam product and is provided as-is to the community.

Welcome to VHS

Components

petra (server)

Server to get a terraform module versions / get a signed URL to download a module from a private registry (Google Cloud Storage bucket). Configured by the following env vars :
- GCS_BUCKET: Bucket used to host Terraform modules
- SIGNED_URL: (Optional) Enables the use of a Signed URL for the download api routes. Defaults to false and just forwards a gcs:// link

petractl (cli)

CLI to upload / remove / upload a terraform module to a private registry (Google Cloud Storage bucket).

Example usage :
bash petractl push --bucket tf-registry-petra ../tests/mod1

Deployment

Deploy Server on Cloud Run

Cloud Run's service account must have the following roles:

  • Service Account Token Creator (used to create signed url)
  • Storage Object Admin (access objects in bucket) for the bucket where you store the terraform modules.

Then terraform init:

// main.tf
module "my_module" {
  source  = "{CLOUD_RUN_URL}/{NAMESPACE}/{MODULE}/{PROVIDER}/{VERSION}"
}

or specify the module version separately :

// main.tf
module "my_module" {
  source  = "{CLOUD_RUN_URL}/{NAMESPACE}/{MODULE}/{PROVIDER}"
  version = "{VERSION}"
}

Deploy Server on GKE with Workload Identity

Activate Workload Identity and the service account must have the following roles:

  • Service Account Token Creator (create signed url)
  • Storage Object Admin (access objects in bucket) for the bucket where you store the terraform modules

Then terraform init:

// main.tf
module "my_module" {
  source  = "{PETRA_SERVER}/{NAMESPACE}/{MODULE}/{PROVIDER}"
  version = "{VERSION}"
}

Development

Follow these steps if you are OK installing and using Go on your machine.

  1. Install Go.
  2. Install Visual Studio Code.
  3. Install Go extension.
  4. Clone and open this repository.
  5. F1 -> Go: Install/Update Tools -> (select all) -> OK.

Release

The release workflow is triggered each time a tag with v prefix is pushed.

CAUTION: Make sure to understand the consequences before you bump the major version. More info: Go Wiki, Go Blog.

Maintainance

Remember to update Go version in .github/workflows

Notable files:

Contributing

Simply create an issue or a pull request.

FAQ

How can I customize the release or add deb/rpm/snap packages, Homebrew Tap, Scoop App Manifest etc

Take a look at GoReleaser docs as well as its repo how it is dogfooding its functionality.

Core symbols most depended-on inside this repo

modPath
called by 2
internal/modules/modules.go
processModule
called by 2
internal/modules/package.go
InitGCSBackend
called by 2
internal/storage/gcs.go
modPathPartial
called by 1
internal/modules/modules.go
PackageModules
called by 1
internal/modules/package.go
archiveModule
called by 1
internal/modules/package.go
UploadModule
called by 1
internal/storage/upload.go
GetModule
called by 1
internal/storage/download.go

Shape

Function 17
Struct 4
Method 3
TypeAlias 1

Languages

Go100%

Modules by API surface

internal/modules/modules.go4 symbols
internal/modules/package.go3 symbols
internal/modules/list.go3 symbols
internal/storage/gcs.go2 symbols
internal/routes/service-discovery.go2 symbols
internal/routes/modules.go2 symbols
cmd/server/server.go2 symbols
cmd/cli/main.go2 symbols
internal/storage/upload.go1 symbols
internal/storage/list.go1 symbols
internal/storage/download.go1 symbols
internal/modules/download.go1 symbols

For agents

$ claude mcp add petra \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact