generator

package
v0.3.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDependsKindsGraph = map[string][]string{
	"Namespace":                      {},
	"ResourceQuota":                  {"Namespace"},
	"StorageClass":                   {},
	"CustomResourceDefinition":       {},
	"ServiceAccount":                 {"Namespace"},
	"PodSecurityPolicy":              {},
	"Role":                           {"Namespace"},
	"ClusterRole":                    {},
	"RoleBinding":                    {"Namespace", "ServiceAccount", "Role"},
	"ClusterRoleBinding":             {"ServiceAccount", "ClusterRole"},
	"ConfigMap":                      {"Namespace"},
	"Secret":                         {"Namespace"},
	"Endpoints":                      {"Namespace"},
	"Service":                        {"Namespace", "Endpoints"},
	"LimitRange":                     {"Namespace", "StorageClass"},
	"PriorityClass":                  {},
	"PersistentVolume":               {"StorageClass"},
	"PersistentVolumeClaim":          {"Namespace", "ResourceQuota", "StorageClass", "PersistentVolume"},
	"Deployment":                     {"Namespace", "ResourceQuota", "PersistentVolumeClaim", "ServiceAccount", "PodSecurityPolicy", "ConfigMap", "Secret", "Service", "LimitRange"},
	"StatefulSet":                    {"Namespace", "ResourceQuota", "PersistentVolumeClaim", "ServiceAccount", "PodSecurityPolicy", "ConfigMap", "Secret", "Service", "LimitRange"},
	"CronJob":                        {"Namespace", "ResourceQuota", "PersistentVolumeClaim", "ServiceAccount", "PodSecurityPolicy", "ConfigMap", "Secret", "Service", "LimitRange"},
	"PodDisruptionBudget":            {"Namespace", "Deployment", "StatefulSet", "CronJob"},
	"MutatingWebhookConfiguration":   {"Namespace", "ServiceAccount", "RoleBinding", "ClusterRoleBinding", "ConfigMap", "Secret", "Service"},
	"ValidatingWebhookConfiguration": {"Namespace", "ServiceAccount", "RoleBinding", "ClusterRoleBinding", "ConfigMap", "Secret", "Service"},
}

DefaultDependsKindsGraph defines the default dependency relationships between Kubernetes resource kinds. This graph maps each resource kind to the list of resource kinds it potentially depends on (not strictly required, but commonly associated in practice).

Structure:

  • Key: The resource kind (e.g., "Deployment")
  • Value: Slice of resource kinds this resource may depend on

Example:

"Deployment": {"Namespace", "ServiceAccount", ...}

Functions

func HasCycleInGraph

func HasCycleInGraph(graph map[string][]string) bool

HasCycleInGraph checks if there's a cycle in the dependency graph. Returns true if a cycle is detected, false otherwise.

func NamespaceResource

func NamespaceResource(ctx context.Context, namespace string) (*v1.Resource, error)

NamespaceResource returns a Kubernetes Namespace resource wrapped into the form of Kusion Resource.

func OrderedResources

func OrderedResources(ctx context.Context, resources v1.Resources, dependsKindsGraph map[string][]string) (v1.Resources, error)

OrderedResources returns a list of Kusion Resources with the injected `dependsOn` in a specified order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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