provider

package
v0.0.0-...-78a3963 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Unlicense Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyAddressFilter   = "address_filter"
	KeyAddressPriority = "address_priority"
	KeyNixosInstance   = "nixos_instance"
	KeyAddress         = "address"
	KeySystem          = "system"
	KeySettings        = "settings"
	KeyConfiguration   = "configuration"
	KeyRetry           = "retry"
	KeyRetryWait       = "retry_wait"

	KeyNix             = "nix"
	KeyNixMode         = "mode"
	KeyNixBuildWrapper = "build_wrapper"

	KeyNixProfile          = "profile"
	KeyNixOutputName       = "output"
	KeyNixActivationScript = "activation_script"
	KeyNixActivationAction = "activation_action"

	KeyNixShowTrace      = "show_trace"
	KeyNixCores          = "cores"
	KeyNixUseSubstitutes = "use_substitutes"

	KeySsh       = "ssh"
	KeySshHost   = "host"
	KeySshUser   = "user"
	KeySshPort   = "port"
	KeySshConfig = "config"

	KeyBastion = "bastion"

	KeySecrets = "secrets"

	KeySecretFingerprint              = "secret_fingerprint"
	KeySecretFingerprintSum           = "sum"
	KeySecretFingerprintSalt          = "salt"
	KeySecretFingerprintKdfIterations = "kdf_iterations"

	KeySecretsProvider                   = "provider"
	KeySecretsProviderFilesystem         = "filesystem"
	KeySecretsProviderCommand            = "command"
	KeySecretsProviderCommandName        = "name"
	KeySecretsProviderCommandArguments   = "arguments"
	KeySecretsProviderCommandEnvironment = "environment"
	KeySecretsProviderGopass             = "gopass"
	KeySecretsProviderGopassStore        = "store"

	KeySecret            = "secret"
	KeySecretSource      = "source"
	KeySecretDestination = "destination"
	KeySecretOwner       = "owner"
	KeySecretGroup       = "group"
	KeySecretPermissions = "permissions"

	KeyDerivations       = "derivations"
	KeyDerivationPath    = "path"
	KeyDerivationOutputs = "outputs"
)
View Source
const (
	SshConfigKeyHost         = "host"
	SshConfigKeyUser         = "user"
	SshConfigKeyPort         = "port"
	SshConfigKeyProxyCommand = "proxyCommand"
)
View Source
const (
	DefaultUser = "root"
)
View Source
const (
	NixEnvironmentSshOpts = "NIX_SSHOPTS"
)
View Source
const SecretDataKeyLen = 32

Variables

