Documentation
¶
Index ¶
- Constants
- func ExtractFields(resource interface{}, fieldMapping func(interface{}) map[string]interface{}) map[string]interface{}
- func LabelsEqual(current, desired map[string]string) bool
- func LabelsEqualPtr(current map[string]*string, desired map[string]string) bool
- type APIPlanner
- type ActionType
- type AuthStrategyPlanner
- type BasePlanner
- func (b *BasePlanner) GetClient() *state.Client
- func (b *BasePlanner) GetDesiredAPIDocuments() []resources.APIDocumentResource
- func (b *BasePlanner) GetDesiredAPIImplementations() []resources.APIImplementationResource
- func (b *BasePlanner) GetDesiredAPIPublications() []resources.APIPublicationResource
- func (b *BasePlanner) GetDesiredAPIVersions() []resources.APIVersionResource
- func (b *BasePlanner) GetDesiredAPIs() []resources.APIResource
- func (b *BasePlanner) GetDesiredAuthStrategies() []resources.ApplicationAuthStrategyResource
- func (b *BasePlanner) GetDesiredPortalCustomDomains() []resources.PortalCustomDomainResource
- func (b *BasePlanner) GetDesiredPortalCustomizations() []resources.PortalCustomizationResource
- func (b *BasePlanner) GetDesiredPortalPages() []resources.PortalPageResource
- func (b *BasePlanner) GetDesiredPortalSnippets() []resources.PortalSnippetResource
- func (b *BasePlanner) GetDesiredPortals() []resources.PortalResource
- func (b *BasePlanner) GetGenericPlanner() *GenericPlanner
- func (b *BasePlanner) GetString(s *string) string
- func (b *BasePlanner) NextChangeID(action ActionType, resourceType string, resourceRef string) string
- func (b *BasePlanner) ValidateProtection(resourceType, resourceName string, isProtected bool, action ActionType) error
- func (b *BasePlanner) ValidateProtectionWithChange(resourceType, resourceName string, isProtected bool, action ActionType, ...) error
- type ContextKey
- type CreateConfig
- type DeleteConfig
- type DependencyResolver
- type FieldChange
- type GenericPlanner
- func (g *GenericPlanner) PlanCreate(_ context.Context, config CreateConfig) (PlannedChange, error)
- func (g *GenericPlanner) PlanDelete(_ context.Context, config DeleteConfig) PlannedChange
- func (g *GenericPlanner) PlanProtectionChange(_ context.Context, config ProtectionChangeConfig) PlannedChange
- func (g *GenericPlanner) PlanUpdate(_ context.Context, config UpdateConfig) (PlannedChange, error)
- func (g *GenericPlanner) ShouldUpdate(config UpdateConfig) bool
- type Options
- type ParentInfo
- type Plan
- type PlanMetadata
- type PlanMode
- type PlanSummary
- type PlanWarning
- type PlannedChange
- type Planner
- func (p *Planner) GeneratePlan(ctx context.Context, rs *resources.ResourceSet, opts Options) (*Plan, error)
- func (p *Planner) GetDesiredAPIs() []resources.APIResource
- func (p *Planner) GetDesiredPortalCustomDomains() []resources.PortalCustomDomainResource
- func (p *Planner) GetDesiredPortalCustomizations() []resources.PortalCustomizationResource
- func (p *Planner) GetDesiredPortalPages() []resources.PortalPageResource
- func (p *Planner) GetDesiredPortalSnippets() []resources.PortalSnippetResource
- type PortalPlanner
- type ProtectionChange
- type ProtectionChangeConfig
- type ProtectionErrorCollector
- type ProtectionSummary
- type ReferenceInfo
- type ReferenceResolver
- type ResolveResult
- type ResolvedReference
- type ResourcePlanner
- type UpdateConfig
Constants ¶
const ( // FieldCurrentLabels contains the current labels of a resource // Used during updates to determine which labels should be removed FieldCurrentLabels = "_current_labels" // FieldStrategyType contains the current strategy type for auth strategies // Used during updates since strategy type cannot be changed FieldStrategyType = "_strategy_type" // FieldError contains validation errors that should be reported // Used when the planner detects an invalid operation FieldError = "_error" )
Internal field names used for communication between planner and executor These fields are prefixed with underscore to indicate they are internal and should not be confused with actual resource fields
const ( // ResourceTypePortal is the resource type for portals ResourceTypePortal = "portal" // ResourceTypePortalPage is the resource type for portal pages ResourceTypePortalPage = "portal_page" // ResourceTypePortalSnippet is the resource type for portal snippets ResourceTypePortalSnippet = "portal_snippet" // ResourceTypePortalCustomization is the resource type for portal customizations ResourceTypePortalCustomization = "portal_customization" // ResourceTypePortalCustomDomain is the resource type for portal custom domains ResourceTypePortalCustomDomain = "portal_custom_domain" )
Resource type constants
const (
// DefaultNamespace is the default namespace when none is specified
DefaultNamespace = "default"
)
Default values
Variables ¶
This section is empty.
Functions ¶
func ExtractFields ¶
func ExtractFields(resource interface{}, fieldMapping func(interface{}) map[string]interface{}) map[string]interface{}
ExtractFields is a helper to create field extractors for resources with SDK types
func LabelsEqual ¶
LabelsEqual compares two label maps for equality
Types ¶
type APIPlanner ¶
type APIPlanner interface {
ResourcePlanner
}
APIPlanner handles planning for API resources and their child resources
func NewAPIPlanner ¶
func NewAPIPlanner(base *BasePlanner) APIPlanner
NewAPIPlanner creates a new API planner
type ActionType ¶
type ActionType string
ActionType represents the type of change
const ( ActionCreate ActionType = "CREATE" ActionUpdate ActionType = "UPDATE" ActionDelete ActionType = "DELETE" // Future )
type AuthStrategyPlanner ¶
type AuthStrategyPlanner interface {
ResourcePlanner
}
AuthStrategyPlanner handles planning for auth strategy resources
func NewAuthStrategyPlanner ¶
func NewAuthStrategyPlanner(base *BasePlanner) AuthStrategyPlanner
NewAuthStrategyPlanner creates a new auth strategy planner
type BasePlanner ¶
type BasePlanner struct {
// contains filtered or unexported fields
}
BasePlanner provides common functionality for all resource planners
func NewBasePlanner ¶
func NewBasePlanner(p *Planner) *BasePlanner
NewBasePlanner creates a new base planner instance
func (*BasePlanner) GetClient ¶
func (b *BasePlanner) GetClient() *state.Client
GetClient returns the state client
func (*BasePlanner) GetDesiredAPIDocuments ¶
func (b *BasePlanner) GetDesiredAPIDocuments() []resources.APIDocumentResource
GetDesiredAPIDocuments returns desired API document resources
func (*BasePlanner) GetDesiredAPIImplementations ¶
func (b *BasePlanner) GetDesiredAPIImplementations() []resources.APIImplementationResource
GetDesiredAPIImplementations returns desired API implementation resources
func (*BasePlanner) GetDesiredAPIPublications ¶
func (b *BasePlanner) GetDesiredAPIPublications() []resources.APIPublicationResource
GetDesiredAPIPublications returns desired API publication resources
func (*BasePlanner) GetDesiredAPIVersions ¶
func (b *BasePlanner) GetDesiredAPIVersions() []resources.APIVersionResource
GetDesiredAPIVersions returns desired API version resources
func (*BasePlanner) GetDesiredAPIs ¶
func (b *BasePlanner) GetDesiredAPIs() []resources.APIResource
GetDesiredAPIs returns desired API resources
func (*BasePlanner) GetDesiredAuthStrategies ¶
func (b *BasePlanner) GetDesiredAuthStrategies() []resources.ApplicationAuthStrategyResource
GetDesiredAuthStrategies returns desired auth strategy resources
func (*BasePlanner) GetDesiredPortalCustomDomains ¶
func (b *BasePlanner) GetDesiredPortalCustomDomains() []resources.PortalCustomDomainResource
GetDesiredPortalCustomDomains returns desired portal custom domain resources
func (*BasePlanner) GetDesiredPortalCustomizations ¶
func (b *BasePlanner) GetDesiredPortalCustomizations() []resources.PortalCustomizationResource
GetDesiredPortalCustomizations returns desired portal customization resources
func (*BasePlanner) GetDesiredPortalPages ¶
func (b *BasePlanner) GetDesiredPortalPages() []resources.PortalPageResource
GetDesiredPortalPages returns desired portal page resources
func (*BasePlanner) GetDesiredPortalSnippets ¶
func (b *BasePlanner) GetDesiredPortalSnippets() []resources.PortalSnippetResource
GetDesiredPortalSnippets returns desired portal snippet resources
func (*BasePlanner) GetDesiredPortals ¶
func (b *BasePlanner) GetDesiredPortals() []resources.PortalResource
GetDesiredPortals returns desired portal resources
func (*BasePlanner) GetGenericPlanner ¶
func (b *BasePlanner) GetGenericPlanner() *GenericPlanner
GetGenericPlanner returns the generic planner instance
func (*BasePlanner) GetString ¶
func (b *BasePlanner) GetString(s *string) string
GetString safely dereferences a string pointer
func (*BasePlanner) NextChangeID ¶
func (b *BasePlanner) NextChangeID(action ActionType, resourceType string, resourceRef string) string
NextChangeID generates a unique change ID
func (*BasePlanner) ValidateProtection ¶
func (b *BasePlanner) ValidateProtection(resourceType, resourceName string, isProtected bool, action ActionType) error
ValidateProtection validates protection status for an operation
func (*BasePlanner) ValidateProtectionWithChange ¶
func (b *BasePlanner) ValidateProtectionWithChange( resourceType, resourceName string, isProtected bool, action ActionType, protectionChange *ProtectionChange, hasOtherFieldChanges bool, ) error
ValidateProtectionWithChange validates protection status for an operation with protection change info
type ContextKey ¶
type ContextKey int
ContextKey is the type for context keys
const ( // NamespaceContextKey is the context key for namespace NamespaceContextKey ContextKey = iota )
Context keys for planner
type CreateConfig ¶
type CreateConfig struct {
ResourceType string
ResourceName string
ResourceRef string
RequiredFields []string
FieldExtractor func(resource interface{}) map[string]interface{}
Namespace string
DependsOn []string
References map[string]ReferenceInfo
Parent *ParentInfo
}
CreateConfig defines configuration for generic create operations
type DeleteConfig ¶
type DeleteConfig struct {
ResourceType string
ResourceName string
ResourceRef string
ResourceID string
Namespace string
}
DeleteConfig defines configuration for generic delete operations
type DependencyResolver ¶
type DependencyResolver struct{}
DependencyResolver calculates execution order for plan changes
func NewDependencyResolver ¶
func NewDependencyResolver() *DependencyResolver
NewDependencyResolver creates a new resolver
func (*DependencyResolver) ResolveDependencies ¶
func (d *DependencyResolver) ResolveDependencies(changes []PlannedChange) ([]string, error)
ResolveDependencies builds dependency graph and calculates execution order
type FieldChange ¶
type FieldChange struct {
Old interface{} `json:"old"`
New interface{} `json:"new"`
}
FieldChange represents a single field modification (for UPDATE)
type GenericPlanner ¶
type GenericPlanner struct {
// contains filtered or unexported fields
}
GenericPlanner provides common planning operations for all resource types
func NewGenericPlanner ¶
func NewGenericPlanner(p *Planner) *GenericPlanner
NewGenericPlanner creates a new generic planner instance
func (*GenericPlanner) PlanCreate ¶
func (g *GenericPlanner) PlanCreate(_ context.Context, config CreateConfig) (PlannedChange, error)
PlanCreate creates a planned change for resource creation
func (*GenericPlanner) PlanDelete ¶
func (g *GenericPlanner) PlanDelete(_ context.Context, config DeleteConfig) PlannedChange
PlanDelete creates a planned change for resource deletion
func (*GenericPlanner) PlanProtectionChange ¶
func (g *GenericPlanner) PlanProtectionChange(_ context.Context, config ProtectionChangeConfig) PlannedChange
PlanProtectionChange creates a planned change for protection status update
func (*GenericPlanner) PlanUpdate ¶
func (g *GenericPlanner) PlanUpdate(_ context.Context, config UpdateConfig) (PlannedChange, error)
PlanUpdate creates a planned change for resource update
func (*GenericPlanner) ShouldUpdate ¶
func (g *GenericPlanner) ShouldUpdate(config UpdateConfig) bool
ShouldUpdate determines if an update is needed by comparing current and desired state
type ParentInfo ¶
type ParentInfo struct {
Ref string `json:"ref"`
ID string `json:"id"` // May be "[unknown]" for parents in same plan
}
ParentInfo tracks parent relationships
type Plan ¶
type Plan struct {
Metadata PlanMetadata `json:"metadata"`
Changes []PlannedChange `json:"changes"`
ExecutionOrder []string `json:"execution_order"`
Summary PlanSummary `json:"summary"`
Warnings []PlanWarning `json:"warnings,omitempty"`
}
Plan represents a declarative configuration plan
func (*Plan) AddChange ¶
func (p *Plan) AddChange(change PlannedChange)
AddChange adds a change to the plan
func (*Plan) AddWarning ¶
AddWarning adds a warning to the plan
func (*Plan) ContainsDeletes ¶
ContainsDeletes returns true if plan contains any DELETE operations
func (*Plan) SetExecutionOrder ¶
SetExecutionOrder sets the calculated execution order
func (*Plan) UpdateSummary ¶
func (p *Plan) UpdateSummary()
UpdateSummary recalculates plan statistics
type PlanMetadata ¶
type PlanMetadata struct {
Version string `json:"version"`
GeneratedAt time.Time `json:"generated_at"`
Generator string `json:"generator"`
Mode PlanMode `json:"mode"`
}
PlanMetadata contains plan generation information
type PlanSummary ¶
type PlanSummary struct {
TotalChanges int `json:"total_changes"`
ByAction map[ActionType]int `json:"by_action"`
ByResource map[string]int `json:"by_resource"`
ProtectionChanges *ProtectionSummary `json:"protection_changes,omitempty"`
}
PlanSummary provides overview statistics
type PlanWarning ¶
PlanWarning represents a warning about the plan
type PlannedChange ¶
type PlannedChange struct {
ID string `json:"id"`
ResourceType string `json:"resource_type"`
ResourceRef string `json:"resource_ref"`
ResourceID string `json:"resource_id,omitempty"` // Only for UPDATE/DELETE
// Human-readable identifiers for resources without config refs
ResourceMonikers map[string]string `json:"resource_monikers,omitempty"`
Action ActionType `json:"action"`
Fields map[string]interface{} `json:"fields"`
References map[string]ReferenceInfo `json:"references,omitempty"`
Parent *ParentInfo `json:"parent,omitempty"`
Protection interface{} `json:"protection,omitempty"` // bool or ProtectionChange
Namespace string `json:"namespace"`
DependsOn []string `json:"depends_on,omitempty"`
}
PlannedChange represents a single resource change
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
Planner generates execution plans
func NewPlanner ¶
NewPlanner creates a new planner
func (*Planner) GeneratePlan ¶
func (p *Planner) GeneratePlan(ctx context.Context, rs *resources.ResourceSet, opts Options) (*Plan, error)
GeneratePlan creates a plan from declarative configuration
func (*Planner) GetDesiredAPIs ¶
func (p *Planner) GetDesiredAPIs() []resources.APIResource
GetDesiredAPIs returns the desired API resources
func (*Planner) GetDesiredPortalCustomDomains ¶
func (p *Planner) GetDesiredPortalCustomDomains() []resources.PortalCustomDomainResource
GetDesiredPortalCustomDomains returns the desired portal custom domain resources
func (*Planner) GetDesiredPortalCustomizations ¶
func (p *Planner) GetDesiredPortalCustomizations() []resources.PortalCustomizationResource
GetDesiredPortalCustomizations returns the desired portal customization resources
func (*Planner) GetDesiredPortalPages ¶
func (p *Planner) GetDesiredPortalPages() []resources.PortalPageResource
GetDesiredPortalPages returns the desired portal page resources
func (*Planner) GetDesiredPortalSnippets ¶
func (p *Planner) GetDesiredPortalSnippets() []resources.PortalSnippetResource
GetDesiredPortalSnippets returns the desired portal snippet resources
type PortalPlanner ¶
type PortalPlanner interface {
ResourcePlanner
}
PortalPlanner handles planning for portal resources
func NewPortalPlanner ¶
func NewPortalPlanner(base *BasePlanner) PortalPlanner
NewPortalPlanner creates a new portal planner
type ProtectionChange ¶
ProtectionChange tracks protection status changes
type ProtectionChangeConfig ¶
type ProtectionChangeConfig struct {
ResourceType string
ResourceName string
ResourceRef string
ResourceID string
OldProtected bool
NewProtected bool
Namespace string
}
ProtectionChangeConfig defines configuration for protection change operations
type ProtectionErrorCollector ¶
type ProtectionErrorCollector struct {
// contains filtered or unexported fields
}
CollectProtectionErrors collects protection validation errors for batch reporting
func (*ProtectionErrorCollector) Add ¶
func (c *ProtectionErrorCollector) Add(err error)
Add adds a protection error to the collector
func (*ProtectionErrorCollector) Error ¶
func (c *ProtectionErrorCollector) Error() error
Error returns a combined error message
func (*ProtectionErrorCollector) HasErrors ¶
func (c *ProtectionErrorCollector) HasErrors() bool
HasErrors returns true if any errors were collected
type ProtectionSummary ¶
type ProtectionSummary struct {
Protecting int `json:"protecting"`
Unprotecting int `json:"unprotecting"`
}
ProtectionSummary tracks protection changes
type ReferenceInfo ¶
type ReferenceInfo struct {
// Existing fields for single references
Ref string `json:"ref,omitempty"`
ID string `json:"id,omitempty"` // May be "[unknown]" for resources in same plan
LookupFields map[string]string `json:"lookup_fields,omitempty"` // Resource-specific identifying fields
// New fields for array references
Refs []string `json:"refs,omitempty"` // Array of reference strings
ResolvedIDs []string `json:"resolved_ids,omitempty"` // Array of resolved UUIDs
LookupArrays map[string][]string `json:"lookup_arrays,omitempty"` // Array lookup fields
IsArray bool `json:"is_array,omitempty"` // Flag to indicate array reference
}
ReferenceInfo tracks reference resolution
type ReferenceResolver ¶
type ReferenceResolver struct {
// contains filtered or unexported fields
}
ReferenceResolver resolves declarative refs to Konnect IDs
func NewReferenceResolver ¶
func NewReferenceResolver(client *state.Client) *ReferenceResolver
NewReferenceResolver creates a new resolver
func (*ReferenceResolver) ResolveReferences ¶
func (r *ReferenceResolver) ResolveReferences(ctx context.Context, changes []PlannedChange) (*ResolveResult, error)
ResolveReferences resolves all references in planned changes
type ResolveResult ¶
type ResolveResult struct {
// Map of change_id -> field -> resolved reference
ChangeReferences map[string]map[string]ResolvedReference
// Errors encountered during resolution
Errors []error
}
ResolveResult contains resolved reference information
type ResolvedReference ¶
ResolvedReference contains ref and resolved ID
type ResourcePlanner ¶
type ResourcePlanner interface {
// PlanChanges is the main entry point for planning changes for a resource type
PlanChanges(ctx context.Context, plan *Plan) error
}
ResourcePlanner defines the interface that all resource type planners must implement
type UpdateConfig ¶
type UpdateConfig struct {
ResourceType string
ResourceName string
ResourceRef string
ResourceID string
CurrentFields map[string]interface{}
DesiredFields map[string]interface{}
CurrentLabels map[string]string
DesiredLabels map[string]string
RequiredFields []string
FieldComparator func(current, desired map[string]interface{}) bool
Namespace string
References map[string]ReferenceInfo
}
UpdateConfig defines configuration for generic update operations