manifest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsBuiltInResource = func(Resource) bool { return false }

IsBuiltInResource allows the catalog package to inject knowledge of built-in resources that should be excluded from round-trip comparison.

View Source
var RelationshipParamTypes = defaultRelationshipParamTypes

RelationshipParamTypes resolves the resource types for path parameters of a relationship kind. The default implementation is used when the catalog package has not yet installed a registry. Assigning a replacement function allows catalog-driven overrides without creating an import cycle.

Functions

func InstallVolatileFields

func InstallVolatileFields(fields map[string]map[string]struct{})

InstallVolatileFields replaces the global set of volatile round-trip field names. It is used by the catalog package after loading field overrides.

func InstallWriteOnlyFields

func InstallWriteOnlyFields(fields map[string]map[string]struct{})

InstallWriteOnlyFields replaces the per-resource-type write-only field sets. It is used by the catalog package after loading field overrides.

func NormalizeForApply

func NormalizeForApply(resources []Resource, relationships []RelationshipOperation) ([]Resource, []RelationshipOperation)

NormalizeForApply returns a canonical manifest suitable for re-applying to a different Keycloak server. Like NormalizeRoundTrip it strips volatile fields, but it preserves the id of any resource that is referenced by another resource in the manifest so that inline UUID references can be remapped.

func NormalizeRoundTrip

func NormalizeRoundTrip(resources []Resource, relationships []RelationshipOperation) ([]Resource, []RelationshipOperation)

NormalizeRoundTrip returns canonical resource and relationship slices for round-trip comparisons. It removes volatile server-managed resource fields, canonicalizes relationship payload JSON, and sorts both collections.

func ValidateResources

func ValidateResources(resources []Resource) error

ValidateResources ensures each resource has the minimum manifest fields required.

Types

type ComparisonReport

type ComparisonReport struct {
	Match                   bool                    `json:"match"`
	MissingResources        []Resource              `json:"missingResources,omitempty"`
	MismatchedResources     []ResourceMismatch      `json:"mismatchedResources,omitempty"`
	UnexpectedResources     []Resource              `json:"unexpectedResources,omitempty"`
	MissingRelationships    []RelationshipOperation `json:"missingRelationships,omitempty"`
	UnexpectedRelationships []RelationshipOperation `json:"unexpectedRelationships,omitempty"`
}

func CompareRoundTrip

func CompareRoundTrip(expectedResources []Resource, expectedRelationships []RelationshipOperation, actualResources []Resource, actualRelationships []RelationshipOperation) ComparisonReport

CompareRoundTrip compares expected manifests with actual fetched state using round-trip normalization. Resource comparison is subset-based per matching resource key, while relationship comparison is exact on normalized entries.

type LoadResult

type LoadResult struct {
	Resources     []Resource
	Relationships []RelationshipOperation
	Skipped       []SkippedFile
}

func LoadPaths

func LoadPaths(paths []string) (LoadResult, error)

type RelationshipManifest

type RelationshipManifest struct {
	Relationships []RelationshipOperation `json:"relationships"`
}

func ParseRelationshipManifest

func ParseRelationshipManifest(data []byte) (*RelationshipManifest, bool, error)

type RelationshipOperation

type RelationshipOperation struct {
	Kind   string          `json:"kind,omitempty"`
	Path   string          `json:"path"`
	Delete bool            `json:"delete,omitempty"`
	Data   json.RawMessage `json:"data,omitempty"`

	Method     string            `json:"-"`
	Template   string            `json:"-"`
	PathParams map[string]string `json:"-"`
}

func NewRelationshipOperation

func NewRelationshipOperation(template, method string, params map[string]string, payload interface{}) (RelationshipOperation, error)

func (*RelationshipOperation) RebuildPath

func (r *RelationshipOperation) RebuildPath()

type Resource

type Resource struct {
	Type       string                 `json:"type"`
	Realm      string                 `json:"realm"`
	Delete     bool                   `json:"delete,omitempty"`
	Data       map[string]interface{} `json:"data"`
	ParentType string                 `json:"parentType,omitempty"` // disambiguates multi-location types (e.g. protocolmapper under clientscope vs client)
}

Resource is the shared manifest model for Keycloak resources.

func ParseResources

func ParseResources(data []byte) ([]Resource, bool, error)

ParseResources decodes a resource manifest from JSON or YAML.

func SortResources

func SortResources(resources []Resource, priorityMap map[string]int) []Resource

SortResources applies the current resource dependency ordering used by uploads. If priorityMap is nil, falls back to hardcoded priorities.

func StripVolatileFields

func StripVolatileFields(resource Resource) Resource

StripVolatileFields returns a copy of the resource with server-managed and write-only fields removed, suitable for validation before apply.

func (Resource) DisplayName

func (r Resource) DisplayName() string

func (Resource) Identifier

func (r Resource) Identifier() string

func (Resource) Name

func (r Resource) Name() string

type ResourceMismatch

type ResourceMismatch struct {
	Expected Resource `json:"expected"`
	Actual   Resource `json:"actual"`
}

type SkippedFile

type SkippedFile struct {
	Path   string
	Reason string
}

Jump to

Keyboard shortcuts

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