View Source
var (
	ProviderSchemaSshMap = map[string]*schema.Schema{
		KeySshUser: {
			Description: "SSH remote user name",
			Type:        schema.TypeString,
			Optional:    true,
			Default:     DefaultUser,
		},
		KeySshPort: {
			Description: "SSH remote port",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		KeySshConfig: {
			Description: "SSH configuration map",
			Type:        schema.TypeMap,
			Elem:        &schema.Schema{Type: schema.TypeString},
			Optional:    true,
			DefaultFunc: DefaultSshConfig,
		},
	}
	ProviderSchemaSsh = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "SSH protocol settings",
		Type:        schema.TypeSet,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: ProviderSchemaSshMap,
		},
		Optional: true,
	})

	ProviderSchemaBastionMap = SchemaMapExtend(
		ProviderSchemaSshMap,
		map[string]*schema.Schema{
			KeySshHost: {
				Description: "SSH bastion remote hostname",
				Type:        schema.TypeString,
				Optional:    true,
			},
		},
	)
	ProviderSchemaBastion = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "SSH configuration for bastion server",
		Type:        schema.TypeSet,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: ProviderSchemaBastionMap,
		},
		Optional: true,
	})

	ProviderSchemaSecretsProviderFilesystem = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "Filesystem secrets provider settings",
		Type:        schema.TypeSet,
		MinItems:    0,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{},
		},
		Optional: true,
	})
	ProviderSchemaSecretsProviderCommand = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "Command secrets provider settings",
		Type:        schema.TypeSet,
		MinItems:    0,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				KeySecretsProviderCommandName: {
					Description: "Provider command name (will be looked up in PATH) to use to retrieve secret",
					Type:        schema.TypeString,
					Required:    true,
				},
				KeySecretsProviderCommandArguments: {
					Description: "Provider command arguments to prepend to secret source",
					Type:        schema.TypeList,
					Elem:        &schema.Schema{Type: schema.TypeString},
					Optional:    true,
				},
				KeySecretsProviderCommandEnvironment: {
					Description: "Provider command environment variables",
					Type:        schema.TypeMap,
					Elem:        &schema.Schema{Type: schema.TypeString},
					Optional:    true,
				},
			},
		},
		Optional: true,
	})
	ProviderSchemaSecretsProviderGopass = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "GoPass secrets provider settings",
		Type:        schema.TypeSet,
		MinItems:    0,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				KeySecretsProviderGopassStore: {
					Description: "Password store directory location",
					Type:        schema.TypeString,
					Optional:    true,
				},
			},
		},
		Optional: true,
	})
	ProviderSchemaSecretsMap = map[string]*schema.Schema{
		KeySecretsProvider: {
			Description: fmt.Sprintf("Secrets provider to use, available: %v", SecretsProviders),
			Type:        schema.TypeString,
			Optional:    true,
			Default:     string(SecretsProviderNameFilesystem),
		},
		KeySecretsProviderFilesystem: ProviderSchemaSecretsProviderFilesystem,
		KeySecretsProviderCommand:    ProviderSchemaSecretsProviderCommand,
		KeySecretsProviderGopass:     ProviderSchemaSecretsProviderGopass,
	}
	ProviderSchemaSecrets = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "Describes secrets settings",
		Type:        schema.TypeSet,
		MinItems:    0,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: ProviderSchemaSecretsMap,
		},
		Optional: true,
	})
	ProviderSchemaSecretFingerprint = &schema.Schema{
		Description: "Secrets state fingerprint information which is used to maintain state",
		Type:        schema.TypeMap,
		Elem:        &schema.Schema{Type: schema.TypeString},
		Computed:    true,
	}
	ProviderSchemaSecret = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "Describes secret which should be transfered to host",
		Type:        schema.TypeSet,
		MinItems:    0,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				KeySecretSource: {
					Description: "Secret file on the host which should be transfered to destination",
					Type:        schema.TypeString,
					Required:    true,
				},
				KeySecretDestination: {
					Description: "Secret file destination on the target host",
					Type:        schema.TypeString,
					Required:    true,
				},
				KeySecretOwner: {
					Description: "Secret file owner username",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "root",
				},
				KeySecretGroup: {
					Description: "Secret file owner groupname",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "root",
				},
				KeySecretPermissions: {
					Description: "Secret file destination permissions (in octal)",
					Type:        schema.TypeInt,
					Optional:    true,
					Default:     600,
				},
			},
		},
		Optional: true,
	})

	ProviderSchemaDerivationsComputedMap = map[string]*schema.Schema{

		KeyDerivationPath: {
			Description: "Path to the derivation in Nix store",
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
		},
		KeyDerivationOutputs: {
			Description: "Derivation outputs paths in the Nix store",
			Type:        schema.TypeMap,
			Elem:        &schema.Schema{Type: schema.TypeString},
			Optional:    true,
			Computed:    true,
		},
	}

	ProviderSchemaNix = SchemaWithDefaultFuncCtr(DefaultMapFromSchema, &schema.Schema{
		Description: "Nix package manager configuration options",
		Type:        schema.TypeSet,
		MaxItems:    1,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				KeyNixMode: {
					Description: "Nix mode (0 - compat, 1 - default)",
					Type:        schema.TypeInt,
					Optional:    true,
					Default:     int(NixModeCompat),
				},
				KeyNixBuildWrapper: {
					Description: "Path to the configuration wrapper in Nix language (function which returns drv_path & out_path)",
					Type:        schema.TypeString,
					Optional:    true,
				},
				KeyNixProfile: {
					Description: "Path to the current system profile",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "/nix/var/nix/profiles/system",
				},
				KeyNixOutputName: {
					Description: "System derivation output name",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "out",
				},
				KeyNixActivationScript: {
					Description: "Path to the system profile activation script",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "/nix/var/nix/profiles/system/bin/switch-to-configuration",
				},
				KeyNixActivationAction: {
					Description: "Activation script action, one of: switch|boot|test|dry-activate",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "switch",
				},
				KeyNixShowTrace: {
					Description: "Show Nix package manager trace on error",
					Type:        schema.TypeBool,
					Optional:    true,
					Default:     true,
				},
				KeyNixCores: {
					Description: "Number of CPU cores  which Nix should use to perform builds",
					Type:        schema.TypeInt,
					Optional:    true,
				},
				KeyNixUseSubstitutes: {
					Description: "Whether or not should Nix use substitutes",
					Type:        schema.TypeBool,
					Optional:    true,
					Default:     true,
				},
			},
		},
		Optional: true,
	})

	ProviderSchemaMap = map[string]*schema.Schema{
		KeyRetry: {
			Description: "Amount of retries for retryable operations",
			Type:        schema.TypeInt,
			Optional:    true,
			Default:     5,
		},
		KeyRetryWait: {
			Description: "Amount of seconds to wait between retries",
			Type:        schema.TypeInt,
			Optional:    true,
			Default:     5,
		},

		KeyAddressFilter: {
			Description: "List of network cidr's to filter addresses used to connect to nixos_instance resources",
			Type:        schema.TypeList,
			Elem:        &schema.Schema{Type: schema.TypeString},
			Optional:    true,
			DefaultFunc: DefaultAddressFilter,
		},
		KeyAddressPriority: {
			Description: "Map of network cidr's with associated weight which will affect address ordering for nixos_isntance resource",
			Type:        schema.TypeMap,
			Elem:        &schema.Schema{Type: schema.TypeInt},
			Optional:    true,
			DefaultFunc: DefaultAddressPriority,
		},

		KeyNix:     ProviderSchemaNix,
		KeySsh:     ProviderSchemaSsh,
		KeyBastion: ProviderSchemaBastion,
		KeySecrets: ProviderSchemaSecrets,
		KeySecret:  ProviderSchemaSecret,
	}

	ProviderResourceMap = map[string]*schema.Resource{
		KeyNixosInstance: {
			Description: "NixOS instance",

			CustomizeDiff: instance.Diff,
			CreateContext: instance.Create,
			ReadContext:   instance.Read,
			UpdateContext: instance.Update,
			DeleteContext: instance.Delete,

			Schema: map[string]*schema.Schema{
				KeyAddress: {
					Description: "List of server addresses",
					Type:        schema.TypeList,
					Elem:        &schema.Schema{Type: schema.TypeString},
					Required:    true,
				},
				KeySystem: {
					Description: "Nix arch & target to build for (defaults to x86_64-linux)",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "x86_64-linux",
				},
				KeySettings: {
					Description: "Optional settings (encoded with HCL function jsonencode()) to pass into Nix configuration derivation as attribute set (any configuration key could be specified)",
					Type:        schema.TypeString,
					Optional:    true,
					Default:     "{}",
				},
				KeyConfiguration: {
					Description: "Path to Nix derivation",
					Type:        schema.TypeString,
					Required:    true,
				},

				KeyNix:     ProviderSchemaNix,
				KeySsh:     ProviderSchemaSsh,
				KeyBastion: ProviderSchemaBastion,
				KeySecrets: ProviderSchemaSecrets,
				KeySecret:  ProviderSchemaSecret,

				KeySecretFingerprint: ProviderSchemaSecretFingerprint,
				KeyDerivations: {
					Description: "List of derivations which is built during apply",
					Type:        schema.TypeList,
					Elem:        &schema.Resource{Schema: ProviderSchemaDerivationsComputedMap},
					Optional:    true,
					Computed:    true,
				},
			},
		},
	}

	ProviderSchema = schema.Provider{
		Schema:       ProviderSchemaMap,
		ResourcesMap: ProviderResourceMap,
	}
)
View Source
var NixWrapper []byte

