impl

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 87 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthProviderNone    = "None"
	AuthProviderGeneric = "Generic"
	AuthProviderAWS     = "AWS"
	AuthProviderAzure   = "Azure"
	AuthProviderGCP     = "GCP"
)
View Source
const (
	AuthMethodKubernetes   = "kubernetes"
	AuthMethodCloud        = "cloud"
	AuthMethodDockerConfig = "docker-config"
	AuthMethodKeychain     = "keychain"
)
View Source
const (
	// Using a nil UUID (all zeros) as the default when SpaceID is not provided
	// This is a valid UUID format that won't cause parsing errors
	DefaultSpaceID       = "00000000-0000-0000-0000-000000000000"
	DefaultUnitSlug      = "default"
	DefaultInventoryName = "inventory"
	DefaultInventoryID   = "00000000-0000-0000-0000-000000000000-default"
	DefaultNamespace     = "default"
	FieldManager         = "confighub-bridge-worker"
	DefaultTimeout       = LargeWaitTimeout
	PollInterval         = 2 * time.Second
	InventoryPrefix      = "inventory"
)
View Source
const (
	// InventoryConfigMapName is the standard name for the inventory ConfigMap
	InventoryConfigMapName = "inventory"
	// YAMLSeparator is the standard YAML document separator
	YAMLSeparator = "---"
	// InventoryIDLabel is the label key for inventory ID
	InventoryIDLabel = "cli-utils.sigs.k8s.io/inventory-id"
	// ManagedByLabel is the label key for managed-by
	ManagedByLabel = "app.kubernetes.io/managed-by"
	// FunctionAnnotation is the annotation key for function
	FunctionAnnotation = "config.k8s.io/function"
	// InventoryDataKey is the key for inventory data in ConfigMap
	InventoryDataKey = "inventory"
)
View Source
const (
	SpaceIDAnnotation     = k8skit.ContextKeyPrefix + "SpaceID"
	UnitSlugAnnotation    = k8skit.ContextKeyPrefix + "UnitSlug"
	RevisionNumAnnotation = k8skit.ContextKeyPrefix + "RevisionNum"
)

Keep consistent with K8sResourceProviderType.ContextPath

View Source
const LargeWaitTimeout = 87600 * time.Hour

LargeWaitTimeout is effectively infinite (~10 years) - disabled per #3220 The Bridge should report what Kubernetes reports, not have its own timeout-based failure.

View Source
const NamespaceProperty = configHubPrefix + ".kubernetes.namespace"

Variables

View Source
var (
	ErrImageHasNotBeenApplied  = errors.New("image has not been applied")
	ErrImageNotFound           = errors.New("image not found")
	ErrImageDeletionNotAllowed = errors.New("image is not allowed to be deleted")
)
View Source
var ErrOperationInterrupted = errors.New("operation interrupted")

ErrOperationInterrupted is returned when an operation is cancelled or overridden. Status is already sent via sendOverriddenStatus/sendCancelledStatus, so no "Failed" status needed.

Functions

func CombineInventoryWithResources

func CombineInventoryWithResources(inventoryCM *InventoryConfigMap, resources []byte) ([]byte, error)

CombineInventoryWithResources combines the inventory ConfigMap with resource YAML The inventory ConfigMap is placed as the first document

func CreateInventoryFromLiveData

func CreateInventoryFromLiveData(ctx context.Context, liveData []byte, inv inventory.Info) (*InMemInventoryClient, *InventoryConfigMap, []byte, error)

CreateInventoryFromLiveData creates an InMemInventoryClient initialized with LiveData data This is a convenience wrapper for backward compatibility

func DiscoverAllResourceTypes

func DiscoverAllResourceTypes(cfg *rest.Config) (map[string]ResourceTypeInfo, error)

DiscoverAllResourceTypes fetches all available resource types (including CRDs) from the cluster Returns a map of resource type string (e.g. group/version/Kind) to ResourceTypeInfo

func ExtractCredentialsFromSecret

func ExtractCredentialsFromSecret(secret corev1.Secret) string

func GetCredentialsFromImagePullSecrets

func GetCredentialsFromImagePullSecrets(ctx context.Context, k8sClient ctrlclient.Client) string

func GetCustomResourceDefinitions

func GetCustomResourceDefinitions(k8sclient KubernetesClient) ([]*unstructured.Unstructured, error)

GetCustomResourceDefinitions fetches only Custom Resource Definitions from the cluster

func GetDefaultKeychainCredentials

func GetDefaultKeychainCredentials(params *FluxOCIParams, keychain authn.Keychain) string

func GetDockerConfigCredentials

func GetDockerConfigCredentials(repository string) string

GetDockerConfigCredentials attempts to find credentials for a given repository by inspecting the local Docker config file (~/.docker/config.json or DOCKER_CONFIG).

func GetK8sSecretCredentials

func GetK8sSecretCredentials(ctx context.Context, params *FluxOCIParams) string

func GetObjectRefsFromInventory

func GetObjectRefsFromInventory(inventoryCM *InventoryConfigMap) (object.ObjMetadataSet, error)

GetObjectRefsFromInventory extracts object references from an inventory ConfigMap

func GetResourcesWithConfig

func GetResourcesWithConfig(k8sclient KubernetesClient, config *ImportConfig, cfg *rest.Config) ([]*unstructured.Unstructured, error)

GetResourcesWithConfig handles resource import with a clean configuration structure

func NewFluxOCIWorkerConfig

func NewFluxOCIWorkerConfig(worker *FluxOCIWorker, inCluster bool, authMethod, k8sSecretPath string) error

func SaveInventoryToLiveData

