Help us shape the future of Go! Take the 2026 Go Developer Survey

application

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultRuntimeAPIURL                   = "https://baseharbor-secrets:8443"
	RuntimeIdentityContainerTokenPath      = "/run/secrets/baseharbor-runtime-token"
	RuntimeIdentityContainerCAPath         = "/run/secrets/baseharbor-runtime-ca"
	RuntimeIdentityContainerClientCertPath = "/run/secrets/baseharbor-runtime-client-cert"
	RuntimeIdentityContainerClientKeyPath  = "/run/secrets/baseharbor-runtime-client-key"
	SecretFileBindingContainerDir          = "/run/baseharbor/bindings/secrets"
)
View Source
const CurrentVersion = 1
View Source
const MaxPostgresBackupBytes int64 = 512 << 20
View Source
const RepositoryManifestName = "baseharbor.yaml"

Variables

View Source
var ErrExists = errors.New("application already exists")
View Source
var ErrRuntimeAPIURL = errors.New("application runtime API URL is invalid")
View Source
var ErrRuntimeDefinitionChanged = errors.New("application runtime definition differs from the BaseHarbor-managed definition")
View Source
var ErrRuntimeNotApplied = errors.New("application runtime has not been applied")
View Source
var ErrUnsupportedService = errors.New("application contains services that are not yet supported by apply")
View Source
var ErrWorkloadComposeAmbiguous = errors.New("multiple application Compose files found")
View Source
var ErrWorkloadComposeNotFound = errors.New("application Compose file not found")

Functions

func ApplicationBackendNetworkName

func ApplicationBackendNetworkName(m Manifest) string

ApplicationBackendNetworkName returns the stable Docker/Podman network name used by BaseHarbor-managed backend services for one application environment.

Application-owned workloads may attach to this network as an additional external network without replacing their own Compose networks. The current Compose provider maps the logical backend network to the deterministic project default network.

func CheckManagedRuntimeDefinition

func CheckManagedRuntimeDefinition(files RuntimeFiles, m Manifest) error

CheckManagedRuntimeDefinition prevents destructive operations from trusting a locally modified Compose file. BaseHarbor may only mutate the runtime shape it originally generated and understands for the current manifest.

func CheckRuntimePermissions

func CheckRuntimePermissions(files RuntimeFiles) error

func CheckSupportedRuntimeServices

func CheckSupportedRuntimeServices(m Manifest) error

func ConfiguredRuntimeAPIURL

func ConfiguredRuntimeAPIURL() (string, bool, error)

func EnsureRuntimeIdentity

func EnsureRuntimeIdentity(m Manifest, files RuntimeFiles) (string, error)

func ExpectedPersistentRuntimeResources

func ExpectedPersistentRuntimeResources(m Manifest) []bhruntime.ProjectResource

func ExpectedPostgresRuntimeResources

func ExpectedPostgresRuntimeResources(m Manifest) []bhruntime.ProjectResource

ExpectedPostgresRuntimeResources is kept for compatibility with the first runtime milestone. New lifecycle code should use ExpectedRuntimeResources.

func ExpectedRuntimeResources

func ExpectedRuntimeResources(m Manifest) []bhruntime.ProjectResource

func FindRepositoryManifest

func FindRepositoryManifest(start string) (string, error)

FindRepositoryManifest returns the nearest baseharbor.yaml from start upward. This lets developers run baha from nested directories inside an application repository.

func HasRequiredFileSecrets

func HasRequiredFileSecrets(m Manifest) bool

func InspectOwnedRuntimeResources

func InspectOwnedRuntimeResources(ctx context.Context, compose bhruntime.Compose, m Manifest) ([]bhruntime.ProjectResource, error)

func MaterializeRuntimeIdentityWorkloadOverride

func MaterializeRuntimeIdentityWorkloadOverride(m Manifest, workload WorkloadFiles, files RuntimeFiles, plan WorkloadBindingPlan) (string, bool, error)