Functions

func CommandExecute

func CommandExecute(command string, arguments []string, options ...CommandOption) ([]byte, error)

func CommandExecuteUnmarshal

func CommandExecuteUnmarshal(command string, arguments []string, unmarshaler Unmarshaler, result interface{}, options ...CommandOption) error

func DefaultAddressFilter

func DefaultAddressFilter() (interface{}, error)

func DefaultAddressPriority

func DefaultAddressPriority() (interface{}, error)

func DefaultSshConfig

func DefaultSshConfig() (interface{}, error)

func HashAny

func HashAny(v interface{}) int

func New

func New() *schema.Provider

func Readln

func Readln(r *bufio.Reader) ([]byte, error)

func SchemaMapExtend

func SchemaMapExtend(original, extension map[string]*schema.Schema) map[string]*schema.Schema

func SchemaWithDefaultFuncCtr

func SchemaWithDefaultFuncCtr(ctr SchemaDefaultFuncCtr, s *schema.Schema) *schema.Schema

func SshSerializeConfig

func SshSerializeConfig(ps SshConfigPairs) string

Types

type CIDR

type CIDR struct {
	IP IP
	*net.IPNet
}

func ParseCIDR

func ParseCIDR(addr string) (*CIDR, error)

type Cmd

type Cmd struct {
	*exec.Cmd
	PreRunHooks []func(*Cmd)
	Stdout      *bytes.Buffer
	Stderr      *bytes.Buffer
	Env         Environment
}

