values

package
v0.4.5-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package values contains domain value objects that encapsulate primitive types with validation and such.

Index

Constants

This section is empty.

Variables

View Source
var (
	SevUnknown  = Severity{SeverityUnknown}
	SevLow      = Severity{SeverityLow}
	SevMedium   = Severity{SeverityMedium}
	SevHigh     = Severity{SeverityHigh}
	SevCritical = Severity{SeverityCritical}
)

Predefined severity values

Functions

func IsValidProfileURL

func IsValidProfileURL(s string) bool

IsValidProfileURL checks if a string looks like a remote profile URL.

Types

type ControlID

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

ControlID uniquely identifies a control within a profile. Enforces non-empty, trimmed identifiers.

func MustNewControlID

func MustNewControlID(id string) ControlID

MustNewControlID creates a ControlID or panics (for tests/constants)

func NewControlID

func NewControlID(id string) (ControlID, error)

NewControlID creates a new ControlID with validation

func (ControlID) Equals

func (c ControlID) Equals(other ControlID) bool

Equals checks if two ControlIDs are equal

func (ControlID) IsEmpty

func (c ControlID) IsEmpty() bool

IsEmpty returns true if this is the zero value

func (ControlID) MarshalJSON

func (c ControlID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (ControlID) String

func (c ControlID) String() string

String returns the string representation

func (*ControlID) UnmarshalJSON

func (c *ControlID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Digest

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

Digest represents a content hash with algorithm.

func ComputeDigestSHA256

func ComputeDigestSHA256(r io.Reader) (Digest, error)

ComputeDigestSHA256 computes SHA-256 digest of reader contents.

func NewDigest

func NewDigest(algorithm, hexValue string) (Digest, error)

NewDigest creates a digest from algorithm and hex value.

func ParseDigest

func ParseDigest(s string) (Digest, error)

ParseDigest parses a digest string (e.g., "sha256:abc123...").

func (Digest) Algorithm

func (d Digest) Algorithm() string

Algorithm returns the hash algorithm.

func (Digest) Equals

func (d Digest) Equals(other Digest) bool

Equals checks equality with another digest.

func (Digest) String

func (d Digest) String() string

String returns the canonical digest string.

func (Digest) Value

func (d Digest) Value() string

Value returns the hex-encoded hash value.

func (Digest) Verify

func (d Digest) Verify(data []byte) error

Verify validates data matches this digest.

type ExecutionID

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

ExecutionID uniquely identifies a profile execution. This is critical for persistence, distributed execution, and result tracking.

func FromUUID

func FromUUID(id uuid.UUID) ExecutionID

FromUUID creates an ExecutionID from a uuid.UUID

func MustParseExecutionID

func MustParseExecutionID(s string) ExecutionID

MustParseExecutionID parses a string or panics (for tests only)

func NewExecutionID

func NewExecutionID() ExecutionID

NewExecutionID creates a new random execution ID

func ParseExecutionID

func ParseExecutionID(s string) (ExecutionID, error)

ParseExecutionID parses a string into an ExecutionID

func (ExecutionID) Equals

func (e ExecutionID) Equals(other ExecutionID) bool

Equals checks if two ExecutionIDs are equal

func (ExecutionID) IsZero

func (e ExecutionID) IsZero() bool

IsZero returns true if this is the zero value

func (ExecutionID) MarshalJSON

func (e ExecutionID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (ExecutionID) String

func (e ExecutionID) String() string

String returns the string representation

func (ExecutionID) UUID

func (e ExecutionID) UUID() uuid.UUID

UUID returns the underlying uuid.UUID

func (*ExecutionID) UnmarshalJSON

func (e *ExecutionID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type PluginMetadata

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

PluginMetadata contains descriptive information about a plugin.

func NewPluginMetadata

func NewPluginMetadata(name, version, description string, capabilities []string) PluginMetadata

NewPluginMetadata creates plugin metadata.

func (PluginMetadata) Capabilities

func (m PluginMetadata) Capabilities() []string

Capabilities returns required capabilities.

func (PluginMetadata) Description

func (m PluginMetadata) Description() string

Description returns human-readable description.

func (PluginMetadata) Name

func (m PluginMetadata) Name() string

Name returns the plugin name.

func (PluginMetadata) Version

func (m PluginMetadata) Version() string

Version returns the semantic version.

type PluginName

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

PluginName represents a validated plugin identifier. Enforces non-empty, trimmed plugin names.

func MustNewPluginName

func MustNewPluginName(name string) PluginName

MustNewPluginName creates a PluginName or panics

func NewPluginName

func NewPluginName(name string) (PluginName, error)

NewPluginName creates a PluginName with strict validation. A valid plugin name must: - Be non-empty - contain only alphanumeric characters, underscores, and hyphens - NOT contain paths, dots, or special characters - Be at most 64 characters long

func (PluginName) Equals

func (p PluginName) Equals(other PluginName) bool

Equals checks if two plugin names are equal

func (PluginName) IsEmpty

func (p PluginName) IsEmpty() bool

IsEmpty returns true if this is the zero value

func (PluginName) MarshalJSON

func (p PluginName) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Uses json.Marshal for proper character escaping.

func (PluginName) String

func (p PluginName) String() string

String returns the string representation

func (*PluginName) UnmarshalJSON

func (p *PluginName) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type PluginReference

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

PluginReference uniquely identifies a plugin version. Format: registry.io/org/repo/name:version or name (for embedded)

func NewPluginReference

func NewPluginReference(registry, org, repo, name, version string) PluginReference

NewPluginReference creates a reference from components.

func ParsePluginReference

func ParsePluginReference(ref string) (PluginReference, error)

ParsePluginReference parses OCI reference string. Examples:

  • file (embedded)
  • ghcr.io/whiskeyjimbo/reglet-plugins/file:1.0.2

func (PluginReference) Equals

func (r PluginReference) Equals(other PluginReference) bool

Equals checks equality with another reference.

func (PluginReference) IsEmbedded

func (r PluginReference) IsEmbedded() bool

IsEmbedded returns true if this is a built-in plugin.

func (PluginReference) Name

func (r PluginReference) Name() string

Name returns the plugin name.

func (PluginReference) Registry

func (r PluginReference) Registry() string

Registry returns the registry hostname.

func (PluginReference) String

func (r PluginReference) String() string

String returns the canonical OCI reference string.

func (PluginReference) Version

func (r PluginReference) Version() string

Version returns the version tag.

type ProfileReference

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

ProfileReference is an immutable value object representing a remote profile location. Supports HTTPS and OCI schemes with optional version/hash pinning.

URL formats:

Invariants:

  • scheme must be "https" or "oci"
  • host must not be empty
  • path must not be empty
  • version and digest are mutually exclusive
  • rawURL never contains credentials

func ParseProfileReference

func ParseProfileReference(rawURL string) (ProfileReference, error)

ParseProfileReference parses a URL string into a ProfileReference. Credentials in the URL are automatically stripped.

func (ProfileReference) CacheKey

func (r ProfileReference) CacheKey() string

CacheKey returns a deterministic key for cache storage. Uses SHA256 of the normalized URL (without version/digest).

func (ProfileReference) Digest

func (r ProfileReference) Digest() *Digest

Digest returns the digest from the URL suffix, or nil.

func (ProfileReference) Equals

func (r ProfileReference) Equals(other ProfileReference) bool

Equals checks equality with another ProfileReference.

func (ProfileReference) HasDigest

func (r ProfileReference) HasDigest() bool

HasDigest returns true if a digest was specified.

func (ProfileReference) HasVersion

func (r ProfileReference) HasVersion() bool

HasVersion returns true if a version was specified.

func (ProfileReference) Host

func (r ProfileReference) Host() string

Host returns the host portion of the URL.

func (ProfileReference) IsHTTPS

func (r ProfileReference) IsHTTPS() bool

IsHTTPS returns true if this is an HTTPS URL.

func (ProfileReference) IsOCI

func (r ProfileReference) IsOCI() bool

IsOCI returns true if this is an OCI registry reference.

func (ProfileReference) IsRemote

func (r ProfileReference) IsRemote() bool

IsRemote returns true if this reference points to a remote resource. Always true for ProfileReference (as opposed to local file paths).

func (ProfileReference) Path

func (r ProfileReference) Path() string

Path returns the path portion of the URL.

func (ProfileReference) RawURL

func (r ProfileReference) RawURL() string

RawURL returns the original URL (with credentials stripped).

func (ProfileReference) Scheme

func (r ProfileReference) Scheme() string

Scheme returns the URL scheme ("https" or "oci").

func (ProfileReference) String

func (r ProfileReference) String() string

String returns the canonical URL without credentials.

func (ProfileReference) Version

func (r ProfileReference) Version() string

Version returns the version from the URL fragment, or empty string.

func (ProfileReference) WithDigest

func (r ProfileReference) WithDigest(digest Digest) ProfileReference

WithDigest returns a new ProfileReference with the specified digest. Clears any existing version.

func (ProfileReference) WithVersion

func (r ProfileReference) WithVersion(version string) ProfileReference

WithVersion returns a new ProfileReference with the specified version. Clears any existing digest.

type Severity

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

Severity represents the severity level of a control. Enforces valid severity values and provides ordering.

func MustNewSeverity

func MustNewSeverity(s string) Severity

MustNewSeverity creates a Severity or panics

func NewSeverity

func NewSeverity(s string) (Severity, error)

NewSeverity creates a Severity from string

func (Severity) Equals

func (s Severity) Equals(other Severity) bool

Equals checks if two severities are equal

func (Severity) IsHigherOrEqual

func (s Severity) IsHigherOrEqual(other Severity) bool

IsHigherOrEqual returns true if this severity is higher or equal to the other

func (Severity) IsHigherThan

func (s Severity) IsHigherThan(other Severity) bool

IsHigherThan returns true if this severity is higher than the other

func (Severity) Level

func (s Severity) Level() int

Level returns the numeric severity level (for ordering)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (Severity) String

func (s Severity) String() string

String returns the string representation

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type SeverityLevel

type SeverityLevel int

SeverityLevel is the internal representation

const (
	// SeverityUnknown = Unknown
	SeverityUnknown SeverityLevel = 0
	// SeverityLow = Low
	SeverityLow SeverityLevel = 1
	// SeverityMedium = Medium
	SeverityMedium SeverityLevel = 2
	// SeverityHigh = High
	SeverityHigh SeverityLevel = 3
	// SeverityCritical = Critical
	SeverityCritical SeverityLevel = 4
)

type Status

type Status string

Status represents the status of a control or observation.

const (
	// StatusPass indicates the check passed
	StatusPass Status = "pass"
	// StatusFail indicates the check failed (but ran successfully)
	StatusFail Status = "fail"
	// StatusError indicates the check encountered an error
	StatusError Status = "error"
	// StatusSkipped indicates the check was skipped (dependency failure or filtered)
	StatusSkipped Status = "skipped"
)

func (Status) IsFailure

func (s Status) IsFailure() bool

IsFailure returns true if this status represents a failure or error

func (Status) IsSkipped

func (s Status) IsSkipped() bool

IsSkipped returns true if this status represents a skip

func (Status) IsSuccess

func (s Status) IsSuccess() bool

IsSuccess returns true if this status represents success

func (Status) Precedence

func (s Status) Precedence() int

Precedence returns the numeric precedence of this status. Higher values indicate higher priority in aggregation. Used by status aggregator to determine control status.

Precedence: Fail (3) > Error (2) > Skipped (1) > Pass (0)

func (Status) Validate

func (s Status) Validate() error

Validate returns an error if the status value is invalid

type TrustedSourcePattern

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

TrustedSourcePattern is an immutable value object representing a glob pattern for matching trusted profile sources.

Examples:

Invariants:

  • pattern must be valid glob syntax
  • pattern must start with "https://" or "oci://"

func ParseTrustedSourcePattern

func ParseTrustedSourcePattern(pattern string) (TrustedSourcePattern, error)

ParseTrustedSourcePattern validates and creates a TrustedSourcePattern.

func (TrustedSourcePattern) Equals

Equals checks equality with another TrustedSourcePattern.

func (TrustedSourcePattern) Matches

Matches checks if the given ProfileReference matches this pattern.

func (TrustedSourcePattern) MatchesURL

func (p TrustedSourcePattern) MatchesURL(url string) bool

MatchesURL checks if the given URL string matches this pattern. This is a convenience method that avoids parsing a full ProfileReference.

func (TrustedSourcePattern) String

func (p TrustedSourcePattern) String() string

String returns the original pattern string.

type TrustedSourcePatterns

type TrustedSourcePatterns []TrustedSourcePattern

TrustedSourcePatterns is a collection of patterns for matching.

func ParseTrustedSourcePatterns

func ParseTrustedSourcePatterns(patterns []string) (TrustedSourcePatterns, error)

ParseTrustedSourcePatterns parses multiple pattern strings.

func (TrustedSourcePatterns) Matches

Matches returns true if any pattern matches the reference.

func (TrustedSourcePatterns) MatchesURL

func (ps TrustedSourcePatterns) MatchesURL(url string) bool

MatchesURL returns true if any pattern matches the URL.

Jump to

Keyboard shortcuts

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