tf

package
v5.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func NewTerraformProvider

func NewTerraformProvider(jobRunner *TfJobRunner, logger lager.Logger, serviceDefinition TfServiceDefinitionV1) broker.ServiceProvider

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

Types

type TfJobRunner

type TfJobRunner struct {
	ProjectId      string
	ServiceAccount string

	// Executor holds a custom executor that will be called when commands are run.
	Executor wrapper.TerraformExecutor
}

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 NewTfJobRunerFromEnv

func NewTfJobRunerFromEnv() (*TfJobRunner, error)

NewTfJobRunerFromEnv creates a new TfJobRunner with default configuration values.

func NewTfJobRunnerForProject

func NewTfJobRunnerForProject(projectId string) *TfJobRunner

Construct 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) 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) 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(ctx context.Context, 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

func (runner *TfJobRunner) Status(ctx context.Context, id string) (isDone bool, err error)

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.

func (*TfJobRunner) Wait

func (runner *TfJobRunner) Wait(ctx context.Context, id string) error

Wait waits for an operation to complete, polling its status once per second.

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"`

	// Internal SHOULD be set to true for Google maintained services.
	Internal bool `yaml:"-"`
}

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

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"`
	Outputs    []broker.BrokerVariable      `yaml:"outputs"`
}

TfServiceDefinitionV1Action holds information needed to process user inputs for a single provision or bind call.

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]string      `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

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

Jump to

Keyboard shortcuts

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