metadata

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataBranch = "hitch-metadata"
	MetadataFile   = "hitch.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchInfo

type BranchInfo struct {
	CreatedAt            time.Time        `json:"created_at"`
	CreatedBy            string           `json:"created_by,omitempty"`
	PromotedTo           []string         `json:"promoted_to"`
	PromotedHistory      []PromotionEvent `json:"promoted_history,omitempty"`
	MergedToMainAt       *time.Time       `json:"merged_to_main_at,omitempty"`
	MergedToMainBy       string           `json:"merged_to_main_by,omitempty"`
	LastCommitAt         time.Time        `json:"last_commit_at,omitempty"`
	LastCommitSHA        string           `json:"last_commit_sha,omitempty"`
	EligibleForCleanupAt *time.Time       `json:"eligible_for_cleanup_at,omitempty"`
}

BranchInfo tracks the lifecycle of a feature branch

type BranchNotFoundError

type BranchNotFoundError struct {
	Branch string
}

BranchNotFoundError is returned when a branch doesn't exist

func (*BranchNotFoundError) Error

func (e *BranchNotFoundError) Error() string

type Config

type Config struct {
	RetentionDaysAfterMerge int       `json:"retention_days_after_merge"`
	StaleDaysNoActivity     int       `json:"stale_days_no_activity"`
	BaseBranch              string    `json:"base_branch"`
	LockTimeoutMinutes      int       `json:"lock_timeout_minutes"`
	AutoRebuildOnPromote    bool      `json:"auto_rebuild_on_promote"`
	ConflictStrategy        string    `json:"conflict_strategy"`
	NotificationWebhooks    []Webhook `json:"notification_webhooks,omitempty"`
}

Config holds global configuration

type Environment

type Environment struct {
	Base              string    `json:"base"`
	Features          []string  `json:"features"`
	Locked            bool      `json:"locked"`
	LockedBy          string    `json:"locked_by,omitempty"`
	LockedAt          time.Time `json:"locked_at,omitempty"`
	LockedReason      string    `json:"locked_reason,omitempty"`
	LastRebuild       time.Time `json:"last_rebuild,omitempty"`
	LastRebuildCommit string    `json:"last_rebuild_commit,omitempty"`
}

Environment represents a deployment environment (dev, qa, etc.)

type EnvironmentLockedError

type EnvironmentLockedError struct {
	Environment string
	LockedBy    string
	LockedAt    time.Time
}

EnvironmentLockedError is returned when an environment is locked by another user

func (*EnvironmentLockedError) Error

func (e *EnvironmentLockedError) Error() string

type EnvironmentNotFoundError

type EnvironmentNotFoundError struct {
	Environment string
}

EnvironmentNotFoundError is returned when an environment doesn't exist

func (*EnvironmentNotFoundError) Error

func (e *EnvironmentNotFoundError) Error() string

type InvalidMetadataError

type InvalidMetadataError struct {
	Reason string
	Err    error
}

InvalidMetadataError is returned when metadata format is invalid

func (*InvalidMetadataError) Error

func (e *InvalidMetadataError) Error() string

func (*InvalidMetadataError) Unwrap

func (e *InvalidMetadataError) Unwrap() error

type MetaInfo

type MetaInfo struct {
	InitializedAt  time.Time `json:"initialized_at"`
	InitializedBy  string    `json:"initialized_by,omitempty"`
	LastModifiedAt time.Time `json:"last_modified_at"`
	LastModifiedBy string    `json:"last_modified_by,omitempty"`
	LastCommand    string    `json:"last_command,omitempty"`
	HitchVersion   string    `json:"hitch_version"`
}

MetaInfo contains metadata about the metadata itself

type Metadata

type Metadata struct {
	Version      string                 `json:"version"`
	Environments map[string]Environment `json:"environments"`
	Branches     map[string]BranchInfo  `json:"branches"`
	Config       Config                 `json:"config"`
	Meta         MetaInfo               `json:"metadata"`
}

