Documentation ¶
Index ¶
- Variables
- func EmptyResponse() *proto.GeneratorResponse
- func KubernetesResourceID(typeMeta metav1.TypeMeta, objectMeta metav1.ObjectMeta) string
- func TerraformProviderExtensions(providerCfg ProviderConfig, resType string) (map[string]any, error)
- func TerraformProviderRegion(providerCfg ProviderConfig) string
- func TerraformResourceID(providerCfg ProviderConfig, resType, resName string) (string, error)
- func UniqueAppLabels(projectName, appName string) map[string]string
- func UniqueAppName(projectName, stackName, appName string) string
- func WrapK8sResourceToKusionResource(id string, resource runtime.Object) (*v1.Resource, error)
- func WrapTFResourceToKusionResource(providerCfg ProviderConfig, resType string, resourceID string, ...) (*v1.Resource, error)
- type FrameworkModule
- type FrameworkModuleWrapper
- type GeneratorRequest
- type GeneratorResponse
- type ProviderConfig
Constants ¶
This section is empty.
Variables ¶
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 ID of a Kubernetes resource based on its type and metadata. Resource ID should be unique in one Spec.
func TerraformProviderExtensions ¶
func TerraformProviderExtensions(providerCfg ProviderConfig, 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. Resource ID should be unique in one Spec.
func UniqueAppLabels ¶
UniqueAppLabels returns a map of labels that identify an app based on its project and name.
func UniqueAppName ¶
UniqueAppName returns a unique name for a workload based on its project and app name.
func WrapTFResourceToKusionResource ¶
func WrapTFResourceToKusionResource( providerCfg ProviderConfig, resType string, resourceID string, attributes map[string]interface{}, dependsOn []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 ¶
func (f *FrameworkModuleWrapper) Generate(ctx context.Context, req *proto.GeneratorRequest) (*proto.GeneratorResponse, error)
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 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"` // ProviderMeta is used to describe configs in the terraform hcl "provider" block. ProviderMeta v1.GenericConfig `yaml:"providerMeta" json:"providerMeta"` }
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 the terraform hcl file, where the former is described by fields Source and Version, and the latter is described by ProviderMeta.