func (*Cmd) Run

func (c *Cmd) Run() ([]byte, []byte, error)

type Command

type Command interface {
	Command() (string, []string, []CommandOption)
	Execute(result CommandResult) error
	Close() error
}

type CommandOption

type CommandOption func(*Cmd)

func CommandOptionEnv

func CommandOptionEnv(env Environment) CommandOption

func CommandOptionStdin

func CommandOptionStdin(stdin io.Reader) CommandOption

func CommandOptionTflogTee

func CommandOptionTflogTee(ctx context.Context) CommandOption

type CommandResult

type CommandResult = interface{}

type Derivation

type Derivation struct {
	Path    string            `json:"drvPath" mapstructure:"path"`
	Outputs map[string]string `json:"outputs" mapstructure:"outputs"`
}

func (Derivation) Hash

func (d Derivation) Hash() string

type Derivations

type Derivations []Derivation

func (Derivations) Hash

func (ds Derivations) Hash() string

type Enclave

type Enclave = memguard.Enclave

type Environment

type Environment map[string][]string

func NewEnvironment

func NewEnvironment(vars ...map[string][]string) Environment

func (Environment) Add

func (e Environment) Add(key string, value ...string) Environment

func (Environment) Copy

func (e Environment) Copy() Environment

func (Environment) Del

func (e Environment) Del(key string) Environment

func (Environment) Set

func (e Environment) Set(key string, value ...string) Environment

func (Environment) Slice

func (e Environment) Slice() []string

func (Environment) With

func (e Environment) With(ee Environment) Environment

TODO: by default we expect "Add" semantics but at some point in time we may need "Set" semantics so it probably should be injectable

type File

type File interface {
	Name() string
	Seek(offset int64, whence int) (ret int64, err error)
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Close() error
}

func NewNixWrapperFile

func NewNixWrapperFile(path string) (File, error)

type IP

type IP = net.IP

func FilterIPAddress

func FilterIPAddress(filter []*CIDR, in []IP) []IP

func ParseIP

func ParseIP(addr string) IP

func SortIPAddress

func SortIPAddress(priority map[*IPNet]int, in []IP) []IP

func ToIPAddrs

func ToIPAddrs(in interface{}) []IP

type IPNet

type IPNet = net.IPNet

type Instance

type Instance struct{}

func (Instance) Create

func (i Instance) Create(ctx context.Context, resource *schema.ResourceData, meta interface{}) diag.Diagnostics

func (Instance) Delete

func (i Instance) Delete(ctx context.Context, resource *schema.ResourceData, meta interface{}) diag.Diagnostics

func (Instance) Diff

func (i Instance) Diff(ctx context.Context, resource *schema.ResourceDiff, meta interface{}) error

func (Instance) Read

func (i Instance) Read(ctx context.Context, resource *schema.ResourceData, meta interface{}) diag.Diagnostics

func (Instance) Update

func (i Instance) Update(ctx context.Context, resource *schema.ResourceData, meta interface{}) diag.Diagnostics

type LockedBuffer

type LockedBuffer = memguard.LockedBuffer

func NewLockedBuffer

func NewLockedBuffer(buf []byte) *LockedBuffer

type LogWriter

type LogWriter struct {
	Context context.Context
}

func NewLogWriter

func NewLogWriter(ctx context.Context) *LogWriter

func (*LogWriter) Write