Metadata represents the complete hitch.json structure

func NewMetadata

func NewMetadata(environments []string, baseBranch string, user string) *Metadata

NewMetadata creates a new Metadata structure with defaults

func (*Metadata) AddBranchToEnvironment

func (m *Metadata) AddBranchToEnvironment(env string, branch string, user string) error

AddBranchToEnvironment adds a branch to an environment's feature list

func (*Metadata) IsEnvironmentLocked

func (m *Metadata) IsEnvironmentLocked(env string) bool

IsEnvironmentLocked checks if an environment is locked

func (*Metadata) IsLockStale

func (m *Metadata) IsLockStale(env string) bool

IsLockStale checks if a lock is older than the timeout

func (*Metadata) IsLockedByUser

func (m *Metadata) IsLockedByUser(env string, user string) bool

IsLockedByUser checks if an environment is locked by a specific user

func (*Metadata) LockEnvironment

func (m *Metadata) LockEnvironment(env string, user string, reason string) error

LockEnvironment locks an environment

func (*Metadata) RemoveBranchFromEnvironment

func (m *Metadata) RemoveBranchFromEnvironment(env string, branch string, user string) error

RemoveBranchFromEnvironment removes a branch from an environment's feature list

func (*Metadata) UnlockEnvironment

func (m *Metadata) UnlockEnvironment(env string) error

UnlockEnvironment unlocks an environment

func (*Metadata) UpdateMeta

func (m *Metadata) UpdateMeta(user, command string)

UpdateMeta updates the metadata modification tracking

type MetadataReadError

type MetadataReadError struct {
	Reason string
	Err    error
}

MetadataReadError is returned when metadata cannot be read

func (*MetadataReadError) Error

func (e *MetadataReadError) Error() string

func (*MetadataReadError) Unwrap

func (e *MetadataReadError) Unwrap() error

type MetadataWriteError

type MetadataWriteError struct {
	Reason string
	Err    error
}

MetadataWriteError is returned when metadata cannot be written

func (*MetadataWriteError) Error

func (e *MetadataWriteError) Error() string

func (*MetadataWriteError) Unwrap

func (e *MetadataWriteError) Unwrap() error

type PromotionEvent

type PromotionEvent struct {
	Environment string     `json:"environment"`
	PromotedAt  time.Time  `json:"promoted_at"`
	PromotedBy  string     `json:"promoted_by,omitempty"`
	DemotedAt   *time.Time `json:"demoted_at,omitempty"`
	DemotedBy   string     `json:"demoted_by,omitempty"`
}

PromotionEvent records a single promotion/demotion event

type Reader

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

Reader handles reading metadata from the hitch-metadata branch

func NewReader

func NewReader(repo *git.Repository) *Reader

NewReader creates a new metadata reader

func (*Reader) Exists

func (r *Reader) Exists() bool

Exists checks if the hitch-metadata branch exists

func (*Reader) Read

func (r *Reader) Read() (*Metadata, error)

Read reads the metadata from the hitch-metadata branch

type Webhook

type Webhook struct {
	URL     string            `json:"url"`
	Events  []string          `json:"events"`
	Headers map[string]string `json:"headers,omitempty"`
}

Webhook represents a notification webhook configuration

type Writer

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

Writer handles writing metadata to the hitch-metadata branch

func NewWriter

func NewWriter(repo *git.Repository) *Writer

NewWriter creates a new metadata writer

func (*Writer) Write

func (w *Writer) Write(m *Metadata, commitMessage string, author string, authorEmail string) error

Write writes metadata to the hitch-metadata branch It uses optimistic concurrency control with force-with-lease

func (*Writer) WriteInitial

func (w *Writer) WriteInitial(m *Metadata, author string, authorEmail string) error

WriteInitial creates the hitch-metadata branch and writes initial metadata

Jump to

Keyboard shortcuts

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