Documentation ¶
Index ¶
- Constants
- func NewTerraformProvider(jobRunner JobRunner, logger lager.Logger, ...) broker.ServiceProvider
- func UpdateWorkspaceHCL(store broker.ServiceProviderStorage, action TfServiceDefinitionV1Action, ...) error
- type ImportParameterMapping
- type ImportResource
- type JobRunner
- type TfCatalogDefinitionV1
- type TfJobRunner
- func (runner *TfJobRunner) Create(ctx context.Context, id string) error
- func (runner *TfJobRunner) Destroy(ctx context.Context, id string, templateVars map[string]interface{}) error
- func (runner *TfJobRunner) Import(ctx context.Context, id string, importResources []ImportResource) error
- func (runner *TfJobRunner) Outputs(ctx context.Context, id, instanceName string) (map[string]interface{}, error)
- func (runner *TfJobRunner) Show(ctx context.Context, id string) (string, error)
- func (runner *TfJobRunner) StageJob(jobId string, workspace *wrapper.TerraformWorkspace) error
- func (runner *TfJobRunner) Status(ctx context.Context, id string) (bool, string, error)
- func (runner *TfJobRunner) Update(ctx context.Context, id string, templateVars map[string]interface{}) error
- func (runner *TfJobRunner) Wait(ctx context.Context, id string) error
- type TfServiceDefinitionV1
- type TfServiceDefinitionV1Action
- func (action *TfServiceDefinitionV1Action) IsTfImport(provisionContext *varcontext.VarContext) bool
- func (action *TfServiceDefinitionV1Action) LoadTemplate(srcDir string) error
- func (action *TfServiceDefinitionV1Action) Validate() (errs *validation.FieldError)
- func (action *TfServiceDefinitionV1Action) ValidateTemplateIO() (errs *validation.FieldError)
- type TfServiceDefinitionV1Plan
Constants ¶
const ( InProgress = "in progress" Succeeded = "succeeded" Failed = "failed" )
Variables ¶
This section is empty.
Functions ¶
func NewTerraformProvider ¶
func NewTerraformProvider(jobRunner JobRunner, logger lager.Logger, serviceDefinition TfServiceDefinitionV1, store broker.ServiceProviderStorage) broker.ServiceProvider
NewTerraformProvider creates a new ServiceProvider backed by Terraform module definitions for provision and bind.
func UpdateWorkspaceHCL ¶
func UpdateWorkspaceHCL(store broker.ServiceProviderStorage, action TfServiceDefinitionV1Action, operationContext *varcontext.VarContext, tfId string) error
Types ¶
type ImportParameterMapping ¶
type ImportParameterMapping struct { TfVariable string `yaml:"tf_variable"` ParameterName string `yaml:"parameter_name"` }
ImportParameterMapping mapping for tf variable to service parameter
type ImportResource ¶
ImportResource represents TF resource to IaaS resource ID mapping for import
type JobRunner ¶
type JobRunner interface { StageJob(jobId string, workspace *wrapper.TerraformWorkspace) error Import(ctx context.Context, id string, importResources []ImportResource) error Create(ctx context.Context, id string) error Update(ctx context.Context, id string, templateVars map[string]interface{}) error Destroy(ctx context.Context, id string, templateVars map[string]interface{}) error Status(ctx context.Context, id string) (bool, string, error) Outputs(ctx context.Context, id, instanceName string) (map[string]interface{}, error) Wait(ctx context.Context, id string) error Show(ctx context.Context, id string) (string, error) }
type TfCatalogDefinitionV1 ¶
type TfCatalogDefinitionV1 []*TfServiceDefinitionV1
func (TfCatalogDefinitionV1) Validate ¶
func (tfb TfCatalogDefinitionV1) Validate() (errs *validation.FieldError)
Validate checks the service definitions for semantic errors.
type TfJobRunner ¶
type TfJobRunner struct { // EnvVars is a list of environment variables that should be included in executor // env (usually Terraform provider credentials) EnvVars map[string]string // Executor holds a custom executor that will be called when commands are run. Executor wrapper.TerraformExecutor // contains filtered or unexported fields }
TfJobRunner is responsible for executing terraform jobs in the background and providing a way to log and access the state of those background tasks.
Jobs are given an ID and a workspace to operate in, and then the TfJobRunner is told which Terraform commands to execute on the given job. The TfJobRunner executes those commands in the background and keeps track of their state in a database table which gets updated once the task is completed.
The TfJobRunner keeps track of the workspace and the Terraform state file so subsequent commands will operate on the same structure.
func NewTfJobRunner ¶
func NewTfJobRunner(envVars map[string]string, store broker.ServiceProviderStorage) *TfJobRunner
NewTfJobRunner constructs a new JobRunner for the given project.
func (*TfJobRunner) Create ¶
func (runner *TfJobRunner) Create(ctx context.Context, id string) error
Create runs `terraform apply` on the given workspace in the background. The status of the job can be found by polling the Status function.
func (*TfJobRunner) Destroy ¶
func (runner *TfJobRunner) Destroy(ctx context.Context, id string, templateVars map[string]interface{}) error
Destroy runs `terraform destroy` on the given workspace in the background. The status of the job can be found by polling the Status function.
func (*TfJobRunner) Import ¶
func (runner *TfJobRunner) Import(ctx context.Context, id string, importResources []ImportResource) error
Import runs `terraform import` and `terraform apply` on the given workspace in the background. The status of the job can be found by polling the Status function.
func (*TfJobRunner) Outputs ¶
func (runner *TfJobRunner) Outputs(ctx context.Context, id, instanceName string) (map[string]interface{}, error)
Outputs gets the output variables for the given module instance in the workspace.
func (*TfJobRunner) StageJob ¶
func (runner *TfJobRunner) StageJob(jobId string, workspace *wrapper.TerraformWorkspace) error
StageJob stages a job to be executed. Before the workspace is saved to the database, the modules and inputs are validated by Terraform.
func (*TfJobRunner) Status ¶
Status gets the status of the most recent job on the workspace. If isDone is true, then the status of the operation will not change again. if isDone is false, then the operation is ongoing.
type TfServiceDefinitionV1 ¶
type TfServiceDefinitionV1 struct { Version int `yaml:"version"` Name string `yaml:"name"` Id string `yaml:"id"` Description string `yaml:"description"` DisplayName string `yaml:"display_name"` ImageUrl string `yaml:"image_url"` DocumentationUrl string `yaml:"documentation_url"` SupportUrl string `yaml:"support_url"` Tags []string `yaml:"tags,flow"` Plans []TfServiceDefinitionV1Plan `yaml:"plans"` ProvisionSettings TfServiceDefinitionV1Action `yaml:"provision"` BindSettings TfServiceDefinitionV1Action `yaml:"bind"` Examples []broker.ServiceExample `yaml:"examples"` PlanUpdateable bool `yaml:"plan_updateable"` // Internal SHOULD be set to true for Google maintained services. Internal bool `yaml:"-"` RequiredEnvVars []string }
TfServiceDefinitionV1 is the first version of user defined services.
func NewExampleTfServiceDefinition ¶
func NewExampleTfServiceDefinition() TfServiceDefinitionV1
NewExampleTfServiceDefinition creates a new service defintition with sample values for the service broker suitable to give a user a template to manually edit.
func (*TfServiceDefinitionV1) ToService ¶
func (tfb *TfServiceDefinitionV1) ToService(executor wrapper.TerraformExecutor) (*broker.ServiceDefinition, error)
ToService converts the flat TfServiceDefinitionV1 into a broker.ServiceDefinition that the registry can use.
func (*TfServiceDefinitionV1) Validate ¶
func (tfb *TfServiceDefinitionV1) Validate() (errs *validation.FieldError)
Validate checks the service definition for semantic errors.
type TfServiceDefinitionV1Action ¶
type TfServiceDefinitionV1Action struct { PlanInputs []broker.BrokerVariable `yaml:"plan_inputs"` UserInputs []broker.BrokerVariable `yaml:"user_inputs"` Computed []varcontext.DefaultVariable `yaml:"computed_inputs"` Template string `yaml:"template"` TemplateRef string `yaml:"template_ref"` Outputs []broker.BrokerVariable `yaml:"outputs"` Templates map[string]string `yaml:"templates"` TemplateRefs map[string]string `yaml:"template_refs"` ImportVariables []broker.ImportVariable `yaml:"import_inputs"` ImportParameterMappings []ImportParameterMapping `yaml:"import_parameter_mappings"` ImportParametersToDelete []string `yaml:"import_parameters_to_delete"` ImportParametersToAdd []ImportParameterMapping `yaml:"import_parameters_to_add"` }
TfServiceDefinitionV1Action holds information needed to process user inputs for a single provision or bind call.
func (*TfServiceDefinitionV1Action) IsTfImport ¶
func (action *TfServiceDefinitionV1Action) IsTfImport(provisionContext *varcontext.VarContext) bool
func (*TfServiceDefinitionV1Action) LoadTemplate ¶
func (action *TfServiceDefinitionV1Action) LoadTemplate(srcDir string) error
LoadTemplate loads template ref into template if provided
func (*TfServiceDefinitionV1Action) Validate ¶
func (action *TfServiceDefinitionV1Action) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.
func (*TfServiceDefinitionV1Action) ValidateTemplateIO ¶
func (action *TfServiceDefinitionV1Action) ValidateTemplateIO() (errs *validation.FieldError)
type TfServiceDefinitionV1Plan ¶
type TfServiceDefinitionV1Plan struct { Name string `yaml:"name"` Id string `yaml:"id"` Description string `yaml:"description"` DisplayName string `yaml:"display_name"` Bullets []string `yaml:"bullets,omitempty"` Free bool `yaml:"free,omitempty"` Properties map[string]interface{} `yaml:"properties"` ProvisionOverrides map[string]interface{} `yaml:"provision_overrides,omitempty"` BindOverrides map[string]interface{} `yaml:"bind_overrides,omitempty"` }
TfServiceDefinitionV1Plan represents a service plan in a human-friendly format that can be converted into an OSB compatible plan.
func (*TfServiceDefinitionV1Plan) ToPlan ¶
func (plan *TfServiceDefinitionV1Plan) ToPlan() broker.ServicePlan
ToPlan converts this plan definition to a broker.ServicePlan.
func (*TfServiceDefinitionV1Plan) Validate ¶
func (plan *TfServiceDefinitionV1Plan) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.