Documentation ¶
Index ¶
- Constants
- func AddConnectionCheckResource(ctx context.Context, deploymentID, nodeName string, ...) error
- func AddOutput(infrastructure *Infrastructure, outputName string, output *Output)
- func AddResource(infrastructure *Infrastructure, resourceType, resourceName string, ...)
- func GetBackendConfiguration(path string, cfg config.Configuration) map[string]interface{}
- func GetConnInfoFromEndpointCredentials(ctx context.Context, deploymentID, nodeName string) (string, *sshutil.PrivateKey, error)
- func GetConsulProviderfiguration(cfg config.Configuration) map[string]interface{}
- func PreDestroyStorageInfraCallback(ctx context.Context, cfg config.Configuration, ...) (bool, error)
- func SSHAgentFromContext(ctx context.Context) (*sshutil.SSHAgent, bool)
- func StoreSSHAgentInContext(ctx context.Context, agent *sshutil.SSHAgent) context.Context
- type Connection
- type ConsulKey
- type ConsulKeys
- type Generator
- type Infrastructure
- type LocalExec
- type Output
- type PostApplyCallback
- type PreDestroyInfraCallback
- type RemoteExec
- type Resource
Constants ¶
const ( // DefaultSSHPrivateKeyFilePath is the default SSH private Key file path // used to connect to provisioned resources DefaultSSHPrivateKeyFilePath = "~/.ssh/yorc.pem" // NullPluginVersionConstraint is the Terraform null plugin version constraint NullPluginVersionConstraint = "~> 1.0" // DefaultConsulProviderAddress is Default Address to use for Terraform Consul Provider DefaultConsulProviderAddress = "127.0.0.1:8500" )
const FileOutputPrefix = "file:"
FileOutputPrefix is the prefix to identify file output
Variables ¶
This section is empty.
Functions ¶
func AddConnectionCheckResource ¶
func AddConnectionCheckResource(ctx context.Context, deploymentID, nodeName string, infrastructure *Infrastructure, user string, privateKey *sshutil.PrivateKey, accessIP, resourceName string, env *[]string) error
AddConnectionCheckResource builds a null specific resource to check SSH connection with SSH key passed via env variable
func AddOutput ¶
func AddOutput(infrastructure *Infrastructure, outputName string, output *Output)
AddOutput allows to add an Output to a defined Infrastructure
func AddResource ¶
func AddResource(infrastructure *Infrastructure, resourceType, resourceName string, resource interface{})
AddResource allows to add a Resource to a defined Infrastructure
func GetBackendConfiguration ¶
func GetBackendConfiguration(path string, cfg config.Configuration) map[string]interface{}
GetBackendConfiguration returns the Terraform Backend configuration to store the state in the Consul KV store at a given path
func GetConnInfoFromEndpointCredentials ¶
func GetConnInfoFromEndpointCredentials(ctx context.Context, deploymentID, nodeName string) (string, *sshutil.PrivateKey, error)
GetConnInfoFromEndpointCredentials allow to retrieve user and private key path for connection needs from endpoint credentials
func GetConsulProviderfiguration ¶
func GetConsulProviderfiguration(cfg config.Configuration) map[string]interface{}
GetConsulProviderfiguration returns the Terraform Consul Provider configuration
func PreDestroyStorageInfraCallback ¶
func PreDestroyStorageInfraCallback(ctx context.Context, cfg config.Configuration, deploymentID, nodeName, infrastructurePath string) (bool, error)
PreDestroyStorageInfraCallback is a callback of type PreDestroyInfraCallback checking if a block storage node is deletable on undeployment.
func SSHAgentFromContext ¶
SSHAgentFromContext retrieves an sshutil.SSHAgent from the given Context
Types ¶
type Connection ¶
type Connection struct { ConnType string `json:"type,omitempty"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` Host string `json:"host,omitempty"` Port string `json:"port,omitempty"` Timeout string `json:"timeout,omitempty"` // defaults to "5m" PrivateKey string `json:"private_key,omitempty"` Agent bool `json:"agent,omitempty"` // The following values are only supported by ssh BastionHost string `json:"bastion_host,omitempty"` BastionPort string `json:"bastion_port,omitempty"` BastionUser string `json:"bastion_user,omitempty"` BastionPassword string `json:"bastion_password,omitempty"` BastionPrivateKey string `json:"bastion_private_key,omitempty"` }
A Connection allows to overwrite the way Terraform connects to a resource
type ConsulKey ¶
type ConsulKey struct { Path string `json:"path"` // Should only be use in datasource (read) mode, this is the name to use to access this key within the terraform interpolation syntax Name string `json:"name,omitempty"` Default string `json:"default,omitempty"` Value string `json:"value,omitempty"` // Should only be use in resource (write) mode, deletes the key Delete bool `json:"delete,omitempty"` }
A ConsulKey can be used in a ConsulKeys 'resource' to writes or a ConsulKeys 'data' to read an individual Key/Value pair into Consul
type ConsulKeys ¶
type ConsulKeys struct { Resource Datacenter string `json:"datacenter,omitempty"` Token string `json:"token,omitempty"` Keys []ConsulKey `json:"key"` }
The ConsulKeys can be used as 'resource' to writes or 'data' to read sets of individual values into Consul.
type Generator ¶
type Generator interface { // GenerateTerraformInfraForNode generates the Terraform infrastructure file for the given node. // It returns 'true' if a file was generated and 'false' otherwise (in case of a infrastructure component // already exists for this node and should just be reused). // GenerateTerraformInfraForNode can also return a map of outputs names indexed by consul keys into which the outputs results should be stored. // And a list of environment variables in form "key=value" to be added to the current process environment when running terraform commands. // This is particularly useful for adding secrets that should not be in tf files. // It returns too a callback function allowing execution some cleanup stuff once the infrastructure has been applied GenerateTerraformInfraForNode(ctx context.Context, cfg config.Configuration, deploymentID, nodeName, infrastructurePath string) (bool, map[string]string, []string, PostApplyCallback, error) }
A Generator is used to generate the Terraform infrastructure for a given TOSCA node
type Infrastructure ¶
type Infrastructure struct { Terraform map[string]interface{} `json:"terraform,omitempty"` Data map[string]interface{} `json:"data,omitempty"` Variable map[string]interface{} `json:"variable,omitempty"` Provider map[string]interface{} `json:"provider,omitempty"` Resource map[string]interface{} `json:"resource,omitempty"` Output map[string]*Output `json:"output,omitempty"` }
An Infrastructure is the top-level element of a Terraform infrastructure definition
type LocalExec ¶
type LocalExec struct { Command string `json:"command"` WorkingDir string `json:"working_dir,omitempty"` Interpreter string `json:"interpreter,omitempty"` Environment map[string]interface{} `json:"environment,omitempty"` }
LocalExec allows to invoke a local executable after a resource is created. This invokes a process on the machine running Terraform, not on the resource
type Output ¶
type Output struct { // Value is the value of the output. This can be a string, list, or map. // This usually includes an interpolation since outputs that are static aren't usually useful. Value interface{} `json:"value"` Sensitive bool `json:"sensitive,omitempty"` }
An Output allows to define a terraform output value
type PostApplyCallback ¶
type PostApplyCallback func()
PostApplyCallback is a callback function called after Terraform apply execution
type PreDestroyInfraCallback ¶
type PreDestroyInfraCallback func(ctx context.Context, cfg config.Configuration, deploymentID, nodeName, infrastructurePath string) (bool, error)
PreDestroyInfraCallback is a function that is call before destroying an infrastructure. If it returns false the node will not be destroyed.
type RemoteExec ¶
type RemoteExec struct { Connection *Connection `json:"connection,omitempty"` Inline []string `json:"inline,omitempty"` Script string `json:"script,omitempty"` Scripts []string `json:"scripts,omitempty"` }
The RemoteExec provisioner invokes a script on a remote resource after it is created.
The remote-exec provisioner supports both ssh and winrm type connections.