meta

package
v2.56.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CredentialsSourceEnvironment     = "Environment variable"
	CredentialsSourceDefault         = "Default"
	CredentialsSourceActiveProfile   = "Active Profile in config.yaml"
	CredentialsSourceProviderProfile = "Profile defined in provider{} block"
	CredentialsSourceInferred        = "CredentialsSourceInferred from default zone"
)

Variables

View Source
var ErrProjectIDNotFound = errors.New("could not detect project id")

ErrProjectIDNotFound is returned when no region can be detected

Functions

func ExtractHTTPClient

func ExtractHTTPClient(m any) *http.Client

func ExtractProjectID

func ExtractProjectID(d terraformResourceData, m any) (projectID string, isDefault bool, err error)

ExtractProjectID will try to guess the project id from the following:

  • project_id field of the resource data
  • default project id from config

func ExtractRegion

func ExtractRegion(d terraformResourceData, m any) (scw.Region, error)

ExtractRegion will try to guess the region from the following:

  • region field of the resource data
  • default region from config

func ExtractRegionWithDefault

func ExtractRegionWithDefault(d terraformResourceData, m any, defaultRegion scw.Region) (scw.Region, error)

ExtractRegionWithDefault will try to guess the region from the following:

  • region field of the resource data
  • default region given in argument
  • default region from config

func ExtractScwClient

func ExtractScwClient(m any) *scw.Client

func ExtractZone

func ExtractZone(d terraformResourceData, m any) (scw.Zone, error)

ExtractZone will try to guess the zone from the following:

  • zone field of the resource data
  • default zone from config

func GetRawConfigForKey added in v2.39.0

func GetRawConfigForKey(d *schema.ResourceData, key string, ty cty.Type) (any, bool)

GetRawConfigForKey returns the value for a specific key in the user's raw configuration, which can be useful on resources' update The value for the key to look for must be a primitive type (bool, string, number) and the expected type of the value should be passed as the ty parameter

Types

type Config

type Config struct {
	ProviderSchema      *schema.ResourceData
	HTTPClient          *http.Client
	TerraformVersion    string
	ForceZone           scw.Zone
	ForceProjectID      string
	ForceOrganizationID string
	ForceAccessKey      string
	ForceSecretKey      string
}

type CredentialsSource added in v2.41.2

type CredentialsSource struct {
	Variables     map[string][]string
	AccessKey     string
	SecretKey     string
	ProjectID     string
	DefaultZone   string
	DefaultRegion string
}

func GetCredentialsSource added in v2.41.2

func GetCredentialsSource(defaultZoneProfile, activeProfile, providerProfile, envProfile *scw.Profile) *CredentialsSource

GetCredentialsSource infers the source of the credentials based on the priority order of the different profiles

type Meta

type Meta struct {
	// contains filtered or unexported fields
}

Meta contains config and SDK clients used by resources.

This meta value is passed into all resources.

func NewMeta

func NewMeta(ctx context.Context, config *Config) (*Meta, error)

NewMeta creates the Meta object containing the SDK client.

func (Meta) AccessKeySource added in v2.41.2

func (m Meta) AccessKeySource() string

func (Meta) HTTPClient

func (m Meta) HTTPClient() *http.Client

func (Meta) HasMultipleVariableSources added in v2.56.0

func (m Meta) HasMultipleVariableSources() (bool, string, error)

HasMultipleVariableSources return an informative message during the Provider initialization if there are multiple sources of configuration that could confuse the user

Variable AvailableSources Using SCW_ACCESS_KEY Active Profile in config.yaml, Environment variable Environment variable SCW_SECRET_KEY Active Profile in config.yaml, Environment variable Environment variable

func (Meta) ProjectIDSource added in v2.41.2

func (m Meta) ProjectIDSource() string

func (Meta) RegionSource added in v2.41.2

func (m Meta) RegionSource() string

func (Meta) ScwClient

func (m Meta) ScwClient() *scw.Client

func (Meta) SecretKeySource added in v2.41.2

func (m Meta) SecretKeySource() string

func (Meta) ZoneSource added in v2.41.2

func (m Meta) ZoneSource() string

Jump to

Keyboard shortcuts

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