tf

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InProgress = "in progress"
	Succeeded  = "succeeded"
	Failed     = "failed"
)

Variables

This section is empty.

Functions

func CheckTerraformPlanOutput added in v0.10.0

func CheckTerraformPlanOutput(logger lager.Logger, output executor.ExecutionOutput) error

Types

type DeploymentManager added in v0.11.0

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

func NewDeploymentManager added in v0.11.0

func NewDeploymentManager(store broker.ServiceProviderStorage) *DeploymentManager

func (*DeploymentManager) CreateAndSaveDeployment added in v0.11.0

func (d *DeploymentManager) CreateAndSaveDeployment(deploymentID string, workspace *workspace.TerraformWorkspace) (storage.TerraformDeployment, error)

func (*DeploymentManager) GetBindingDeployments added in v0.11.0

func (d *DeploymentManager) GetBindingDeployments(deploymentID string) ([]storage.TerraformDeployment, error)

func (*DeploymentManager) GetTerraformDeployment added in v0.11.0

func (d *DeploymentManager) GetTerraformDeployment(deploymentID string) (storage.TerraformDeployment, error)

func (*DeploymentManager) MarkOperationFinished added in v0.11.0

func (d *DeploymentManager) MarkOperationFinished(deployment *storage.TerraformDeployment, err error) error

func (*DeploymentManager) MarkOperationStarted added in v0.11.0

func (d *DeploymentManager) MarkOperationStarted(deployment *storage.TerraformDeployment, operationType string) error

func (*DeploymentManager) OperationStatus added in v0.11.0

func (d *DeploymentManager) OperationStatus(deploymentID string) (bool, string, error)

func (*DeploymentManager) UpdateWorkspaceHCL added in v0.11.0

func (d *DeploymentManager) UpdateWorkspaceHCL(deploymentID string, serviceDefinitionAction TfServiceDefinitionV1Action, templateVars map[string]any) error

type DeploymentManagerInterface added in v0.11.0

type DeploymentManagerInterface interface {
	GetTerraformDeployment(deploymentID string) (storage.TerraformDeployment, error)
	CreateAndSaveDeployment(deploymentID string, workspace *workspace.TerraformWorkspace) (storage.TerraformDeployment, error)
	MarkOperationStarted(deployment *storage.TerraformDeployment, operationType string) error
	MarkOperationFinished(deployment *storage.TerraformDeployment, err error) error
	OperationStatus(deploymentID string) (bool, string, error)
	UpdateWorkspaceHCL(deploymentID string, serviceDefinitionAction TfServiceDefinitionV1Action, templateVars map[string]any) error
	GetBindingDeployments(deploymentID string) ([]storage.TerraformDeployment, error)
}

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

type ImportResource struct {
	TfResource   string
	IaaSResource string
}

ImportResource represents TF resource to IaaS resource ID mapping for import

type TerraformProvider added in v0.11.0

type TerraformProvider struct {
	invoker.TerraformInvokerBuilder

	DeploymentManagerInterface
	// contains filtered or unexported fields
}

func NewTerraformProvider

func NewTerraformProvider(
	tfBinContext executor.TFBinariesContext,
	invokerBuilder invoker.TerraformInvokerBuilder,
	logger lager.Logger,
	serviceDefinition TfServiceDefinitionV1,
	deploymentManager DeploymentManagerInterface,
) *TerraformProvider

NewTerraformProvider creates a new ServiceProvider backed by Terraform module definitions for provision and bind.

func (*TerraformProvider) Bind added in v0.11.0

func (provider *TerraformProvider) Bind(ctx context.Context, bindContext *varcontext.VarContext) (map[string]any, error)

Bind creates a new backing Terraform job and executes it, waiting on the result.

func (*TerraformProvider) CheckOperationConstraints added in v0.11.0

func (provider *TerraformProvider) CheckOperationConstraints(deploymentID string, operationType string) error

func (*TerraformProvider) CheckUpgradeAvailable added in v0.11.0

func (provider *TerraformProvider) CheckUpgradeAvailable(deploymentGUID string) error

func (*TerraformProvider) DefaultInvoker added in v0.11.0

func (provider *TerraformProvider) DefaultInvoker() invoker.TerraformInvoker

func (*TerraformProvider) Deprovision added in v0.11.0

func (provider *TerraformProvider) Deprovision(ctx context.Context, instanceGUID string, vc *varcontext.VarContext) (*string, error)

Deprovision performs a terraform destroy on the instance.

func (*TerraformProvider) GetImportedProperties added in v0.11.0

func (provider *TerraformProvider) GetImportedProperties(ctx context.Context, planGUID string, instanceGUID string, inputVariables []broker.BrokerVariable) (map[string]any, error)

func (*TerraformProvider) GetTerraformOutputs added in v0.11.0

func (provider *TerraformProvider) GetTerraformOutputs(ctx context.Context, instanceGUID string) (storage.JSONObject, error)

func (*TerraformProvider) PollInstance added in v0.11.0

func (provider *TerraformProvider) PollInstance(ctx context.Context, instanceGUID string) (bool, string, error)

PollInstance returns the instance status of the backing job.

func (*TerraformProvider) Provision added in v0.11.0

func (provider *TerraformProvider) Provision(ctx context.Context, provisionContext *varcontext.VarContext) (storage.ServiceInstanceDetails, error)

Provision creates the necessary resources that an instance of this service needs to operate.

func (*TerraformProvider) Unbind added in v0.11.0

func (provider *TerraformProvider) Unbind(ctx context.Context, instanceGUID, bindingID string, vc *varcontext.VarContext) error

Unbind performs a terraform destroy on the binding.

func (*TerraformProvider) Update added in v0.11.0

func (provider *TerraformProvider) Update(ctx context.Context, updateContext *varcontext.VarContext) (models.ServiceInstanceDetails, error)

Update makes necessary updates to resources so they match new desired configuration

func (*TerraformProvider) Upgrade added in v0.11.0

func (provider *TerraformProvider) Upgrade(ctx context.Context, instanceContext *varcontext.VarContext, bindingContexts []*varcontext.VarContext) (models.ServiceInstanceDetails, error)

Upgrade makes necessary updates to resources so they match plan configuration

func (*TerraformProvider) VersionedInvoker added in v0.11.0

func (provider *TerraformProvider) VersionedInvoker(version *version.Version) invoker.TerraformInvoker

func (*TerraformProvider) Wait added in v0.11.0

func (provider *TerraformProvider) Wait(ctx context.Context, id 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 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"`

	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) IsSubsumePlan added in v0.11.0

func (tfb *TfServiceDefinitionV1) IsSubsumePlan(planGUID string) bool

func (*TfServiceDefinitionV1) ToService

func (tfb *TfServiceDefinitionV1) ToService(tfBinContext executor.TFBinariesContext, maintenanceInfo *domain.MaintenanceInfo) (*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]any `yaml:"properties"`
	ProvisionOverrides map[string]any `yaml:"provision_overrides,omitempty"`
	BindOverrides      map[string]any `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(maintenanceInfo *domain.MaintenanceInfo) 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.

Directories

Path Synopsis
executorfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
invokerfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
workspacefakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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