folder

package
v0.67.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// UIDPrefix is the prefix for all operator-managed folder UIDs.
	// This follows the same convention as datasource UIDs (gs- prefix).
	UIDPrefix = "gs-"

	// Description is set on operator-managed folders for human readability.
	Description = "managed-by: observability-operator"

	// MaxTitleLength is the maximum length of a Grafana folder title (per segment).
	// This matches Grafana's API limit of 255 characters.
	MaxTitleLength = 255

	// MaxDepth is the maximum nesting depth for folder hierarchies.
	// This reflects Grafana's built-in folder nesting limit.
	MaxDepth = 4
)

Variables

View Source
var (
	// ErrInvalidFolderPath is returned when the folder path has leading/trailing slashes or empty segments.
	ErrInvalidFolderPath = errors.New("invalid folder path: must not have leading/trailing slashes or empty segments")

	// ErrFolderNameTooLong is returned when a folder name segment exceeds the Grafana title limit.
	ErrFolderNameTooLong = fmt.Errorf("invalid folder path: segment exceeds maximum length of %d characters", MaxTitleLength)

	// ErrFolderPathTooDeep is returned when the folder path exceeds the maximum nesting depth.
	ErrFolderPathTooDeep = fmt.Errorf("invalid folder path: exceeds maximum nesting depth of %d", MaxDepth)
)

Functions

func GenerateUID

func GenerateUID(fullPath string) string

GenerateUID produces a deterministic UID from the full folder path. Uses gs- prefix + first 6 bytes of SHA256(fullPath) encoded as 12 hex chars.

func IsOperatorManaged

func IsOperatorManaged(uid string) bool

IsOperatorManaged checks if a folder UID belongs to the operator.

func ValidatePath

func ValidatePath(path string) error

ValidatePath checks that a folder path is well-formed. Returns an error if the path has leading/trailing slashes or empty segments.

Types

type Folder

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

Folder represents a single Grafana folder managed by the operator.

func New

func New(fullPath string, title string, parentUID string) *Folder

New creates a new Folder domain object.

func ParsePath

func ParsePath(path string) []*Folder

ParsePath splits a slash-separated path into individual Folder domain objects representing the hierarchy from root to leaf. E.g., "team-a/networking/alerts" -> [Folder{team-a}, Folder{team-a/networking}, Folder{team-a/networking/alerts}]

func (*Folder) FullPath

func (f *Folder) FullPath() string

func (*Folder) ParentUID

func (f *Folder) ParentUID() string

func (*Folder) Title

func (f *Folder) Title() string

func (*Folder) UID

func (f *Folder) UID() string

Jump to

Keyboard shortcuts

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