func (w *LogWriter) Write(buf []byte) (int, error)

type Memo

type Memo struct {
	sync.RWMutex
	Store map[string][]byte
}

func (*Memo) Get

func (m *Memo) Get(key string) ([]byte, bool)

func (*Memo) Set

func (m *Memo) Set(key string, value []byte)

type Nix

type Nix struct {
	Mode           NixMode
	Arguments      []string
	CommandOptions []CommandOption
	Environment    Environment
	Ssh            *Ssh
}

func NewNix

func NewNix(options ...NixOption) *Nix

func (*Nix) Build

func (n *Nix) Build(options ...NixBuildCommandOption) *NixBuildCommand

func (*Nix) Close

func (n *Nix) Close() error

func (*Nix) Command

func (n *Nix) Command() (string, []string, []CommandOption)

func (*Nix) Copy

func (n *Nix) Copy(options ...NixCopyCommandOption) *NixCopyCommand

func (*Nix) Execute

func (n *Nix) Execute(result interface{}) error

func (*Nix) Profile

func (n *Nix) Profile(options ...NixProfileCommandOption) *NixProfileCommand

func (*Nix) With

func (n *Nix) With(options ...NixOption) *Nix

type NixActivationAction

type NixActivationAction = string
const (
	NixActivationActionNone        NixActivationAction = ""
	NixActivationActionSwitch      NixActivationAction = "switch"
	NixActivationActionBoot        NixActivationAction = "boot"
	NixActivationActionTest        NixActivationAction = "test"
	NixActivationActionDryActivate NixActivationAction = "dry-activate"
)

type NixBuildCommand

type NixBuildCommand struct {
	Nix       *Nix
	Arguments []string
	Memoize   bool
	MemoKey   string
	Unmarshaler
}

func (*NixBuildCommand) Close

func (n *NixBuildCommand) Close() error

func (*NixBuildCommand) Command

func (n *NixBuildCommand) Command() (string, []string, []CommandOption)

func (*NixBuildCommand) Execute

func (n *NixBuildCommand) Execute(result interface{}) error

type NixBuildCommandOption

type NixBuildCommandOption func(*NixBuildCommand)

func NixBuildCommandOptionArg

func NixBuildCommandOptionArg(name string, expr string) NixBuildCommandOption

func NixBuildCommandOptionArgStr

func NixBuildCommandOptionArgStr(name string, value string) NixBuildCommandOption

func NixBuildCommandOptionFile

func NixBuildCommandOptionFile(fd File) NixBuildCommandOption

func NixBuildCommandOptionJSON

func NixBuildCommandOptionJSON() NixBuildCommandOption

func NixBuildCommandOptionMemoize

func NixBuildCommandOptionMemoize(key string) NixBuildCommandOption
func NixBuildCommandOptionNoLink() NixBuildCommandOption

type NixCopyCommand

type NixCopyCommand struct {
	Nix       *Nix
	Arguments []string
}

func (*NixCopyCommand) Close

func (n *NixCopyCommand) Close() error

func (*NixCopyCommand) Command

func (n *NixCopyCommand) Command() (string, []string, []CommandOption)

func (*NixCopyCommand) Execute

func (n *NixCopyCommand) Execute(result interface{}) error

type NixCopyCommandOption

type NixCopyCommandOption func(*NixCopyCommand)

func NixCopyCommandOptionFrom

func NixCopyCommandOptionFrom(protocol NixCopyProtocol, from string) NixCopyCommandOption

func NixCopyCommandOptionPath

func NixCopyCommandOptionPath(path string) NixCopyCommandOption

func NixCopyCommandOptionTo

func NixCopyCommandOptionTo(protocol NixCopyProtocol, to string) NixCopyCommandOption

func NixCopyCommandOptionUseSubstitutes

func NixCopyCommandOptionUseSubstitutes() NixCopyCommandOption

type NixCopyProtocol

type NixCopyProtocol string
const (
	NixCopyProtocolNone NixCopyProtocol = ""
	NixCopyProtocolSSH  NixCopyProtocol = "ssh"
	NixCopyProtocolS3   NixCopyProtocol = "s3"
	NixCopyProtocolFile NixCopyProtocol = "file"
)

func (NixCopyProtocol) Path

func (n NixCopyProtocol) Path(path string) string