MaterializeRuntimeIdentityWorkloadOverride adds only the protected bindings that selected application services actually consume. Runtime identity is injected through ordinary environment file paths plus Compose secret mounts; applications do not configure certificates, keys or broker topology.

func PostgresInstanceNames

func PostgresInstanceNames(m Manifest) []string

func ReallocateRuntimePorts

func ReallocateRuntimePorts(m Manifest, files RuntimeFiles) error

ReallocateRuntimePorts replaces only the generated host-port assignments for an already materialized application runtime. Credentials, databases, volumes and other persisted runtime values are left unchanged. This is used when the container runtime proves that a probed loopback port was claimed between allocation and the actual container bind.

func RedisInstanceNames

func RedisInstanceNames(m Manifest) []string

func RequiredSecretNames

func RequiredSecretNames(m Manifest) []string

func RequiredSecretUsesFileBinding

func RequiredSecretUsesFileBinding(name string) bool

func ResolveWorkloadCompose

func ResolveWorkloadCompose(repositoryRoot string, m Manifest) (string, bool, error)

func ResourceExists

func ResourceExists(resources []bhruntime.ProjectResource, kind string) bool

func ResourceNamedExists

func ResourceNamedExists(resources []bhruntime.ProjectResource, wanted bhruntime.ProjectResource) bool

func RestorePostgresInstances

func RestorePostgresInstances(ctx context.Context, runtime PostgresBackupRuntime, m Manifest, files RuntimeFiles, backups []PostgresBackup) error

func RevokeRuntimeIdentity

func RevokeRuntimeIdentity(m Manifest, files RuntimeFiles) error

func RotateRuntimeIdentity

func RotateRuntimeIdentity(m Manifest, files RuntimeFiles) error

func RuntimeComposeYAML

func RuntimeComposeYAML(m Manifest) (string, error)

func RuntimeIdentityRevoked

func RuntimeIdentityRevoked(files RuntimeFiles) bool

func RuntimeIdentityRevokedPath

func RuntimeIdentityRevokedPath(files RuntimeFiles) string

func RuntimeIdentityTokenPath

func RuntimeIdentityTokenPath(files RuntimeFiles) string

func RuntimeMTLSHostDir

func RuntimeMTLSHostDir(files RuntimeFiles) string

func RuntimeProjectName

func RuntimeProjectName(m Manifest) string

func SecretFileContainerPath

func SecretFileContainerPath(name string) string

func SecretFileHostDir

func SecretFileHostDir(files RuntimeFiles) string

func SecretFileHostPath

func SecretFileHostPath(files RuntimeFiles, name string) string

func ValidatePostgresBackupSet

func ValidatePostgresBackupSet(m Manifest, backups []PostgresBackup) error

func VerifyPostgresRuntime

func VerifyPostgresRuntime(ctx context.Context, compose bhruntime.Compose, m Manifest, files RuntimeFiles) error

func VerifyValkeyRuntime

func VerifyValkeyRuntime(ctx context.Context, compose bhruntime.Compose, m Manifest, files RuntimeFiles) error

func WorkloadProjectName

func WorkloadProjectName(m Manifest) string

Types

type Action

type Action struct {
	Kind        string
	Resource    string
	Description string
}

type Manifest

type Manifest struct {
	Version     int
	Name        string
	Environment string
	Services    Services
	Secrets     SecretRequirements
	Workload    WorkloadConfig
}

Manifest is the declarative application backend request understood by BaseHarbor.

func LoadManifestFile

func LoadManifestFile(path string) (Manifest, error)

func New

func New(name, environment string, postgres, redis, secrets bool) Manifest

func ParseYAML

func ParseYAML(input string) (Manifest, error)

ParseYAML parses the intentionally small v1 manifest grammar without adding a runtime dependency.

func WithPostgresInstances

func WithPostgresInstances(m Manifest, names ...string) Manifest

func WithRedisInstances

func WithRedisInstances(m Manifest, names ...string) Manifest

func WithRequiredSecrets

func WithRequiredSecrets(m Manifest, names ...string) Manifest

func WithWorkload

