module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 12 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 v1.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 v1.ProviderConfig) string

TerraformProviderRegion returns the resource region from the Terraform provider configs.

func TerraformResourceID

func TerraformResourceID(providerCfg v1.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,omitempty" yaml:"project"`
	// Stack represents the stack name
	Stack string `json:"stack,omitempty" yaml:"stack"`
	// App represents the application name, which is typically the same as the namespace of Kubernetes resources
	App string `json:"app,omitempty" yaml:"app"`
	// Workload represents the workload configuration
	Workload *internalv1.Workload `json:"workload,omitempty" yaml:"workload"`
	// DevModuleConfig is the developer's inputs of this module
	DevModuleConfig internalv1.Accessory `json:"dev_module_config,omitempty" yaml:"devModuleConfig"`
	// PlatformModuleConfig is the platform engineer's inputs of this module
	PlatformModuleConfig apiv1.GenericConfig `json:"platform_module_config,omitempty" yaml:"platformModuleConfig"`
}

func NewGeneratorRequest

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

type GeneratorResponse

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

Jump to

Keyboard shortcuts

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