terraform

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobTypeApply   = "apply"
	JobTypeDestroy = "destroy"
)
View Source
const DeployerType = types.DeployerTypeTF

DeployerType the type of deployer.

View Source
const WalrusContextVariableName = "context"

Variables

This section is empty.

Functions

func CreateJob

func CreateJob(ctx context.Context, clientSet *kubernetes.Clientset, opts JobCreateOptions) error

CreateJob create a job to run terraform deployment.

func CreateSecret

func CreateSecret(ctx context.Context, clientSet *kubernetes.Clientset, name string, data map[string][]byte) error

CreateSecret create a secret to store terraform config.

func ParseModuleAttributes added in v0.3.1

func ParseModuleAttributes(
	ctx context.Context,
	mc model.ClientSet,
	attributes map[string]any,
	onlyValidated bool,
	opts RevisionOpts,
) (variables model.Variables, outputs map[string]parser.OutputState, err error)

ParseModuleAttributes parse module variables and dependencies.

func StreamJobLogs

func StreamJobLogs(ctx context.Context, opts StreamJobLogsOptions) error

StreamJobLogs streams the logs of a job.

func SyncResourceRevisionStatus added in v0.4.0

func SyncResourceRevisionStatus(ctx context.Context, bm revisionbus.BusMessage) (err error)

SyncResourceRevisionStatus updates the status of the service according to its recent finished service revision.

Types

type Context added in v0.4.0

type Context struct {
	// Project indicate the project metadata.
	Project struct {
		Name string    `json:"name,omitempty"`
		ID   object.ID `json:"id,omitempty"`
	} `json:"project,omitempty"`

	// Environment indicate the environment metadata.
	Environment struct {
		Name string    `json:"name,omitempty"`
		ID   object.ID `json:"id,omitempty"`
		// Namespace is the managed namespace name of an environment,
		// valid when Kubernetes connector is used in the environment.
		Namespace string `json:"namespace,omitempty"`
	} `json:"environment,omitempty"`

	// Resource indicate the resource metadata.
	Resource struct {
		Name string    `json:"name,omitempty"`
		ID   object.ID `json:"id,omitempty"`
	} `json:"resource,omitempty"`
}

Context indicate the walrus related metadata, will set to attribute context while user module include this attribute.

func NewContext added in v0.4.0

func NewContext() *Context

func (*Context) SetEnvironment added in v0.4.0

func (c *Context) SetEnvironment(id object.ID, name, namespace string) *Context

func (*Context) SetProject added in v0.4.0

func (c *Context) SetProject(id object.ID, name string) *Context

func (*Context) SetResource added in v0.4.0

func (c *Context) SetResource(id object.ID, name string) *Context

type Deployer

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

Deployer terraform deployer to deploy the resource.

func (Deployer) Apply

func (d Deployer) Apply(ctx context.Context, resource *model.Resource, opts deptypes.ApplyOptions) (err error)

Apply creates a new resource revision by the given resource, and drives the Kubernetes Job to create components of the resource.

func (Deployer) Destroy

func (d Deployer) Destroy(ctx context.Context, resource *model.Resource, opts deptypes.DestroyOptions) (err error)

Destroy creates a new resource revision by the given resource, and drives the Kubernetes Job to clean the components of the resource.

func (Deployer) Type

func (d Deployer) Type() deptypes.Type

type JobCreateOptions

type JobCreateOptions struct {
	// Type is the deployment type of job, apply or destroy or other.
	Type               string
	ResourceRevisionID string
	Image              string
	Env                []corev1.EnvVar
}

type JobReconciler

type JobReconciler struct {
	Logger      logr.Logger
	Kubeconfig  *rest.Config
	KubeClient  client.Client
	ModelClient *model.Client
}

func (JobReconciler) Reconcile

func (r JobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (JobReconciler) Setup

func (r JobReconciler) Setup(mgr ctrl.Manager) error

type RevisionOpts added in v0.4.0

type RevisionOpts struct {
	ResourceRevision *model.ResourceRevision

	ResourceName string

	ProjectID     object.ID
	EnvironmentID object.ID
}

type StreamJobLogsOptions

type StreamJobLogsOptions struct {
	Cli        *coreclient.CoreV1Client
	RevisionID object.ID
	JobType    string
	Out        io.Writer
}

Jump to

Keyboard shortcuts

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