func WithWorkload(m Manifest, compose string, services ...string) Manifest

func (Manifest) Validate

func (m Manifest) Validate() error

func (Manifest) YAML

func (m Manifest) YAML() string

type Plan

type Plan struct {
	Application string
	Environment string
	Actions     []Action
}

func BuildPlan

func BuildPlan(m Manifest) (Plan, error)

type PostgresBackup

type PostgresBackup struct {
	Instance string
	SQL      []byte
}

func DumpPostgresInstances

func DumpPostgresInstances(ctx context.Context, runtime PostgresBackupRuntime, m Manifest, files RuntimeFiles) ([]PostgresBackup, error)

type PostgresBackupRuntime

type PostgresBackupRuntime interface {
	ExecProject(ctx context.Context, project, composeFile, envFile, service string, args ...string) (string, error)
	ExecProjectInput(ctx context.Context, project, composeFile, envFile string, input []byte, service string, args ...string) (string, error)
}

type RuntimeContract

type RuntimeContract struct {
	Env         string
	BindingsDir string
	Metadata    string
}

func EnsureRuntimeContract

func EnsureRuntimeContract(m Manifest, files RuntimeFiles) (RuntimeContract, error)

type RuntimeFiles

type RuntimeFiles struct {
	Dir            string
	Compose        string
	Env            string
	ApplicationEnv string
	Bindings       string
}

func EnsurePostgresRuntime

func EnsurePostgresRuntime(store Store, m Manifest) (RuntimeFiles, error)

EnsurePostgresRuntime is kept for callers from the first runtime milestone.

func EnsureRuntime

func EnsureRuntime(store Store, m Manifest) (RuntimeFiles, error)

func ExistingRuntimeFiles

func ExistingRuntimeFiles(store Store, m Manifest) (RuntimeFiles, error)

type SecretRequirement

type SecretRequirement struct {
	Name string
}

type SecretRequirements

type SecretRequirements struct {
	Required []SecretRequirement
}

SecretRequirements declares application-owned secret requirements. Values never belong in the manifest, and the contract intentionally does not encode a runtime delivery mechanism.

type ServiceInstance

type ServiceInstance struct{}

ServiceInstance is the stable logical identity of one requested backend service. The empty v1 shape is intentional: topology remains a BaseHarbor implementation detail and future intent such as availability can evolve here.

type Services

type Services struct {
	Postgres          bool
	Redis             bool
	Secrets           bool
	PostgresInstances map[string]ServiceInstance
	RedisInstances    map[string]ServiceInstance
}

type Store

type Store struct {
	Root string
}

func DefaultStore

func DefaultStore() Store

func (Store) Create

func (s Store) Create(m Manifest) (string, error)

func (Store) Delete

func (s Store) Delete(name string) error

func (Store) List

func (s Store) List() ([]Manifest, error)

func (Store) Load

func (s Store) Load(name string) (Manifest, string, error)

func (Store) Sync

func (s Store) Sync(m Manifest) (string, error)

Sync stores a canonical internal copy of a repository manifest while preserving already materialized runtime state. The repository file remains authoritative.

type WorkloadBindingPlan

type WorkloadBindingPlan struct {
	RuntimeIdentityServices []string
	FileSecretsByService    map[string][]string
}

func (WorkloadBindingPlan) Empty

func (p WorkloadBindingPlan) Empty() bool

type WorkloadConfig

type WorkloadConfig struct {
	Compose  string
	Services []string
}

WorkloadConfig optionally disambiguates an existing application Compose workload. Empty values keep the common case convention-based: BaseHarbor may detect one unambiguous Compose file and attach all of its services.

type WorkloadFiles

type WorkloadFiles struct {
	RepositoryRoot string
	Compose        string
	Override       string
	Services       []string
	Project        string
	Partial        bool
}

func MaterializeWorkload

func MaterializeWorkload(repositoryRoot string, m Manifest, runtime RuntimeFiles) (WorkloadFiles, bool, error)

Jump to

Keyboard shortcuts

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