index

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index is a generic resource index that provides fast lookups by GVK and file path

func New

func New(repoPath string) *Index

New creates a new empty index

func (*Index) Add

func (idx *Index) Add(entry *ResourceEntry) error

Add adds a resource entry to the index

func (*Index) Get

func (idx *Index) Get(gvk schema.GroupVersionKind, namespace, name string) (*ResourceEntry, bool)

Get retrieves a resource by GVK and namespaced name

func (*Index) GetByFile

func (idx *Index) GetByFile(filePath string) []*ResourceEntry

GetByFile returns all resources from a specific file

func (*Index) GetCommitSHA

func (idx *Index) GetCommitSHA() string

GetCommitSHA returns the commit SHA

func (*Index) GetRepoPath

func (idx *Index) GetRepoPath() string

GetRepoPath returns the repository path

func (*Index) List

func (idx *Index) List(gvk schema.GroupVersionKind) []*ResourceEntry

List returns all resources of a specific GVK

func (*Index) ListAll

func (idx *Index) ListAll() []*ResourceEntry

ListAll returns all resources across all GVKs

func (*Index) RemoveEntriesForFile

func (idx *Index) RemoveEntriesForFile(filePath string)

RemoveEntriesForFile removes all entries associated with a file

func (*Index) SetCommitSHA

func (idx *Index) SetCommitSHA(sha string)

SetCommitSHA sets the commit SHA

func (*Index) Stats

func (idx *Index) Stats() IndexStats

Stats returns generic statistics about the index

func (*Index) ToSerializable

func (idx *Index) ToSerializable() *SerializableIndex

ToSerializable converts the Index to a serializable format

type IndexStats

type IndexStats struct {
	TotalResources int
	TotalFiles     int
	GVKCounts      map[string]int // Kind -> count
}

IndexStats holds generic statistics about the index

type ResourceEntry

type ResourceEntry struct {
	Resource *unstructured.Unstructured
	FilePath string
}

ResourceEntry holds a resource with its source file path

func (*ResourceEntry) GetNestedMap

func (r *ResourceEntry) GetNestedMap(fields ...string) map[string]interface{}

GetNestedMap safely extracts a nested map from the resource

func (*ResourceEntry) GetNestedSlice

func (r *ResourceEntry) GetNestedSlice(fields ...string) []interface{}

GetNestedSlice safely extracts a nested slice from the resource

func (*ResourceEntry) GetNestedString

func (r *ResourceEntry) GetNestedString(fields ...string) string

GetNestedString safely extracts a nested string value from the resource

func (*ResourceEntry) Name

func (r *ResourceEntry) Name() string

Name returns the resource name

func (*ResourceEntry) Namespace

func (r *ResourceEntry) Namespace() string

Namespace returns the resource namespace

func (*ResourceEntry) NamespacedName

func (r *ResourceEntry) NamespacedName() string

NamespacedName returns the namespaced name in the format "namespace/name"

type SerializableIndex

type SerializableIndex struct {
	Resources []SerializableResource `json:"resources"`
	RepoPath  string                 `json:"repoPath"`
	CommitSHA string                 `json:"commitSHA"`
}

SerializableIndex is the JSON-friendly version of Index

func (*SerializableIndex) ToIndex

func (si *SerializableIndex) ToIndex(repoPath string) *Index

ToIndex converts a SerializableIndex back to an Index

type SerializableResource

type SerializableResource struct {
	GVK       string                 `json:"gvk"` // "openchoreo.dev/v1alpha1/Component"
	Namespace string                 `json:"namespace"`
	Name      string                 `json:"name"`
	FilePath  string                 `json:"filePath"`
	Object    map[string]interface{} `json:"object"` // Full resource
}

SerializableResource is a JSON-friendly representation of a resource entry

Jump to

Keyboard shortcuts

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