install

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package install finds provider plugins that OpenTofu or Terraform already downloaded, and asks them to download missing ones.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoBinary = errors.New("neither tofu nor terraform was found in PATH; install OpenTofu (https://opentofu.org) or pass --tf-binary")

ErrNoBinary means neither tofu nor terraform could be found.

View Source
var KnownSources = map[string]string{
	"alicloud":      "aliyun/alicloud",
	"auth0":         "auth0/auth0",
	"aws":           "hashicorp/aws",
	"azuread":       "hashicorp/azuread",
	"azuredevops":   "microsoft/azuredevops",
	"azurerm":       "hashicorp/azurerm",
	"cloudflare":    "cloudflare/cloudflare",
	"commercetools": "labd/commercetools",
	"datadog":       "DataDog/datadog",
	"digitalocean":  "digitalocean/digitalocean",
	"fastly":        "fastly/fastly",
	"github":        "integrations/github",
	"gitlab":        "gitlabhq/gitlab",
	"gmailfilter":   "yamamoto-febc/gmailfilter",
	"google":        "hashicorp/google",
	"google-beta":   "hashicorp/google-beta",
	"grafana":       "grafana/grafana",
	"heroku":        "heroku/heroku",
	"honeycombio":   "honeycombio/honeycombio",
	"ibm":           "IBM-Cloud/ibm",
	"ionoscloud":    "ionos-cloud/ionoscloud",
	"keycloak":      "keycloak/keycloak",
	"kubernetes":    "hashicorp/kubernetes",
	"launchdarkly":  "launchdarkly/launchdarkly",
	"linode":        "linode/linode",
	"logzio":        "logzio/logzio",
	"mackerel":      "mackerelio-labs/mackerel",
	"metal":         "equinix/metal",
	"mikrotik":      "ddelnano/mikrotik",
	"myrasec":       "Myra-Security-GmbH/myrasec",
	"newrelic":      "newrelic/newrelic",
	"ns1":           "ns1-terraform/ns1",
	"octopusdeploy": "OctopusDeployLabs/octopusdeploy",
	"okta":          "okta/okta",
	"opal":          "opalsecurity/opal",
	"openstack":     "terraform-provider-openstack/openstack",
	"opsgenie":      "opsgenie/opsgenie",
	"pagerduty":     "PagerDuty/pagerduty",
	"panos":         "PaloAltoNetworks/panos",
	"rabbitmq":      "cyrilgdn/rabbitmq",
	"tencentcloud":  "tencentcloudstack/tencentcloud",
	"vault":         "hashicorp/vault",
	"vultr":         "vultr/vultr",
	"xenorchestra":  "vatesfr/xenorchestra",

	"yandex": "registry.terraform.io/yandex-cloud/yandex",
}

KnownSources maps the provider names used in resource type prefixes to their registry addresses. Terraformer wrote most of these providers into required_providers without a source, which silently meant hashicorp/<name> and broke `init` for every provider not published by HashiCorp.

View Source
var Registries = []string{"registry.opentofu.org", "registry.terraform.io"}

Registries are searched in this order. OpenTofu comes first because its registry mirrors almost every provider and needs no account.

Functions

func SearchDirs

func SearchDirs() []string

SearchDirs lists the directories that may hold unpacked providers, most specific first: the current working directory's .terraform, the plugin cache, then the per-user plugin directories.

Types

type Installer

type Installer struct {
	// Binary is the tofu or terraform executable. Empty means look for tofu,
	// then terraform, in PATH.
	Binary string
	// CacheDir holds one working directory per provider.
	CacheDir string
}

Installer downloads providers with the tofu or terraform binary, so that checksums, mirrors and credentials work exactly as the user configured.

func (*Installer) Ensure

func (in *Installer) Ensure(ctx context.Context, src Source, constraint string) (*Provider, error)

Ensure returns an installed provider, running `init` in a private working directory when it is not installed yet. constraint may be empty.

func (*Installer) FindBinary

func (in *Installer) FindBinary() (string, error)

FindBinary returns the tofu or terraform executable to use.

type Provider

type Provider struct {
	Source  string // "hashicorp/aws"
	Version string // "6.14.1"
	Path    string
}

Provider is a provider binary on disk.

func Find

func Find(src Source, dirs []string) (*Provider, error)

Find returns the newest installed build of the provider for this platform.

type Source

type Source struct {
	Host      string
	Namespace string
	Type      string
}

Source is the registry address of a provider. Host is empty for the default registry of whichever tool installs the provider.

func ParseSource

func ParseSource(s string) (Source, error)

ParseSource accepts "type", "namespace/type" or "host/namespace/type". A bare type means the hashicorp namespace, as in required_providers.

func SourceFor

func SourceFor(name string) Source

SourceFor returns the registry address for a provider name, falling back to the hashicorp namespace the way required_providers does.

func (Source) String

func (s Source) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL