provider

package
v0.0.0-...-d1645de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenSchemaBot

func GenSchemaBot(ctx context.Context) (tfsdk.Schema, diag.Diagnostics)

func New

func New() tfsdk.Provider

New returns an empty provider struct

Types

type Bot

type Bot struct {
	ID      types.String   `tfsdk:"id"`
	Name    types.String   `tfsdk:"name"`
	Roles   []types.String `tfsdk:"roles"`
	TokenID types.String   `tfsdk:"token_id"`
	Traits  types.Map      `tfsdk:"traits"`
	TTL     types.String   `tfsdk:"token_ttl"`

	UserName types.String `tfsdk:"user_name"`
	RoleName types.String `tfsdk:"role_name"`
}

Bot is a deserializes representation of the terraform state for this resource.

type CredentialSource

type CredentialSource interface {
	Name() string
	IsActive(providerData) (bool, string)
	Credentials(context.Context, providerData) (client.Credentials, error)
}

CredentialSource is a potential way for the Terraform provider to obtain the client.Credentials needed to connect to the Teleport cluster. A CredentialSource is active if the user specified configuration specific to this source. Only active CredentialSources are considered by the Provider.

type CredentialSources

type CredentialSources []CredentialSource

CredentialSources is a list of CredentialSource

func (CredentialSources) ActiveSources

func (s CredentialSources) ActiveSources(ctx context.Context, config providerData) (CredentialSources, diag.Diagnostics)

ActiveSources returns the list of active sources, and an error diagnostic if no source is active. The error diagnostic explains why every source is inactive.

func (CredentialSources) BuildClient

func (s CredentialSources) BuildClient(ctx context.Context, clientCfg client.Config, providerCfg providerData) (*client.Client, diag.Diagnostics)

BuildClient sequentially builds credentials for every source and tries to use them to connect to Teleport. Any CredentialSource failing to return a Credential and a tls.Config causes a hard failure. If we have a valid credential but cannot connect, we send a warning and continue with the next credential (this is for backward compatibility). Expired credentials are skipped for the sake of UX. This is the most common failure mode and we can return an error quickly instead of hanging for 30 whole seconds.

type CredentialsFromIdentityFileBase64

type CredentialsFromIdentityFileBase64 struct{}

CredentialsFromIdentityFileBase64 builds credentials from an identity file passed as a base64-encoded string.

func (CredentialsFromIdentityFileBase64) Credentials

func (CredentialsFromIdentityFileBase64) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromIdentityFileBase64) IsActive

func (CredentialsFromIdentityFileBase64) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromIdentityFileBase64) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromIdentityFilePath

type CredentialsFromIdentityFilePath struct{}

CredentialsFromIdentityFilePath builds credentials from an identity file path.

func (CredentialsFromIdentityFilePath) Credentials

func (CredentialsFromIdentityFilePath) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromIdentityFilePath) IsActive

func (CredentialsFromIdentityFilePath) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromIdentityFilePath) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromIdentityFileString

type CredentialsFromIdentityFileString struct{}

CredentialsFromIdentityFileString builds credentials from an identity file passed as a string.

func (CredentialsFromIdentityFileString) Credentials

func (CredentialsFromIdentityFileString) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromIdentityFileString) IsActive

func (CredentialsFromIdentityFileString) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromIdentityFileString) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromKeyAndCertBase64

type CredentialsFromKeyAndCertBase64 struct{}

CredentialsFromKeyAndCertBase64 builds credentials from key, cert, and CA cert base64.

func (CredentialsFromKeyAndCertBase64) Credentials

func (CredentialsFromKeyAndCertBase64) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromKeyAndCertBase64) IsActive

func (CredentialsFromKeyAndCertBase64) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromKeyAndCertBase64) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromKeyAndCertPath

type CredentialsFromKeyAndCertPath struct{}

CredentialsFromKeyAndCertPath builds credentials from key, cert and ca cert paths.

func (CredentialsFromKeyAndCertPath) Credentials

func (CredentialsFromKeyAndCertPath) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromKeyAndCertPath) IsActive

func (CredentialsFromKeyAndCertPath) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromKeyAndCertPath) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromNativeMachineID

type CredentialsFromNativeMachineID struct{}

CredentialsFromNativeMachineID builds credentials by performing a MachineID join and

func (CredentialsFromNativeMachineID) Credentials

func (CredentialsFromNativeMachineID) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromNativeMachineID) IsActive

func (CredentialsFromNativeMachineID) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromNativeMachineID) Name

Name implements CredentialSource and returns the source name.

type CredentialsFromProfile

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

CredentialsFromProfile builds credentials from a local tsh profile.

func (CredentialsFromProfile) Credentials

func (CredentialsFromProfile) Credentials(ctx context.Context, config providerData) (client.Credentials, error)

Credentials implements CredentialSource and returns a client.Credentials for the provider.

func (CredentialsFromProfile) IsActive

func (c CredentialsFromProfile) IsActive(config providerData) (bool, string)

IsActive implements CredentialSource and returns if the source is active and why.

func (CredentialsFromProfile) Name

func (c CredentialsFromProfile) Name() string

Name implements CredentialSource and returns the source name.

type Provider

type Provider struct {
	Client      *client.Client
	RetryConfig RetryConfig
	// contains filtered or unexported fields
}

Provider Teleport Provider

func (*Provider) Close

func (p *Provider) Close() error

Close closes the provider's client and cancels its context. This is needed in the tests to avoid accumulating clients and running out of file descriptors.

func (*Provider) Configure

Configure configures the Teleport client

func (*Provider) GetDataSources

func (p *Provider) GetDataSources(_ context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics)

GetDataSources returns the map of provider data sources

func (*Provider) GetResources

func (p *Provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceType, diag.Diagnostics)

GetResources returns the map of provider resources

func (*Provider) GetSchema

func (p *Provider) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics)

GetSchema returns the Terraform provider schema

func (*Provider) IsConfigured

func (p *Provider) IsConfigured(diags diag.Diagnostics) bool

IsConfigured checks if provider is configured, adds diagnostics if not

type RetryConfig

type RetryConfig struct {
	Base     time.Duration
	Cap      time.Duration
	MaxTries int
}

Source Files

Jump to

Keyboard shortcuts

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