func SaveInventoryToLiveData(invClient *InMemInventoryClient, inventoryCM *InventoryConfigMap, inventoryInfo inventory.Info, resources []byte) ([]byte, error)

SaveInventoryToLiveData updates the LiveData with the current inventory state This is a convenience wrapper for backward compatibility

func SetConfigProvider

func SetConfigProvider(provider ConfigProvider)

SetConfigProvider allows tests to override the config provider

func TryAuth

func TryAuth(auths map[string]DockerAuth, key string) string

Helper to look up an auth entry in the map and base64-decode it

func UpdateInventoryConfigMap

func UpdateInventoryConfigMap(inventoryCM *InventoryConfigMap, objRefs object.ObjMetadataSet) error

UpdateInventoryConfigMap updates the inventory ConfigMap with new object metadata

func ValidateResourceTypeFormat

func ValidateResourceTypeFormat(resourceType string) bool

ValidateResourceTypeFormat checks if a resource type string is properly formatted Returns true if the format matches the expected GVK pattern Valid formats: "v1/Kind" (core API) or "group/version/Kind" (non-core API)

Types

type AppConfigYAMLFunctionWorker

type AppConfigYAMLFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewAppConfigYAMLFunctionWorker

func NewAppConfigYAMLFunctionWorker() *AppConfigYAMLFunctionWorker

func (AppConfigYAMLFunctionWorker) Info

func (AppConfigYAMLFunctionWorker) Invoke

type ApplierComponents

type ApplierComponents struct {
	KubernetesClient       KubernetesClient
	DynamicClient          dynamic.Interface
	DiscoveryClient        discovery.CachedDiscoveryInterface
	RestConfig             *rest.Config
	RestMapper             meta.RESTMapper
	Applier                *apply.Applier
	Destroyer              *apply.Destroyer
	InventoryClient        inventory.Client
	InventoryInfo          inventory.Info
	ServerSideOptions      common.ServerSideOptions
	ReconcileTimeout       time.Duration
	PruneTimeout           time.Duration
	PrunePropagationPolicy metav1.DeletionPropagation
	InventoryPolicy        inventory.Policy
}

ApplierComponents holds all components needed for apply operations

type ApplierConfig

type ApplierConfig struct {
	KubeContext string
	LiveData    []byte // LiveData containing inventory and resources
	SpaceID     string // SpaceID for inventory identification
	UnitSlug    string // UnitSlug for inventory identification
	RevisionNum int64  // RevisionNum for the revision being applied
	WaitTimeout string // WaitTimeout duration string for resource readiness
}

ApplierConfig contains configuration for creating an applier

type ApplierName

type ApplierName string
const (
	FluxSSA     ApplierName = "FluxSSA"
	CLIUtilsSSA ApplierName = "CLIUtilsSSA"
)

type ApplyResult

type ApplyResult struct {
	ResourceSet      ResourceSet
	LiveObjects      []*unstructured.Unstructured
	LiveData         []byte // Updated LiveData including inventory
	LiveState        []byte
	ResourceStatuses api.ResourceStatusMap // Per-resource sync and readiness status
	Error            error
}

ApplyResult contains the result of an apply operation

type ArgoCDOCIWorker added in v0.1.1

type ArgoCDOCIWorker struct {
	KubernetesBridgeWorker
	// contains filtered or unexported fields
}

ArgoCDOCIWorker transforms Kubernetes manifests into ArgoCD Application CRDs using OCI registry as the source, then applies them using the parent's cliutils applier.

func NewArgoCDOCIWorker added in v0.1.1

func NewArgoCDOCIWorker(workerID, workerSecret string) *ArgoCDOCIWorker

NewArgoCDOCIWorker creates a new ArgoCDOCIWorker with properly initialized embedded KubernetesBridgeWorker (including applierType). workerID and workerSecret are used to auto-generate ArgoCD repo-creds Secrets.

func (*ArgoCDOCIWorker) Apply added in v0.1.1

func (*ArgoCDOCIWorker) Destroy added in v0.1.1

func (*ArgoCDOCIWorker) ID added in v0.1.1

func (*ArgoCDOCIWorker) Import added in v0.1.1

func (*ArgoCDOCIWorker) Info added in v0.1.1

func (*ArgoCDOCIWorker) Refresh added in v0.1.1

func (*ArgoCDOCIWorker) WatchForApply added in v0.1.1

func (w *ArgoCDOCIWorker) WatchForApply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

func (*ArgoCDOCIWorker) WatchForDestroy added in v0.1.1

