provisioners

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvisionResources

func ProvisionResources(ctx context.Context, state *project.State, provisioners []Provisioner, composeProject *compose.Project) (*project.State, error)

Types

type Input

type Input struct {
	ResourceUid      string                 `json:"resource_uid"`
	ResourceType     string                 `json:"resource_type"`
	ResourceClass    string                 `json:"resource_class"`
	ResourceId       string                 `json:"resource_id"`
	ResourceParams   map[string]interface{} `json:"resource_params"`
	ResourceMetadata map[string]interface{} `json:"resource_metadata"`

	// SourceWorkload is the name of the workload that first defined this resource or carries the params definition.
	SourceWorkload string `json:"source_workload"`
	// WorkloadServices is a map from workload name to the network NetworkService of another workload which defines
	// the hostname and the set of ports it exposes.
	WorkloadServices map[string]NetworkService `json:"workload_services"`

	ResourceState map[string]interface{} `json:"resource_state"`
	SharedState   map[string]interface{} `json:"shared_state"`

	ComposeProjectName string `json:"compose_project_name"`
	MountDirectoryPath string `json:"mount_directory_path"`
}

Input is the set of thins passed to the provisioner implementation. It provides context, previous state, and shared state used by all resources.

type NetworkService

type NetworkService struct {
	ServiceName string                 `yaml:"service_name"`
	Ports       map[string]ServicePort `json:"ports"`
}

NetworkService describes how to contact ports exposed by another workload

type ProvisionOutput

type ProvisionOutput struct {
	ProvisionerUri       string                           `json:"-"`
	ResourceState        map[string]interface{}           `json:"resource_state"`
	ResourceOutputs      map[string]interface{}           `json:"resource_outputs"`
	SharedState          map[string]interface{}           `json:"shared_state"`
	RelativeDirectories  map[string]bool                  `json:"relative_directories"`
	RelativeFileContents map[string]*string               `json:"relative_file_contents"`
	ComposeNetworks      map[string]compose.NetworkConfig `json:"compose_networks"`
	ComposeVolumes       map[string]compose.VolumeConfig  `json:"compose_volumes"`
	ComposeServices      map[string]compose.ServiceConfig `json:"compose_services"`

	// For testing and legacy reasons, built in provisioners can set a direct lookup function
	OutputLookupFunc project.OutputLookupFunc `json:"-"`
}

ProvisionOutput is the output returned from a provisioner implementation.

func (*ProvisionOutput) ApplyToStateAndProject

func (po *ProvisionOutput) ApplyToStateAndProject(state *project.State, resUid project.ResourceUid, project *compose.Project) (*project.State, error)

ApplyToStateAndProject takes the outputs of a provisioning request and applies to the state, file tree, and docker compose project.

type Provisioner

type Provisioner interface {
	Uri() string
	Match(resUid project.ResourceUid) bool
	Provision(ctx context.Context, input *Input) (*ProvisionOutput, error)
}

func NewEphemeralProvisioner

func NewEphemeralProvisioner(uri string, matchUid project.ResourceUid, inner func(ctx context.Context, input *Input) (*ProvisionOutput, error)) Provisioner

NewEphemeralProvisioner is mostly used for internal testing and uses the given provisioner function to provision an exact resource.

type ServicePort

type ServicePort struct {
	// Name is the name of the port from the workload specification
	Name string `json:"name"`
	// Port is the numeric port intended to be published
	Port int `json:"port"`
	// TargetPort is the port on the workload that hosts the actual traffic
	TargetPort int `json:"target_port"`
	// Protocol is TCP or UDP.
	Protocol score.ServicePortProtocol `json:"protocol"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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