type NixFeature

type NixFeature = string
const (
	NixFeatureCommand NixFeature = "nix-command"
)

type NixMode

type NixMode uint8
const (
	NixModeCompat  NixMode = 0
	NixModeDefault NixMode = 1
)

type NixOption

type NixOption func(*Nix)

func NixOptionCores

func NixOptionCores(num int) NixOption

func NixOptionExperimentalFeatures

func NixOptionExperimentalFeatures(feature ...NixFeature) NixOption

func NixOptionMode

func NixOptionMode(mode NixMode) NixOption

func NixOptionShowTrace

func NixOptionShowTrace() NixOption

func NixOptionSsh

func NixOptionSsh(s *Ssh) NixOption

func NixOptionSshOpts

func NixOptionSshOpts(opts ...string) NixOption

func NixOptionUseSubstitutes

func NixOptionUseSubstitutes() NixOption

func NixOptionWithCommandOptions

func NixOptionWithCommandOptions(options ...CommandOption) NixOption

type NixProfileCommand

type NixProfileCommand struct {
	Nix       *Nix
	Arguments []string
}

func (*NixProfileCommand) Close

func (n *NixProfileCommand) Close() error

func (*NixProfileCommand) Command

func (n *NixProfileCommand) Command() (string, []string, []CommandOption)

func (*NixProfileCommand) Execute

func (n *NixProfileCommand) Execute(result interface{}) error

func (*NixProfileCommand) Install

type NixProfileCommandOption

type NixProfileCommandOption func(*NixProfileCommand)

type NixProfileInstallCommand

type NixProfileInstallCommand struct {
	Profile   *NixProfileCommand
	Arguments []string
}

func (*NixProfileInstallCommand) Close

func (n *NixProfileInstallCommand) Close() error

func (*NixProfileInstallCommand) Command

func (n *NixProfileInstallCommand) Command() (string, []string, []CommandOption)

func (*NixProfileInstallCommand) Execute

func (n *NixProfileInstallCommand) Execute(result interface{}) error

type NixProfileInstallCommandOption

type NixProfileInstallCommandOption func(*NixProfileInstallCommand)

func NixProfileInstallCommandOptionDerivation

func NixProfileInstallCommandOptionDerivation(path string) NixProfileInstallCommandOption

func NixProfileInstallCommandOptionProfile

func NixProfileInstallCommandOptionProfile(location string) NixProfileInstallCommandOption

type Provider

