Documentation ¶
Index ¶
- Constants
- Variables
- func AddKubeConfigIf(i *apiv1.Intent, ws *apiv1.Workspace)
- func AppendToIntent(resourceType apiv1.Type, resourceID string, i *apiv1.Intent, resource any) error
- func CallGenerators(i *apiv1.Intent, newGenerators ...NewGeneratorFunc) error
- func ForeachOrdered[T any](m map[string]T, f func(key string, value T) error) error
- func GenericPtr[T any](i T) *T
- func KubernetesResourceID(typeMeta metav1.TypeMeta, objectMeta metav1.ObjectMeta) string
- func KusionPathDependency(id, name string) string
- func MergeMaps(maps ...map[string]string) map[string]string
- func PatchResource[T any](resources map[string][]*apiv1.Resource, gvk string, patchFunc func(*T) error) error
- func PluginDir() (string, error)
- func UniqueAppLabels(projectName, appName string) map[string]string
- func UniqueAppName(projectName, stackName, appName string) string
- type GRPCClient
- type GRPCPlugin
- type GRPCServer
- type Generator
- type Module
- type NewGeneratorFunc
- type Plugin
Constants ¶
const ( DefaultModulePathEnv = "KUSION_MODULE_PATH" KusionModuleBinaryPrefix = "kusion-module-" Dir = "modules" )
const PluginKey = "module-default"
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "MODULE_PLUGIN",
MagicCookieValue: "ON",
}
HandshakeConfig is a common handshake that is shared by plugin and host.
var PluginMap = map[string]plugin.Plugin{ PluginKey: &GRPCPlugin{}, }
PluginMap is the map of plugins we can dispense.
Functions ¶
func AddKubeConfigIf ¶ added in v0.10.0
AddKubeConfigIf adds kubeConfig from workspace to extensions of Kubernetes type resource in intent. If there is already has kubeConfig in extensions, use the kubeConfig in extensions.
func AppendToIntent ¶
func AppendToIntent(resourceType apiv1.Type, resourceID string, i *apiv1.Intent, resource any) error
AppendToIntent adds a Kubernetes resource to the Intent resources slice.
func CallGenerators ¶
func CallGenerators(i *apiv1.Intent, newGenerators ...NewGeneratorFunc) error
CallGenerators calls the Generate method of each Generator instance returned by the given NewGeneratorFuncs.
func ForeachOrdered ¶
ForeachOrdered executes the given function on each item in the map in order of their keys.
func GenericPtr ¶
func GenericPtr[T any](i T) *T
GenericPtr returns a pointer to the provided value.
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 KusionPathDependency ¶
KusionPathDependency returns the implicit resource dependency path based on the resource id and name with the "$kusion_path" prefix.
func MergeMaps ¶
MergeMaps merges multiple map[string]string into one map[string]string. If a map is nil, it skips it and moves on to the next one. For each non-nil map, it iterates over its key-value pairs and adds them to the merged map. Finally, it returns the merged map.
func PatchResource ¶
func PatchResource[T any](resources map[string][]*apiv1.Resource, gvk string, patchFunc func(*T) error) error
PatchResource patches the resource with the given patch.
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.
Types ¶
type GRPCClient ¶ added in v0.11.0
type GRPCClient struct {
// contains filtered or unexported fields
}
func (*GRPCClient) Generate ¶ added in v0.11.0
func (c *GRPCClient) Generate(ctx context.Context, req *proto.GeneratorRequest) (*proto.GeneratorResponse, error)
type GRPCPlugin ¶ added in v0.11.0
type GRPCPlugin struct { // GRPCPlugin must still implement the Plugin interface plugin.Plugin // Concrete implementation, written in Go. This is only used for plugins that are written in Go. Impl Module }
func (*GRPCPlugin) GRPCClient ¶ added in v0.11.0
func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient is going to be invoked by the go-plugin framework
func (*GRPCPlugin) GRPCServer ¶ added in v0.11.0
func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer is going to be invoked by the go-plugin framework
type GRPCServer ¶ added in v0.11.0
type GRPCServer struct { // This is the real implementation Impl Module proto.UnimplementedModuleServer }
func (*GRPCServer) Generate ¶ added in v0.11.0
func (s *GRPCServer) Generate(ctx context.Context, req *proto.GeneratorRequest) (res *proto.GeneratorResponse, err error)
type Generator ¶
type Generator interface { // Generate performs the intent generate operation. Generate(intent *v1.Intent) error }
Generator is an interface for things that can generate Intent from input configurations. todo it's for built-in generators and we should consider to convert it to a general Module interface
func CallGeneratorFuncs ¶
func CallGeneratorFuncs(newGenerators ...NewGeneratorFunc) ([]Generator, error)
CallGeneratorFuncs calls each NewGeneratorFunc in the given slice and returns a slice of Generator instances.
type Module ¶ added in v0.11.0
type Module interface {
Generate(ctx context.Context, req *proto.GeneratorRequest) (*proto.GeneratorResponse, error)
}
Module is the interface that we're exposing as a kusion module plugin.
type NewGeneratorFunc ¶
NewGeneratorFunc is a function that returns a Generator.
type Plugin ¶ added in v0.11.0
type Plugin struct { // Module represents the real module impl Module Module // contains filtered or unexported fields }
func (*Plugin) KillPluginClient ¶ added in v0.11.0
Directories ¶
Path | Synopsis |
---|---|
Package generators contains all codes about the Intent generator mechanism.
|
Package generators contains all codes about the Intent generator mechanism. |