module

package
v0.2.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyTFProviderVersion = errors.New("empty terraform provider version")

Functions

func EmptyResponse

func EmptyResponse() *proto.GeneratorResponse

EmptyResponse represents a legal but empty response. Interfaces should return an EmptyResponse instead of nil when the response is empty

func KubernetesResourceID

func KubernetesResourceID(typeMeta metav1.TypeMeta, objectMeta metav1.ObjectMeta) string

KubernetesResourceID returns the unique ID of a Kubernetes resource based on its type and metadata.

func TerraformProviderExtensions

func TerraformProviderExtensions(
	providerCfg ProviderConfig,
	providerMeta map[string]any, resType string,
) (map[string]any, error)

TerraformProviderExtensions returns the Kusion resource extension of the Terraform provider.

func TerraformProviderRegion

func TerraformProviderRegion(providerCfg ProviderConfig) string

TerraformProviderRegion returns the resource region from the Terraform provider configs.

func TerraformResourceID

func TerraformResourceID(providerCfg ProviderConfig, resType, resName string) (string, error)

TerraformResourceID returns the Kusion resource ID of the Terraform resource.

func UniqueAppLabels

func UniqueAppLabels(projectName, appName string) map[string]string

UniqueAppLabels returns a map of labels that identify an app based on its project and name.

func UniqueAppName

func UniqueAppName(projectName, stackName, appName string) string

UniqueAppName returns a unique name for a workload based on its project and app name.

func WrapK8sResourceToKusionResource

func WrapK8sResourceToKusionResource(id string, resource any) (*v1.Resource, error)

func WrapTFResourceToKusionResource

func WrapTFResourceToKusionResource(
	id string,
	attributes, extensions map[string]any,
	denpendsOn []string,
) (*v1.Resource, error)

WrapTFResourceToKusionResource wraps the Terraform resource into the format of the Kusion resource.

Types

type FrameworkModule

type FrameworkModule interface {
	Generate(ctx context.Context, req *GeneratorRequest) (*GeneratorResponse, error)
}

type FrameworkModuleWrapper

type FrameworkModuleWrapper struct {
	// Module is the actual FrameworkModule implemented by platform engineers
	Module FrameworkModule
}

FrameworkModuleWrapper is a module that implements the proto Module interface. It wraps a dev-centric FrameworkModule into a proto Module

func (*FrameworkModuleWrapper) Generate

type GeneratorRequest

type GeneratorRequest struct {
	// Project represents the project name
	Project string `json:"project" yaml:"project"`
	// Stack represents the stack name
	Stack string `json:"stack" yaml:"stack"`
	// App represents the application name, which is typically the same as the namespace of Kubernetes resources
	App string `json:"app" yaml:"app"`
	// Workload represents the workload configuration
	Workload *v1.Workload `json:"workload,omitempty" yaml:"workload,omitempty"`
	// DevConfig is the developer's inputs of this module
	DevConfig v1.Accessory `json:"devConfig,omitempty" yaml:"devConfig,omitempty"`
	// PlatformConfig is the platform engineer's inputs of this module
	PlatformConfig v1.GenericConfig `json:"platformConfig,omitempty" yaml:"platformConfig,omitempty"`
	// Context contains workspace-level configurations, such as topologies, server endpoints, metadata, etc.
	Context v1.GenericConfig `yaml:"context,omitempty" json:"context,omitempty"`
}

func NewGeneratorRequest

func NewGeneratorRequest(req *proto.GeneratorRequest) (*GeneratorRequest, error)

type GeneratorResponse

type GeneratorResponse struct {
	// Resources represents the generated resources
	Resources []v1.Resource `json:"resources,omitempty" yaml:"resources,omitempty"`
	Patchers  []v1.Patcher  `json:"patchers,omitempty" yaml:"patchers,omitempty"`
}

type ProviderConfig added in v0.2.0

type ProviderConfig struct {
	// Source of the provider.
	Source string `yaml:"source" json:"source"`

	// Version of the provider.
	Version string `yaml:"version" json:"version"`

	// GenericConfig is used to describe the config of a specified terraform provider.
	v1.GenericConfig `yaml:",inline,omitempty" json:",inline,omitempty"`
}

ProviderConfig contains the full configurations of a specified provider. It is the combination of the specified provider's config in blocks "terraform/required_providers" and "providers" in terraform hcl file, where the former is described by fields Source and Version, and the latter is described by GenericConfig cause different provider has different config.

Jump to

Keyboard shortcuts

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