type Provider struct {
	ResourceBox
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(d ResourceBox) (*Provider, error)

func (*Provider) Address

func (p *Provider) Address(rawAddrs interface{}) (IP, error)

func (*Provider) BastionSettings

func (p *Provider) BastionSettings(resource ResourceBox) map[string]interface{}

func (*Provider) Build

func (p *Provider) Build(ctx context.Context, resource ResourceBox) (Derivations, error)

func (*Provider) Close

func (p *Provider) Close() error

func (*Provider) CopySecrets

func (p *Provider) CopySecrets(ctx context.Context, resource ResourceBox, secrets *Secrets) error

func (*Provider) NewNix

func (p *Provider) NewNix(ctx context.Context, resource ResourceBox) *Nix

func (*Provider) NewSecrets

func (p *Provider) NewSecrets(resource ResourceBox) (*Secrets, error)

func (*Provider) NewSsh

func (p *Provider) NewSsh(resource ResourceBox) *Ssh

func (*Provider) NixSettings

func (p *Provider) NixSettings(resource ResourceBox) map[string]interface{}

func (*Provider) Push

func (p *Provider) Push(ctx context.Context, resource ResourceBox, drvs Derivations) error

func (*Provider) SecretsSet

func (p *Provider) SecretsSet(resource ResourceBox) []map[string]interface{}

func (*Provider) SecretsSettings

func (p *Provider) SecretsSettings(resource ResourceBox) map[string]interface{}

func (*Provider) SshConfigMap

func (p *Provider) SshConfigMap(settings map[string]interface{}) *SshConfigMap

func (*Provider) SshSettings

func (p *Provider) SshSettings(resource ResourceBox) map[string]interface{}

func (*Provider) Switch

func (p *Provider) Switch(ctx context.Context, resource ResourceBox, drvs Derivations) error

type RemoteCommand

type RemoteCommand struct {
	Ssh *Ssh
	Cmd Command
}

func NewRemoteCommand

func NewRemoteCommand(s *Ssh, c Command) *RemoteCommand

func (*RemoteCommand) Close

func (c *RemoteCommand) Close() error

func (*RemoteCommand) Command

func (c *RemoteCommand) Command() (string, []string, []CommandOption)

func (*RemoteCommand) Execute

func (c *RemoteCommand) Execute(v interface{}) error

type ResourceBox

type ResourceBox interface {
	Get(string) interface{}
}

type ResourceData

type ResourceData struct {
	ResourceBox
	Schema map[string]*schema.Schema
}

func (*ResourceData) Get

func (rd *ResourceData) Get(key string) interface{}

type SchemaDefaultFunc

type SchemaDefaultFunc = schema.SchemaDefaultFunc

func DefaultMapFromSchema

func DefaultMapFromSchema(s *schema.Schema) SchemaDefaultFunc

type SchemaDefaultFuncCtr

type SchemaDefaultFuncCtr = func(*schema.Schema) SchemaDefaultFunc

type SecretData

type SecretData struct {
	*LockedBuffer
	*SecretDescription
}

func (*SecretData) Hash

func (s *SecretData) Hash(salt []byte, iter int) []byte

func (*SecretData) HashString

func (s *SecretData) HashString(salt []byte, iter int) string

type SecretDescription

type SecretDescription struct {
	Source      string
	Destination string
	Owner       string
	Group       string
	Permissions int
}

type Secrets

type Secrets struct {
	Provider SecretsProvider
	Secrets  SecretsDescriptions
	// contains filtered or unexported fields
}

func (*Secrets) Close

func (s *Secrets) Close() error

func (*Secrets) Copy

func (s *Secrets) Copy(ssh *Ssh) (*SecretsCopy, error)

func (*Secrets) Data

func (s *Secrets) Data() (SecretsData, error)

func (*Secrets) Tar

func (s *Secrets) Tar() (io.Reader, error)

type SecretsCopy

type SecretsCopy struct {
	*RemoteCommand
	Secrets *Secrets
}

type SecretsCopyOption

type SecretsCopyOption func(*SecretsCopy)

type SecretsData

type SecretsData []*SecretData

func (SecretsData) Destroy

func (s SecretsData) Destroy()

func (SecretsData) Hash

func (s SecretsData) Hash(salt []byte, iter int) []byte

func (SecretsData) HashString

func (s SecretsData) HashString(salt []byte, iter int) string

type SecretsDescriptions

type SecretsDescriptions []*SecretDescription

type SecretsProvider

type SecretsProvider interface {
	Name() string
	Get(source string) ([]byte, error)
}

type SecretsProviderCommand

type SecretsProviderCommand struct {
	Command     string
	Arguments   []string
	Environment Environment
}

func NewSecretsProviderCommand

func NewSecretsProviderCommand(command string, arguments []string, environment map[string]string) *SecretsProviderCommand

func (*SecretsProviderCommand) Get

func (p *SecretsProviderCommand) Get(source string) ([]byte, error)

func (*SecretsProviderCommand) Name

func (p *SecretsProviderCommand) Name() string

type SecretsProviderFilesystem

type SecretsProviderFilesystem struct{}

func NewSecretsProviderFilesystem

func NewSecretsProviderFilesystem() *SecretsProviderFilesystem

func (*SecretsProviderFilesystem) Get

func (p *SecretsProviderFilesystem) Get(source string) ([]byte, error)

func (*SecretsProviderFilesystem) Name

type SecretsProviderGopass

type SecretsProviderGopass struct {
	*SecretsProviderCommand
}

func NewSecretsProviderGopass

func NewSecretsProviderGopass(store string) *SecretsProviderGopass

type SecretsProviderName

type SecretsProviderName string
const (
	SecretsProviderNameFilesystem SecretsProviderName = "filesystem"
	SecretsProviderNameCommand    SecretsProviderName = "command"
	SecretsProviderNameGopass     SecretsProviderName = "gopass"
)

type Ssh

type Ssh struct {
	Arguments  []string
	Finalizers []func()
}

func NewSsh

func NewSsh(options ...SshOption) *Ssh

func (*Ssh) Close

func (s *Ssh) Close() error

func (*Ssh) Command

func (s *Ssh) Command() (string, []string, []CommandOption)

func (*Ssh) Execute

func (s *Ssh) Execute(result interface{}) error

func (*Ssh) Finalize

func (s *Ssh) Finalize()

func (*Ssh) With

func (s *Ssh) With(options ...SshOption) *Ssh

type SshConfigKeyValue

type SshConfigKeyValue struct {
	Key   string
	Value string
}

type SshConfigMap

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

func NewSshConfigMap

func NewSshConfigMap() *SshConfigMap

func (*SshConfigMap) Copy

func (m *SshConfigMap) Copy() *SshConfigMap

func (*SshConfigMap) Extend

func (m *SshConfigMap) Extend(em *SshConfigMap)

func (*SshConfigMap) Get

func (m *SshConfigMap) Get(key string) (string, bool)

func (*SshConfigMap) Len

func (m *SshConfigMap) Len() int

func (*SshConfigMap) Pairs

func (m *SshConfigMap) Pairs() SshConfigPairs

func (*SshConfigMap) Set

func (m *SshConfigMap) Set(key, value string)

type SshConfigPairs

type SshConfigPairs = []SshConfigKeyValue

type SshFinalizer

type SshFinalizer func(*Ssh)

func SshFinalizerFile

func SshFinalizerFile(fd File) SshFinalizer

type SshOption

type SshOption func(*Ssh)

func SshOptionCommand

func SshOptionCommand(cmd string) SshOption

func SshOptionConfig

func SshOptionConfig(path string) SshOption

func SshOptionConfigFile

func SshOptionConfigFile(fd File) SshOption

func SshOptionConfigMap

func SshOptionConfigMap(m *SshConfigMap) SshOption

func SshOptionHost

func SshOptionHost(host string) SshOption

func SshOptionIORedirection

func SshOptionIORedirection(host, port string) SshOption

func SshOptionNonInteractive

func SshOptionNonInteractive() SshOption

type StringCommand

type StringCommand struct {
	Cmd       string
	Arguments []string
	Options   []CommandOption
}

func CommandFromString

func CommandFromString(command string, arguments ...string) *StringCommand

func (*StringCommand) Close

func (c *StringCommand) Close() error

func (*StringCommand) Command

func (c *StringCommand) Command() (string, []string, []CommandOption)

func (*StringCommand) Execute

func (c *StringCommand) Execute(v interface{}) error

type Tar

type Tar struct {
	CommandOptions []CommandOption
	Arguments      []string
}

func NewTar

func NewTar(options ...TarOption) *Tar

func (*Tar) Close

func (t *Tar) Close() error

func (*Tar) Command

func (t *Tar) Command() (string, []string, []CommandOption)

func (*Tar) Execute

func (t *Tar) Execute(result interface{}) error

type TarOption

type TarOption func(t *Tar)

func TarOptionChDir

func TarOptionChDir(path string) TarOption

func TarOptionCommandOptions

func TarOptionCommandOptions(option ...CommandOption) TarOption

func TarOptionCreate

func TarOptionCreate() TarOption

func TarOptionExtract

func TarOptionExtract() TarOption

func TarOptionFile

func TarOptionFile(path string) TarOption

func TarOptionGzip

func TarOptionGzip() TarOption

func TarOptionPaths

func TarOptionPaths(paths ...string) TarOption

type TempFile

type TempFile struct {
	*os.File
}

func CreateTemp

func CreateTemp(name string) (*TempFile, error)

func (TempFile) Close

func (fd TempFile) Close() error

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(buf []byte, v interface{}) error
}

type UnmarshalerJSON

type UnmarshalerJSON struct{}

func NewUnmarshalerJSON

func NewUnmarshalerJSON() *UnmarshalerJSON

func (*UnmarshalerJSON) Unmarshal

func (*UnmarshalerJSON) Unmarshal(buf []byte, v interface{}) error

type UnmarshalerPassthrough

type UnmarshalerPassthrough struct{}

func NewUnmarshalerPassthrough

func NewUnmarshalerPassthrough() *UnmarshalerPassthrough

func (*UnmarshalerPassthrough) Unmarshal

func (*UnmarshalerPassthrough) Unmarshal(buf []byte, v interface{}) error

Jump to

Keyboard shortcuts

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