func (w *ArgoCDOCIWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type ArgoCDOCIWorkerParams added in v0.1.1

type ArgoCDOCIWorkerParams struct {
	KubeContext          string `json:",omitempty"`
	WaitTimeout          string `json:",omitempty"`
	ArgoCDNamespace      string `json:",omitempty"` // Namespace where ArgoCD Application will be created (default: "argocd")
	DestinationServer    string `json:",omitempty"` // Target cluster API server URL (default: "https://kubernetes.default.svc")
	DestinationNamespace string `json:",omitempty"` // Target namespace for deployed resources (default: "default")
	Project              string `json:",omitempty"` // ArgoCD project name (default: "default")
	SyncPolicy           string `json:",omitempty"` // "automated" or "manual" (default: "manual")
	PruneEnabled         bool   `json:",omitempty"` // Enable pruning of orphaned resources
	SelfHealEnabled      bool   `json:",omitempty"` // Enable self-healing (auto-sync on drift)
	OCIRepoURL           string `json:",omitempty"` // OCI registry URL - if empty, auto-constructed from OCIHost and unit info
	OCIHost              string `json:",omitempty"` // OCI registry host - optional, inferred from server URL if not set
	OCIPath              string `json:",omitempty"` // Path within OCI artifact (default: ".")
	TargetRevision       string `json:",omitempty"` // OCI tag or digest (default: "latest")
	DisableRepoCreds     bool   `json:",omitempty"` // Skip auto-generation of ArgoCD repo-creds Secret (default: false)
}

ArgoCDOCIWorkerParams contains the configuration parameters for the ArgoCD OCI bridge worker.

type ArgoCDRendererWorker

type ArgoCDRendererWorker struct {
	KubernetesBridgeWorker KubernetesBridgeWorker
}

ArgoCDRendererWorker renders ArgoCD Application resources to Kubernetes manifests by creating the Application in the cluster and calling the ArgoCD API to get the rendered manifests.

func (*ArgoCDRendererWorker) Apply

func (*ArgoCDRendererWorker) Destroy

func (*ArgoCDRendererWorker) Finalize

func (*ArgoCDRendererWorker) ID added in v0.1.1

func (*ArgoCDRendererWorker) Import

func (*ArgoCDRendererWorker) Info

func (*ArgoCDRendererWorker) Refresh

func (*ArgoCDRendererWorker) WatchForApply

func (w *ArgoCDRendererWorker) WatchForApply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

func (*ArgoCDRendererWorker) WatchForDestroy

func (w *ArgoCDRendererWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type BridgeDispatcher

type BridgeDispatcher struct {
	// contains filtered or unexported fields
}

BridgeDispatcher is a bridge worker that delegates operations to registered workers based on the toolchain and provider information in the request payload It ensures operations on the same unit are processed sequentially

func NewBridgeDispatcher

func NewBridgeDispatcher() *BridgeDispatcher

NewBridgeDispatcher creates a new Dispatcher instance with unit queue management

func (*BridgeDispatcher) Apply

Apply delegates the Apply operation to the appropriate worker and ensures operations on the same unit ID are processed sequentially

func (*BridgeDispatcher) Destroy

Destroy delegates the Destroy operation to the appropriate worker and ensures operations on the same unit ID are processed sequentially

func (*BridgeDispatcher) Finalize

Finalize delegates the Finalize operation to the appropriate worker and ensures operations on the same unit ID are processed sequentially

func (*BridgeDispatcher) ID added in v0.1.1

ID returns an empty BridgeWorkerID since the dispatcher aggregates multiple workers.

func (*BridgeDispatcher) Import

Import delegates the Import operation to the appropriate worker and ensures operations on the same unit ID are processed sequentially

func (*BridgeDispatcher) Info

Info returns aggregated information about all registered workers

func (*BridgeDispatcher) Refresh

Refresh delegates the Refresh operation to the appropriate worker and ensures operations on the same unit ID are processed sequentially

func (*BridgeDispatcher) RegisterWorker

func (d *BridgeDispatcher) RegisterWorker(toolchainType workerapi.ToolchainType, providerType api.ProviderType, worker api.BridgeWorker)

RegisterWorker registers a bridge worker for a specific toolchain and provider combination

func (*BridgeDispatcher) WatchForApply

func (d *BridgeDispatcher) WatchForApply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

func (*BridgeDispatcher) WatchForDestroy

func (d *BridgeDispatcher) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type CLIUtilsApplier

type CLIUtilsApplier struct {
	// contains filtered or unexported fields
}

CLIUtilsApplier implements K8sApplier using kubernetes-sigs/cli-utils

func (*CLIUtilsApplier) Apply

Apply implements K8sApplier.Apply following the CLI-Utils algorithm

func (*CLIUtilsApplier) Destroy

Destroy implements K8sApplier.Destroy following the CLI-Utils algorithm

func (*CLIUtilsApplier) Refresh

Refresh implements K8sApplier.Refresh Returns uncleaned live objects - caller will cleanup for LiveData, keep uncleaned for LiveState

func (*CLIUtilsApplier) WaitForApply

func (a *CLIUtilsApplier) WaitForApply(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult

WaitForApply implements K8sApplier.WaitForApply

func (*CLIUtilsApplier) WaitForDestroy

func (a *CLIUtilsApplier) WaitForDestroy(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult

WaitForDestroy implements K8sApplier.WaitForDestroy

type CachedResource

type CachedResource struct {
	// contains filtered or unexported fields
}

CachedResource represents a cached Kubernetes resource

type ConfigHubBridgeWorker

type ConfigHubBridgeWorker struct {
	// contains filtered or unexported fields
}

func NewConfigHubBridgeWorker

func NewConfigHubBridgeWorker() *ConfigHubBridgeWorker

NewConfigHubBridgeWorker creates a new ConfigHubBridgeWorker

func (*ConfigHubBridgeWorker) Apply

func (w *ConfigHubBridgeWorker) Apply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) (retErr error)

Apply processes the configuration data

func (*ConfigHubBridgeWorker) Destroy

Destroy removes all resources tracked in the inventory

func (*ConfigHubBridgeWorker) Finalize

Finalize performs cleanup operations

func (*ConfigHubBridgeWorker) ID added in v0.1.1

func (*ConfigHubBridgeWorker) Import

func (w *ConfigHubBridgeWorker) Import(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) (retErr error)

Import imports entities from ConfigHub based on the provided ImportRequest

func (*ConfigHubBridgeWorker) Info

Info returns the bridge worker information

func (*ConfigHubBridgeWorker) Init added in v0.1.1

func (*ConfigHubBridgeWorker) Refresh

func (w *ConfigHubBridgeWorker) Refresh(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) (retErr error)

Refresh gets the current state of entities and updates the config data, inventory, and live state

type ConfigHubFunctionWorker

type ConfigHubFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewConfigHubFunctionWorker

func NewConfigHubFunctionWorker() *ConfigHubFunctionWorker

func (ConfigHubFunctionWorker) Info

type ConfigMapBridgeWorker

type ConfigMapBridgeWorker struct {
	KubernetesBridgeWorker
}

func (*ConfigMapBridgeWorker) Apply

func (*ConfigMapBridgeWorker) Destroy

func (*ConfigMapBridgeWorker) Finalize

func (*ConfigMapBridgeWorker) ID added in v0.1.1

func (*ConfigMapBridgeWorker) Import

func (*ConfigMapBridgeWorker) Info

func (*ConfigMapBridgeWorker) Refresh

func (*ConfigMapBridgeWorker) WatchForApply

func (*ConfigMapBridgeWorker) WatchForDestroy

func (w *ConfigMapBridgeWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type ConfigProvider

type ConfigProvider interface {
	GetConfig() (*rest.Config, error)
}

ConfigProvider interface allows for testing by controlling config retrieval

type DefaultConfigProvider

type DefaultConfigProvider struct{}

DefaultConfigProvider uses InClusterConfig for production

func (DefaultConfigProvider) GetConfig

func (d DefaultConfigProvider) GetConfig() (*rest.Config, error)

type DestroyResult

type DestroyResult struct {
	ResourceSet ResourceSet
	LiveData    []byte // Updated LiveData including inventory after destroy
	Error       error
}

DestroyResult contains the result of a destroy operation

type DockerAuth

type DockerAuth struct {
	Auth     string `json:"auth"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

DockerAuth represents the auth configuration for a registry

type DockerConfig

type DockerConfig struct {
	Auths map[string]DockerAuth `json:"auths"`
}

DockerConfig represents the structure of a Docker config.json file

type EventProcessor

type EventProcessor struct {
	// contains filtered or unexported fields
}

EventProcessor handles events from apply/destroy operations. It tracks three types of resource modifications: - appliedObjects: Resources that were created or updated during apply - prunedObjects: Resources removed during apply because they're no longer in desired state - deletedObjects: Resources explicitly removed during destroy operations

type FetchStrategy

type FetchStrategy struct {
	// contains filtered or unexported fields
}

FetchStrategy determines how to fetch resources

type FluxOCIParams

type FluxOCIParams struct {
	Repository    string `json:",omitempty"`
	RevTag        string `json:"-"` // internal use for revision tag: rev1, rev2, etc.
	Tag           string `json:",omitempty"`
	Provider      string `json:",omitempty"`
	AllowDeletion string `json:",omitempty"`
	// Optional Kubernetes Secret for Docker credentials
	KubernetesSecretName      string `json:",omitempty"`
	KubernetesSecretNamespace string `json:",omitempty"`
}

FluxOCIParams represents the target parameters for OCI operations

func ParseFluxOCIParams

func ParseFluxOCIParams(payload api.BridgeWorkerPayload) (*FluxOCIParams, error)

ParseTargetParams extracts and parses target parameters for OCI

func (*FluxOCIParams) ToMap

func (p *FluxOCIParams) ToMap() map[string]interface{}

type FluxOCIWorker

type FluxOCIWorker struct {
	Config              *FluxOCIWorkerConfig
	LoginToRegistryFunc func(ctx context.Context, workerConfig *FluxOCIWorkerConfig, params *FluxOCIParams, newClientFunc NewClientFunc) (OCIClient, error)
}

func NewFluxOCIWorker

func NewFluxOCIWorker() *FluxOCIWorker

Default implementation of LoginToRegistryFunc

func (FluxOCIWorker) Apply

func (FluxOCIWorker) Destroy

func (FluxOCIWorker) Finalize

func (FluxOCIWorker) ID added in v0.1.1

func (FluxOCIWorker) Import

func (FluxOCIWorker) Info

Info shows FluxOCIWorker api.BridgeWorkerInfo. If the worker is not configured with REPO and TAG, we will not provide any default targets Repository and Tag are generally passed via FluxOCIParams and read from the BridgeWorkerPayload

func (FluxOCIWorker) Refresh

type FluxOCIWorkerConfig

type FluxOCIWorkerConfig struct {
	InCluster                   bool
	AuthMethod                  string
	KubernetesSecretPath        string
	KubernetesSecretCredentials string
}

type FluxRendererWorker

type FluxRendererWorker struct {
	KubernetesBridgeWorker KubernetesBridgeWorker
}

FluxRendererWorker renders Flux HelmRelease and Kustomization resources to Kubernetes manifests without applying them to a cluster. It looks up artifact URLs and digests from Flux source controller resources.

func (*FluxRendererWorker) Apply

func (*FluxRendererWorker) Destroy

func (*FluxRendererWorker) Finalize

func (*FluxRendererWorker) ID added in v0.1.1

func (*FluxRendererWorker) Import

func (*FluxRendererWorker) Info

func (*FluxRendererWorker) Refresh

func (*FluxRendererWorker) WatchForApply

func (w *FluxRendererWorker) WatchForApply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

func (*FluxRendererWorker) WatchForDestroy

func (w *FluxRendererWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type FreshDiscoveryClient

type FreshDiscoveryClient struct {
	*discovery.DiscoveryClient
}

FreshDiscoveryClient is a wrapper around DiscoveryClient that implements CachedDiscoveryInterface but always returns fresh data (no caching)

func (*FreshDiscoveryClient) Fresh

func (f *FreshDiscoveryClient) Fresh() bool

Fresh implements CachedDiscoveryInterface - always returns true since we don't cache

func (*FreshDiscoveryClient) Invalidate

func (f *FreshDiscoveryClient) Invalidate()

Invalidate implements CachedDiscoveryInterface - no-op since we don't cache

type FunctionDispatcher

type FunctionDispatcher struct {
	// contains filtered or unexported fields
}

FunctionDispatcher is a function worker that delegates operations to registered workers based on the toolchain type information in the function request It ensures operations on the same unit are processed sequentially

func NewFunctionDispatcher

func NewFunctionDispatcher() *FunctionDispatcher

NewFunctionDispatcher creates a new DispatcherFunctionWorker instance

func (*FunctionDispatcher) Info

Info returns aggregated information about all registered function workers

func (*FunctionDispatcher) Invoke

Invoke delegates the function invocation to the appropriate worker and ensures operations on the same unit are processed sequentially

func (*FunctionDispatcher) RegisterWorker

func (d *FunctionDispatcher) RegisterWorker(toolchainType workerapi.ToolchainType, worker api.FunctionWorker)

RegisterWorker registers a function worker for a specific toolchain type

type INIFunctionWorker

type INIFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewINIFunctionWorker

func NewINIFunctionWorker() *INIFunctionWorker

func (INIFunctionWorker) Info

type ImportConfig

type ImportConfig struct {
	IncludeSystem  bool
	IncludeCustom  bool
	IncludeCluster bool
	Namespaces     []string
	Filters        []goclientnew.ImportFilter
}

ImportConfig holds the configuration options for resource import

func NewImportConfigFromRequest

func NewImportConfigFromRequest(request *goclientnew.ImportRequest) *ImportConfig

NewImportConfigFromRequest creates an ImportConfig from an ImportRequest

type InMemInventory

type InMemInventory struct {
	// contains filtered or unexported fields
}

InMemInventory represents an in-memory inventory

func (*InMemInventory) GetObjectRefs

func (i *InMemInventory) GetObjectRefs() object.ObjMetadataSet

GetObjectRefs returns the list of object references tracked in the inventory

func (*InMemInventory) GetObjectStatuses

func (i *InMemInventory) GetObjectStatuses() object.ObjectStatusSet

GetObjectStatuses returns the list of statuses for each object reference

func (*InMemInventory) Info

func (i *InMemInventory) Info() inventory.Info

Info returns the inventory info

func (*InMemInventory) SetObjectRefs

func (i *InMemInventory) SetObjectRefs(refs object.ObjMetadataSet)

SetObjectRefs updates the local cache of object references

func (*InMemInventory) SetObjectStatuses

func (i *InMemInventory) SetObjectStatuses(statuses object.ObjectStatusSet)

SetObjectStatuses updates the local cache of object statuses

type InMemInventoryClient

type InMemInventoryClient struct {
	// contains filtered or unexported fields
}

InMemInventoryClient is an inventory client that stores everything in memory

func NewInMemInventoryClient

func NewInMemInventoryClient() *InMemInventoryClient

NewInMemInventoryClient creates a new in-memory inventory client

func (*InMemInventoryClient) CreateFromLiveData

func (c *InMemInventoryClient) CreateFromLiveData(ctx context.Context, liveData []byte, inv inventory.Info) (*InventoryConfigMap, []byte, error)

CreateFromLiveData creates an InMemInventoryClient initialized with LiveData data

func (*InMemInventoryClient) CreateOrUpdate

CreateOrUpdate creates or updates an inventory object in memory

func (*InMemInventoryClient) Delete

Delete removes an inventory object from memory

func (*InMemInventoryClient) Get

Get retrieves an inventory object from memory

func (*InMemInventoryClient) List

List returns all inventory objects from memory

func (*InMemInventoryClient) NewInventory

func (c *InMemInventoryClient) NewInventory(info inventory.Info) (inventory.Inventory, error)

NewInventory returns an empty initialized inventory object

func (*InMemInventoryClient) PopulateFromObjects

func (c *InMemInventoryClient) PopulateFromObjects(ctx context.Context, inv inventory.Info, objects []*unstructured.Unstructured) error

PopulateFromObjects populates the inventory with object metadata from unstructured objects. This is used for backward compatibility when inventory is empty but objects need to be tracked (e.g., for units created before inventory tracking was added).

func (*InMemInventoryClient) SaveToLiveData

func (c *InMemInventoryClient) SaveToLiveData(inventoryCM *InventoryConfigMap, inventoryInfo inventory.Info, resources []byte) ([]byte, error)

SaveToLiveData updates the LiveData with the current inventory state

type InventoryConfigMap

type InventoryConfigMap struct {
	*unstructured.Unstructured
}

InventoryConfigMap represents the structure of the inventory ConfigMap that tracks applied resources for pruning and lifecycle management

func NewInventoryConfigMap

func NewInventoryConfigMap(inv inventory.Info) *InventoryConfigMap

NewInventoryConfigMap creates a new inventory ConfigMap for the given inventory info

func NewInventoryConfigMapWithOptions

func NewInventoryConfigMapWithOptions(inv inventory.Info, opts InventoryOptions) *InventoryConfigMap

NewInventoryConfigMapWithOptions creates a new inventory ConfigMap with optional metadata

func SplitInventoryFromLiveData

func SplitInventoryFromLiveData(liveData []byte) (*InventoryConfigMap, []byte, error)

SplitInventoryFromLiveData splits the LiveData YAML into inventory ConfigMap and remaining resources The inventory ConfigMap is expected to be the first document in the YAML

func (*InventoryConfigMap) GetInventoryID

func (i *InventoryConfigMap) GetInventoryID() string

GetInventoryID retrieves the inventory ID from the ConfigMap

func (*InventoryConfigMap) IsValid

func (i *InventoryConfigMap) IsValid() bool

IsValid checks if the InventoryConfigMap is valid

type InventoryMetadata

type InventoryMetadata struct {
	SpaceID       string
	UnitSlug      string
	InventoryName string
	InventoryID   string
}

InventoryMetadata contains extracted inventory metadata

type InventoryOptions

type InventoryOptions struct {
	Name     string
	SpaceID  string
	UnitSlug string
}

InventoryOptions contains optional metadata for inventory ConfigMap

type K8sApplier

type K8sApplier interface {
	// Apply applies the given objects to the cluster
	Apply(ctx context.Context, objects []*unstructured.Unstructured) ApplyResult

	// WaitForApply waits for applied resources to be ready
	WaitForApply(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult

	// Refresh retrieves the current live state of objects
	Refresh(ctx context.Context, objects []*unstructured.Unstructured) ([]*unstructured.Unstructured, error)

	// Destroy deletes the given objects from the cluster
	Destroy(ctx context.Context, objects []*unstructured.Unstructured) DestroyResult

	// WaitForDestroy waits for resources to be terminated and returns the final state
	WaitForDestroy(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult
}

K8sApplier defines the interface for Kubernetes resource operations Note: Import is not part of this interface because it's a higher-level operation that reads live objects from the cluster based on discovery/filtering logic. Import belongs to the BridgeWorker interface as it operates at the orchestration level, while K8sApplier focuses on direct resource manipulation (apply/destroy/refresh).

func NewCLIUtilsApplier

func NewCLIUtilsApplier(config ApplierConfig) (K8sApplier, error)

NewCLIUtilsApplier creates a new K8sApplier instance

func NewFluxSSAApplier

func NewFluxSSAApplier(config ApplierConfig) (K8sApplier, error)

NewFluxSSAApplier creates a new K8sApplier instance using the SSA implementation

func NewK8sApplier

func NewK8sApplier(name ApplierName, config ApplierConfig) (K8sApplier, error)

type KubernetesBridgeWorker

type KubernetesBridgeWorker struct {
	// contains filtered or unexported fields
}

func NewKubernetesBridgeWorker

func NewKubernetesBridgeWorker() *KubernetesBridgeWorker

NewKubernetesBridgeWorker creates a new KubernetesBridgeWorker with CLI Utils SSA as default

func (*KubernetesBridgeWorker) Apply

func (*KubernetesBridgeWorker) Destroy

func (*KubernetesBridgeWorker) Finalize

Finalize implements api.BridgeWorker.Finalize This method is called when the worker is being shutdown or cleaned up

func (*KubernetesBridgeWorker) ID added in v0.1.1

func (*KubernetesBridgeWorker) Import

func (w *KubernetesBridgeWorker) Import(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) (retErr error)

func (*KubernetesBridgeWorker) Info

func (*KubernetesBridgeWorker) InfoForToolchainAndProvider

func (w *KubernetesBridgeWorker) InfoForToolchainAndProvider(opts api.InfoOptions, toolchain workerapi.ToolchainType, provider api.ProviderType) api.BridgeWorkerInfo

This supports ToolchainTypes and ProviderTypes that generate and apply Kubernetes resources.

func (*KubernetesBridgeWorker) Refresh

func (*KubernetesBridgeWorker) WatchForApply

func (*KubernetesBridgeWorker) WatchForDestroy

func (w *KubernetesBridgeWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type KubernetesClient

type KubernetesClient interface {
	Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
	Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
	Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
	Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
	Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
	DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
	IsObjectNamespaced(obj runtime.Object) (bool, error)
	// Add other methods as needed
	List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
}

type KubernetesFunctionWorker

type KubernetesFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewKubernetesFunctionWorker

func NewKubernetesFunctionWorker() *KubernetesFunctionWorker

func (KubernetesFunctionWorker) Info

type KubernetesWorkerParams

type KubernetesWorkerParams struct {
	KubeContext string `json:",omitempty"`
	WaitTimeout string `json:",omitempty"` // Duration string like "5m0s", "10h5m"

	// Retry configuration
	RetryInitialInterval string  `json:",omitempty"` // Initial retry interval (e.g., "10s")
	RetryMultiplier      float64 `json:",omitempty"` // Backoff multiplier (e.g., 2.0)
	RetryMaxInterval     string  `json:",omitempty"` // Max retry interval (e.g., "5m")
	RetryMaxElapsedTime  string  `json:",omitempty"` // Max total time for retries (e.g., "30m")
}

func (KubernetesWorkerParams) ToMap

func (p KubernetesWorkerParams) ToMap() map[string]interface{}

type ListOptionsBuilder

type ListOptionsBuilder struct {
	// contains filtered or unexported fields
}

ListOptionsBuilder helps construct Kubernetes list options consistently

func NewListOptionsBuilder

func NewListOptionsBuilder() *ListOptionsBuilder

NewListOptionsBuilder creates a new builder

func (*ListOptionsBuilder) Build

func (b *ListOptionsBuilder) Build() []client.ListOption

Build constructs the final list options

func (*ListOptionsBuilder) WithFilters

WithFilters adds filters to the builder

func (*ListOptionsBuilder) WithNamespace

func (b *ListOptionsBuilder) WithNamespace(namespace string) *ListOptionsBuilder

WithNamespace sets the target namespace

func (*ListOptionsBuilder) WithSystemFiltering

func (b *ListOptionsBuilder) WithSystemFiltering(includeSystem, isNamespaced bool) *ListOptionsBuilder

WithSystemFiltering configures system resource filtering

type LiveDataBuilder

type LiveDataBuilder struct {
	// contains filtered or unexported fields
}

LiveDataBuilder optimally builds LiveData from tracked events

func NewLiveDataBuilder

func NewLiveDataBuilder(
	inventory inventory.Client,
	dynamicClient dynamic.Interface,
	restMapper meta.RESTMapper,
	spaceID string,
	unitSlug string,
) *LiveDataBuilder

NewLiveDataBuilder creates a new LiveDataBuilder

func (*LiveDataBuilder) BuildLiveData

func (b *LiveDataBuilder) BuildLiveData(
	ctx context.Context,
	invInfo inventory.Info,
	processor *EventProcessor,
	previousLiveData []byte,
) (liveData []byte, resourceSet ResourceSet, err error)

BuildLiveData builds optimal LiveData from tracked events

type NewClientFunc

type NewClientFunc func() OCIClient

type OCIClient

type OCIClient interface {
	LoginWithCredentials(cred string) error
	Delete(ctx context.Context, url string) error
	GetOptions() []crane.Option
}

func LoginToRegistry

func LoginToRegistry(ctx context.Context, workerConfig *FluxOCIWorkerConfig, params *FluxOCIParams, newClientFunc NewClientFunc) (OCIClient, error)

LoginToRegistry attempts registry authentication in multiple ways: 1) Kubernetes secret from params (if specified) 2) Configured AuthMethod (kubernetes, docker-config, or keychain) - with fallback 3) Always fallback to docker-config if not already tried 4) Always fallback to keychain if not already tried 5) Anonymous access for public registries

func NewRealOCIClient

func NewRealOCIClient() OCIClient

type OpenTofuAWSParams

type OpenTofuAWSParams struct {
	Profile string `json:",omitempty"`
	Region  string `json:",omitempty"`
}

func (*OpenTofuAWSParams) ToMap

func (p *OpenTofuAWSParams) ToMap() map[string]interface{}

type OpenTofuAWSWorker

type OpenTofuAWSWorker struct{}

func (*OpenTofuAWSWorker) Apply

func (*OpenTofuAWSWorker) Destroy

func (*OpenTofuAWSWorker) Finalize

func (*OpenTofuAWSWorker) ID added in v0.1.1

func (*OpenTofuAWSWorker) Import

func (*OpenTofuAWSWorker) Info

func (*OpenTofuAWSWorker) Refresh

type OpentofuFunctionWorker

type OpentofuFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewOpentofuFunctionWorker

func NewOpentofuFunctionWorker() *OpentofuFunctionWorker

func (OpentofuFunctionWorker) Info

type PropertiesFunctionWorker

type PropertiesFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewPropertiesFunctionWorker

func NewPropertiesFunctionWorker() *PropertiesFunctionWorker

func (PropertiesFunctionWorker) Info

type RealOCIClient

type RealOCIClient struct {
	// contains filtered or unexported fields
}

func (*RealOCIClient) Delete

func (r *RealOCIClient) Delete(ctx context.Context, url string) error

func (*RealOCIClient) GetOptions

func (r *RealOCIClient) GetOptions() []crane.Option

func (*RealOCIClient) LoginWithCredentials

func (r *RealOCIClient) LoginWithCredentials(cred string) error

type ResourceCache

type ResourceCache struct {
	// contains filtered or unexported fields
}

ResourceCache provides LRU caching for unchanged resources

func NewResourceCache

func NewResourceCache(maxSize int, maxAge time.Duration) *ResourceCache

NewResourceCache creates a new resource cache

func (*ResourceCache) Get

Get retrieves a cached resource

func (*ResourceCache) IsValid

func (c *ResourceCache) IsValid(key string) bool

IsValid checks if a cached resource is still valid

func (*ResourceCache) Put

func (c *ResourceCache) Put(key string, obj *unstructured.Unstructured)

Put stores a resource in cache

func (*ResourceCache) Remove

func (c *ResourceCache) Remove(key string)

Remove deletes a resource from cache

type ResourceDiscovery

type ResourceDiscovery struct {
	// contains filtered or unexported fields
}

ResourceDiscovery encapsulates the logic for discovering and filtering Kubernetes resources

func NewResourceDiscovery

func NewResourceDiscovery(client KubernetesClient, config *ImportConfig, cfg *rest.Config) *ResourceDiscovery

NewResourceDiscovery creates a new ResourceDiscovery instance

func (*ResourceDiscovery) Discover

func (rd *ResourceDiscovery) Discover() ([]*unstructured.Unstructured, error)

Discover performs resource discovery based on the configured parameters

type ResourceManager

type ResourceManager interface {
	ApplyAllStaged(ctx context.Context, objects []*unstructured.Unstructured, opts ssa.ApplyOptions) (*ssa.ChangeSet, error)
	Wait(objects []*unstructured.Unstructured, opts ssa.WaitOptions) error
	WaitForTermination(objects []*unstructured.Unstructured, opts ssa.WaitOptions) error
	DeleteAll(ctx context.Context, objects []*unstructured.Unstructured, opts ssa.DeleteOptions) (*ssa.ChangeSet, error)
	Client() KubernetesClient // Updated to return KubernetesClient interface
}

type ResourceSet

type ResourceSet interface {
	// Entries returns a slice that can be used to get the count of changes
	GetEntries() []ResourceSetEntry
}

ResourceSet represents a generic resource set interface This allows different applier implementations to provide their own ResourceSet types

type ResourceSetEntry

type ResourceSetEntry interface {
	// Minimal interface for change set entries
	String() string
}

ResourceSetEntry represents a single change in the resource set

type ResourceTypeInfo

type ResourceTypeInfo struct {
	GVK        schema.GroupVersionKind
	Namespaced bool
}

ResourceTypeInfo holds information about a discovered resource type including its GVK and whether it's namespaced

type SSAApplier

type SSAApplier struct {
	// contains filtered or unexported fields
}

SSAApplier implements K8sApplier using FluxCD Server-Side Apply

func (*SSAApplier) Apply

func (a *SSAApplier) Apply(ctx context.Context, objects []*unstructured.Unstructured) ApplyResult

Apply implements K8sApplier.Apply

func (*SSAApplier) Destroy

func (a *SSAApplier) Destroy(ctx context.Context, objects []*unstructured.Unstructured) DestroyResult

Destroy implements K8sApplier.Destroy

func (*SSAApplier) Refresh

Refresh implements K8sApplier.Refresh Returns uncleaned live objects - caller will cleanup for LiveData, keep uncleaned for LiveState

func (*SSAApplier) WaitForApply

func (a *SSAApplier) WaitForApply(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult

WaitForApply implements K8sApplier.WaitForApply

func (*SSAApplier) WaitForDestroy

func (a *SSAApplier) WaitForDestroy(ctx context.Context, objects []*unstructured.Unstructured, timeout time.Duration) WaitResult

WaitForDestroy implements K8sApplier.WaitForDestroy

type SSAResourceSetEntryWrapper

type SSAResourceSetEntryWrapper struct {
	// contains filtered or unexported fields
}

SSAResourceSetEntryWrapper wraps an SSA ChangeSetEntry

func (*SSAResourceSetEntryWrapper) String

func (w *SSAResourceSetEntryWrapper) String() string

String implements the ResourceSetEntry interface

type SSAResourceSetWrapper

type SSAResourceSetWrapper struct {
	// contains filtered or unexported fields
}

SSAResourceSetWrapper wraps an SSA ChangeSet to implement our generic ResourceSet interface

func NewSSAResourceSetWrapper

func NewSSAResourceSetWrapper(changeSet *ssa.ChangeSet) *SSAResourceSetWrapper

NewSSAResourceSetWrapper creates a wrapper for SSA ChangeSet

func (*SSAResourceSetWrapper) GetEntries

func (w *SSAResourceSetWrapper) GetEntries() []ResourceSetEntry

GetEntries implements the ResourceSet interface for SSA ChangeSet

type SimpleInventoryInfo

type SimpleInventoryInfo struct {
	// contains filtered or unexported fields
}

SimpleInventoryInfo implements the inventory.Info interface

func (*SimpleInventoryInfo) GetID

func (s *SimpleInventoryInfo) GetID() inventory.ID

func (*SimpleInventoryInfo) GetName

func (s *SimpleInventoryInfo) GetName() string

func (*SimpleInventoryInfo) GetNamespace

func (s *SimpleInventoryInfo) GetNamespace() string

type SimpleRESTClientGetter

type SimpleRESTClientGetter struct {
	// contains filtered or unexported fields
}

SimpleRESTClientGetter implements genericclioptions.RESTClientGetter using our existing REST config

func (*SimpleRESTClientGetter) ToDiscoveryClient

func (*SimpleRESTClientGetter) ToRESTConfig

func (r *SimpleRESTClientGetter) ToRESTConfig() (*rest.Config, error)

func (*SimpleRESTClientGetter) ToRESTMapper

func (r *SimpleRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

func (*SimpleRESTClientGetter) ToRawKubeConfigLoader

func (r *SimpleRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig

type SimpleResourceSet

type SimpleResourceSet struct {
	Entries []SimpleResourceSetEntry
}

SimpleResourceSet is a basic implementation of ResourceSet

func NewSimpleResourceSet

func NewSimpleResourceSet() *SimpleResourceSet

NewSimpleResourceSet creates a new SimpleResourceSet

func (*SimpleResourceSet) Add

Add adds an entry to the SimpleResourceSet

func (*SimpleResourceSet) GetEntries

func (s *SimpleResourceSet) GetEntries() []ResourceSetEntry

type SimpleResourceSetEntry

type SimpleResourceSetEntry struct {
	Name      string
	Namespace string
	Kind      string
	Action    string
}

SimpleResourceSetEntry is a basic implementation of ResourceSetEntry

func (SimpleResourceSetEntry) String

func (s SimpleResourceSetEntry) String() string

type TOMLFunctionWorker

type TOMLFunctionWorker struct {
	// contains filtered or unexported fields
}

func NewTOMLFunctionWorker

func NewTOMLFunctionWorker() *TOMLFunctionWorker

func (TOMLFunctionWorker) Info

type WaitResult

type WaitResult struct {
	LiveObjects      []*unstructured.Unstructured
	ResourceSet      ResourceSet
	ResourceStatuses api.ResourceStatusMap // Per-resource sync and readiness status
	Error            error
}

WaitResult contains the result of a wait operation

type WorkerKey

type WorkerKey struct {
	ToolchainType workerapi.ToolchainType
	ProviderType  api.ProviderType
}

WorkerKey represents a unique identifier for a registered bridge worker

type WrappedResourceManager

type WrappedResourceManager struct {
	*ssa.ResourceManager
	// contains filtered or unexported fields
}

func (*WrappedResourceManager) Client

Directories

Path Synopsis
Package argocdrenderer provides functionality for rendering ArgoCD Application resources to Kubernetes manifests by calling the ArgoCD API.
Package argocdrenderer provides functionality for rendering ArgoCD Application resources to Kubernetes manifests by calling the ArgoCD API.
Package fluxrenderer provides functionality for rendering Flux HelmRelease and Kustomization resources to Kubernetes manifests.
Package fluxrenderer provides functionality for rendering Flux HelmRelease and Kustomization resources to Kubernetes manifests.

Jump to

Keyboard shortcuts

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