ociutils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ociutils provides utilities for generating OCI registry URLs for ConfigHub units and targets.

Index

Constants

View Source
const (
	// RefHead points to the current unit state (head revision)
	RefHead = "head"
	// RefLatest is an alias for RefHead
	RefLatest = "latest"
	// RefLive points to the currently applied/live revision
	RefLive = "live"
	// RefLastApplied points to the last applied revision
	RefLastApplied = "last-applied"
)

Reference tag constants for OCI URLs

Variables

This section is empty.

Functions

func RevisionRef

func RevisionRef(revisionNum int) string

RevisionRef returns a reference tag for a specific revision number. Format: v{revisionNum} (e.g., "v5", "v42")

Types

type OCIURLBuilder

type OCIURLBuilder struct {
	// Host is the OCI registry host (e.g., "oci.confighub.com")
	Host string
}

OCIURLBuilder helps construct OCI registry URLs for ConfigHub resources.

func NewOCIURLBuilder

func NewOCIURLBuilder(host string) *OCIURLBuilder

NewOCIURLBuilder creates a new OCIURLBuilder with the given host. If host is empty, it defaults to constructing from the API host.

func NewOCIURLBuilderFromAPIHost

func NewOCIURLBuilderFromAPIHost(apiHost string) *OCIURLBuilder

NewOCIURLBuilderFromAPIHost creates a new OCIURLBuilder by deriving the OCI host from the API host (e.g., "hub.confighub.com" -> "oci.hub.confighub.com"). For IP addresses, the "oci." prefix is not added, and the port is changed to 9092 (OCI server port).

func (*OCIURLBuilder) TargetURL

func (b *OCIURLBuilder) TargetURL(spaceSlug, targetSlug, reference string) string

TargetURL generates an OCI URL for a target bundle. Format: oci://{host}/target/{spaceSlug}/{targetSlug}:{reference}

Parameters:

  • spaceSlug: The space slug (e.g., "production")
  • targetSlug: The target slug (e.g., "k8s-cluster")
  • reference: The reference tag (e.g., "head", "live", "v5")

Example: oci://oci.confighub.com/target/production/k8s-cluster:live

func (*OCIURLBuilder) TargetURLFromInfo

func (b *OCIURLBuilder) TargetURLFromInfo(info TargetOCIInfo) string

TargetURLFromInfo generates an OCI URL from TargetOCIInfo using "latest" reference.

func (*OCIURLBuilder) UnitURL

func (b *OCIURLBuilder) UnitURL(spaceSlug, unitSlug, reference string) string

UnitURL generates an OCI URL for a specific unit. Format: oci://{host}/unit/{spaceSlug}/{unitSlug}:{reference}

Parameters:

  • spaceSlug: The space slug (e.g., "production")
  • unitSlug: The unit slug (e.g., "my-deployment")
  • reference: The reference tag (e.g., "head", "live", "v5")

Example: oci://oci.confighub.com/unit/production/my-deployment:live

func (*OCIURLBuilder) UnitURLFromInfo

func (b *OCIURLBuilder) UnitURLFromInfo(info UnitOCIInfo) string

UnitURLFromInfo generates an OCI URL from UnitOCIInfo using "latest" reference.

type ParsedOCIURL

type ParsedOCIURL struct {
	Host         string // e.g., "oci.confighub.com"
	ResourceType string // "unit" or "target"
	SpaceSlug    string // e.g., "production"
	ResourceSlug string // unit slug or target slug
	Reference    string // e.g., "head", "live", "v5"
}

ParsedOCIURL represents a parsed OCI URL.

func ParseOCIURL

func ParseOCIURL(url string) (*ParsedOCIURL, error)

ParseOCIURL parses an OCI URL and returns its components. Returns an error if the URL format is invalid.

func (*ParsedOCIURL) IsTarget

func (p *ParsedOCIURL) IsTarget() bool

IsTarget returns true if this URL points to a target resource.

func (*ParsedOCIURL) IsUnit

func (p *ParsedOCIURL) IsUnit() bool

IsUnit returns true if this URL points to a unit resource.

func (*ParsedOCIURL) String

func (p *ParsedOCIURL) String() string

String reconstructs the OCI URL string.

type TargetOCIInfo

type TargetOCIInfo struct {
	SpaceSlug  string
	TargetSlug string
}

TargetOCIInfo contains the information needed to construct a target OCI URL.

type UnitOCIInfo

type UnitOCIInfo struct {
	SpaceSlug string
	UnitSlug  string
}

UnitOCIInfo contains the information needed to construct a unit OCI URL.

Jump to

Keyboard shortcuts

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