Documentation
¶
Index ¶
- Constants
- Variables
- func ApplicationBackendNetworkName(m Manifest) string
- func ApplicationExposureNetworkName(m Manifest) string
- func CapabilityBindings(m Manifest) ([]capability.Binding, error)
- func CheckControlPlaneDestroySafe() error
- func CheckManagedRuntimeDefinition(files RuntimeFiles, m Manifest) error
- func CheckReferenceProviderRegistry(m Manifest) error
- func CheckRuntimePermissions(files RuntimeFiles) error
- func CheckSupportedRuntimeServices(m Manifest) error
- func ConfiguredRuntimeAPIURL() (string, bool, error)
- func EnsureRuntimeIdentity(m Manifest, files RuntimeFiles) (string, error)
- func ExpectedPersistentRuntimeResources(m Manifest) []bhruntime.ProjectResource
- func ExpectedPostgresRuntimeResources(m Manifest) []bhruntime.ProjectResource
- func ExpectedRuntimeResources(m Manifest) []bhruntime.ProjectResource
- func FindRepositoryManifest(start string) (string, error)
- func GenerateSecretValue(generation SecretGeneration) ([]byte, error)
- func HasExplicitWorkload(m Manifest) bool
- func HasManagedRuntimeServices(m Manifest) bool
- func HasRequiredFileSecrets(m Manifest) bool
- func InspectOwnedRuntimeResources(ctx context.Context, compose bhruntime.Compose, m Manifest) ([]bhruntime.ProjectResource, error)
- func ManagedSecretsSecureBinding(m Manifest) capability.SecureBinding
- func MaterializeRuntimeIdentityWorkloadOverride(m Manifest, workload WorkloadFiles, files RuntimeFiles, ...) (string, bool, error)
- func PostgresInstanceNames(m Manifest) []string
- func ReallocateRuntimePorts(m Manifest, files RuntimeFiles) error
- func ReconcileReferenceProviderRegistry(m Manifest) error
- func RedisInstanceNames(m Manifest) []string
- func ReleaseApplicationProviderRegistry(m Manifest) error
- func RequiredSecretNames(m Manifest) []string
- func RequiredSecretUsesFileBinding(name string) bool
- func ResolveCapabilityResources(contract PortableContract) ([]capability.Resource, error)
- func ResolveWorkloadCompose(repositoryRoot string, m Manifest) (string, bool, error)
- func ResourceExists(resources []bhruntime.ProjectResource, kind string) bool
- func ResourceNamedExists(resources []bhruntime.ProjectResource, wanted bhruntime.ProjectResource) bool
- func RestorePostgresInstances(ctx context.Context, runtime PostgresBackupRuntime, m Manifest, ...) error
- func RevokeRuntimeIdentity(m Manifest, files RuntimeFiles) error
- func RotateRuntimeIdentity(m Manifest, files RuntimeFiles) error
- func RuntimeComposeYAML(m Manifest) (string, error)
- func RuntimeIdentityRevoked(files RuntimeFiles) bool
- func RuntimeIdentityRevokedPath(files RuntimeFiles) string
- func RuntimeIdentityTokenPath(files RuntimeFiles) string
- func RuntimeMTLSHostDir(files RuntimeFiles) string
- func RuntimeProjectName(m Manifest) string
- func SecretFileContainerPath(name string) string
- func SecretFileHostDir(files RuntimeFiles) string
- func SecretFileHostPath(files RuntimeFiles, name string) string
- func ValidatePostgresBackupSet(m Manifest, backups []PostgresBackup) error
- func VerifyPostgresRuntime(ctx context.Context, compose bhruntime.Compose, m Manifest, files RuntimeFiles) error
- func VerifyValkeyRuntime(ctx context.Context, compose bhruntime.Compose, m Manifest, files RuntimeFiles) error
- func WorkloadProjectName(m Manifest) string
- type Action
- type BackupMetadata
- type CapabilityKind
- type CapabilityRequirement
- type HTTPExposureRequirement
- type Manifest
- func LoadManifestFile(path string) (Manifest, error)
- func New(name, environment string, postgres, redis, secrets bool) Manifest
- func ParseYAML(input string) (Manifest, error)
- func WithGeneratedSecret(m Manifest, name, generationType string, size int) Manifest
- func WithHTTPExposure(m Manifest, name, service string, port int, protocol string) Manifest
- func WithPostgresInstances(m Manifest, names ...string) Manifest
- func WithRedisInstances(m Manifest, names ...string) Manifest
- func WithRequiredSecrets(m Manifest, names ...string) Manifest
- func WithWorkload(m Manifest, compose string, services ...string) Manifest
- type Plan
- type PortableContract
- type PostgresBackup
- type PostgresBackupRuntime
- type RecoveryMetadata
- type RuntimeContract
- type RuntimeFiles
- type SecretContract
- type SecretGeneration
- type SecretRequirement
- type SecretRequirements
- type ServiceBinding
- type ServiceInstance
- type Services
- type Store
- func (s Store) Create(m Manifest) (string, error)
- func (s Store) Delete(name string) error
- func (s Store) LastBackup(applicationName string) (BackupMetadata, error)
- func (s Store) LastRecovery(applicationName string) (RecoveryMetadata, error)
- func (s Store) LastUpdate(applicationName string) (UpdateMetadata, error)
- func (s Store) List() ([]Manifest, error)
- func (s Store) Load(name string) (Manifest, string, error)
- func (s Store) RecordLastBackup(metadata BackupMetadata) error
- func (s Store) RecordLastRecovery(metadata RecoveryMetadata) error
- func (s Store) RecordLastUpdate(metadata UpdateMetadata) error
- func (s Store) Sync(m Manifest) (string, error)
- type UpdateMetadata
- type WorkloadBindingPlan
- type WorkloadConfig
- type WorkloadFiles
Constants ¶
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" )
const CurrentVersion = 1
const (
LastBackupMetadataVersion = 1
)
const (
LastRecoveryMetadataVersion = 1
)
const (
LastUpdateMetadataVersion = 1
)
const MaxPostgresBackupBytes int64 = 512 << 20
const RepositoryManifestName = "baseharbor.yaml"
Variables ¶
var ErrExists = errors.New("application already exists")
var ErrNoBackupMetadata = errors.New("no application backup metadata recorded")
var ErrNoRecoveryMetadata = errors.New("no application recovery metadata recorded")
var ErrNoUpdateMetadata = errors.New("no application update metadata recorded")
var ErrRuntimeAPIURL = errors.New("application runtime API URL is invalid")
var ErrRuntimeDefinitionChanged = errors.New("application runtime definition differs from the BaseHarbor-managed definition")
var ErrRuntimeNotApplied = errors.New("application runtime has not been applied")
var ErrUnsupportedService = errors.New("application contains services that are not yet supported by apply")
var ErrWorkloadComposeAmbiguous = errors.New("multiple application Compose files found")
var ErrWorkloadComposeNotFound = errors.New("application Compose file not found")
Functions ¶
func ApplicationBackendNetworkName ¶
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 ApplicationExposureNetworkName ¶ added in v0.4.4
ApplicationExposureNetworkName returns the stable Compose network used to connect explicitly exposed workload endpoints to the selected exposure provider. It is separate from the managed backend network because endpoint exposure must also work for workload-only applications.
func CapabilityBindings ¶ added in v0.4.1
func CapabilityBindings(m Manifest) ([]capability.Binding, error)
func CheckControlPlaneDestroySafe ¶ added in v0.4.4
func CheckControlPlaneDestroySafe() error
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 CheckReferenceProviderRegistry ¶ added in v0.4.4
CheckReferenceProviderRegistry validates the protected provider registry and simulates the desired application reconciliation without writing it. Lifecycle callers use this during preflight so invalid provider metadata fails before any runtime or workload mutation.
func CheckRuntimePermissions ¶
func CheckRuntimePermissions(files RuntimeFiles) error
func ConfiguredRuntimeAPIURL ¶
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 ¶
FindRepositoryManifest returns the nearest baseharbor.yaml from start upward. This lets developers run baha from nested directories inside an application repository.
func GenerateSecretValue ¶
func GenerateSecretValue(generation SecretGeneration) ([]byte, error)
func HasExplicitWorkload ¶ added in v0.3.0
HasExplicitWorkload reports whether the repository manifest explicitly declares a Compose workload. Workload-only applications must be explicit so validation never guesses based on files outside the manifest.
func HasManagedRuntimeServices ¶ added in v0.3.0
HasManagedRuntimeServices reports whether BaseHarbor owns a materialized PostgreSQL or Valkey runtime for the application. Managed secrets currently require one of those services and therefore do not form a standalone runtime.
func HasRequiredFileSecrets ¶
func ManagedSecretsSecureBinding ¶ added in v0.4.5
func ManagedSecretsSecureBinding(m Manifest) capability.SecureBinding
ManagedSecretsSecureBinding describes the existing BaseHarbor runtime identity/secret-delivery semantics without exposing OpenBao paths, AppRoles, policies, tokens, private keys, or provider-specific object names.
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 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 ReconcileReferenceProviderRegistry ¶ added in v0.4.2
func RedisInstanceNames ¶
func ReleaseApplicationProviderRegistry ¶ added in v0.4.2
func RequiredSecretNames ¶
func ResolveCapabilityResources ¶ added in v0.4.1
func ResolveCapabilityResources(contract PortableContract) ([]capability.Resource, error)
func ResolveWorkloadCompose ¶
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 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 SecretFileContainerPath ¶
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 VerifyValkeyRuntime ¶
func WorkloadProjectName ¶
Types ¶
type BackupMetadata ¶ added in v0.3.0
type BackupMetadata struct {
Version int `json:"version"`
Application string `json:"application"`
Environment string `json:"environment"`
CreatedAt time.Time `json:"created_at"`
ArchivePath string `json:"archive_path"`
PostgresResources []string `json:"postgres_resources,omitempty"`
IncludesSecrets bool `json:"includes_secrets"`
}
func (BackupMetadata) Validate ¶ added in v0.3.0
func (m BackupMetadata) Validate() error
type CapabilityKind ¶ added in v0.4.0
type CapabilityKind = capability.Kind
CapabilityKind and CapabilityRequirement remain aliases in the application package so existing v0.4 callers keep their source-compatible contract while the reusable capability domain moves into the shared core.
const ( CapabilitySQL CapabilityKind = capability.SQL CapabilityKeyValue CapabilityKind = capability.KeyValue CapabilityExposureHTTP CapabilityKind = capability.ExposureHTTP )
type CapabilityRequirement ¶ added in v0.4.0
type CapabilityRequirement = capability.Requirement
type HTTPExposureRequirement ¶ added in v0.4.4
type HTTPExposureRequirement struct {
Name string
Service string
Port int
Protocol string
Visibility string
}
HTTPExposureRequirement is provider-neutral public HTTP exposure intent. Hostname, host port, TLS source paths and reverse-proxy implementation are deployment/provider state and deliberately absent.
type Manifest ¶
type Manifest struct {
Version int
Name string
Environment string
Services Services
Secrets SecretRequirements
Workload WorkloadConfig
Exposures []HTTPExposureRequirement
}
Manifest is the declarative application backend request understood by BaseHarbor.
func LoadManifestFile ¶
func ParseYAML ¶
ParseYAML parses the intentionally small v1 manifest grammar without adding a runtime dependency.
func WithGeneratedSecret ¶
func WithHTTPExposure ¶ added in v0.4.4
func WithPostgresInstances ¶
func WithRedisInstances ¶
func WithRequiredSecrets ¶
type PortableContract ¶ added in v0.4.0
type PortableContract struct {
Application string
Capabilities []CapabilityRequirement
Secrets SecretContract
Exposures []HTTPExposureRequirement
}
PortableContract is the provider-neutral application requirement view used as the seam between manifest compatibility and runtime/capability providers.
Deployment context such as environment, Compose paths, host ports, TLS source directories and provider object names must not be added here. Those belong to deployment state or provider-specific configuration.
func PortableContractFromManifest ¶ added in v0.4.0
func PortableContractFromManifest(m Manifest) (PortableContract, error)
PortableContractFromManifest translates the current manifest v1 compatibility surface into provider-neutral requirements without changing manifest behavior. The translation is deliberately one-way for now: v0.4 can evolve a future contract schema while existing v0.3 manifests continue to load unchanged.
type PostgresBackup ¶
func DumpPostgresInstances ¶
func DumpPostgresInstances(ctx context.Context, runtime PostgresBackupRuntime, m Manifest, files RuntimeFiles) ([]PostgresBackup, error)
type PostgresBackupRuntime ¶
type RecoveryMetadata ¶ added in v0.3.0
type RecoveryMetadata struct {
Version int `json:"version"`
Application string `json:"application"`
Environment string `json:"environment"`
RestoredAt time.Time `json:"restored_at"`
BackupCreatedAt time.Time `json:"backup_created_at"`
ArchivePath string `json:"archive_path"`
}
func (RecoveryMetadata) Validate ¶ added in v0.3.0
func (m RecoveryMetadata) Validate() error
type RuntimeContract ¶
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)
func RuntimeFilesFor ¶ added in v0.4.4
func RuntimeFilesFor(store Store, m Manifest) RuntimeFiles
type SecretContract ¶ added in v0.4.0
type SecretContract struct {
Managed bool
Required []SecretRequirement
}
SecretContract describes secret intent without selecting a concrete secret backend or delivery mechanism. Required values remain names/generation intent only; provider credentials and provider object identifiers never belong here.
type SecretGeneration ¶
type SecretRequirement ¶
type SecretRequirement struct {
Name string
Generate *SecretGeneration
}
func GeneratedSecretRequirements ¶
func GeneratedSecretRequirements(m Manifest) []SecretRequirement
func SecretRequirementByName ¶
func SecretRequirementByName(m Manifest, name string) (SecretRequirement, bool)
type SecretRequirements ¶
type SecretRequirements struct {
Required []SecretRequirement
}
SecretRequirements declares application-owned secret requirements. Values never belong in the manifest. Generate only expresses explicit intent for BaseHarbor to create a missing value directly in the managed secret backend.
type ServiceBinding ¶ added in v0.3.0
type ServiceBinding struct {
Kind string
Instance string
Host string
Port string
Database string
Username string
Password string
URI string
}
ServiceBinding is the provider-neutral information needed by developer access actions. Callers should prefer these fields over runtime/container names so a later provider can satisfy the same action model.
func ResolveServiceBinding ¶ added in v0.3.0
func ResolveServiceBinding(files RuntimeFiles, kind, instance string) (ServiceBinding, error)
ResolveServiceBinding loads an already-materialized owner-only service binding. It never creates or rotates credentials.
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) LastBackup ¶ added in v0.3.0
func (s Store) LastBackup(applicationName string) (BackupMetadata, error)
func (Store) LastRecovery ¶ added in v0.3.0
func (s Store) LastRecovery(applicationName string) (RecoveryMetadata, error)
func (Store) LastUpdate ¶ added in v0.3.0
func (s Store) LastUpdate(applicationName string) (UpdateMetadata, error)
func (Store) RecordLastBackup ¶ added in v0.3.0
func (s Store) RecordLastBackup(metadata BackupMetadata) error
func (Store) RecordLastRecovery ¶ added in v0.3.0
func (s Store) RecordLastRecovery(metadata RecoveryMetadata) error
func (Store) RecordLastUpdate ¶ added in v0.3.0
func (s Store) RecordLastUpdate(metadata UpdateMetadata) error
type UpdateMetadata ¶ added in v0.3.0
type UpdateMetadata struct {
Version int `json:"version"`
Application string `json:"application"`
Environment string `json:"environment"`
UpdatedAt time.Time `json:"updated_at"`
Branch string `json:"branch"`
Upstream string `json:"upstream"`
FromRevision string `json:"from_revision"`
ToRevision string `json:"to_revision"`
Result string `json:"result"`
BackupPath string `json:"backup_path,omitempty"`
BackupCreatedAt time.Time `json:"backup_created_at,omitempty"`
}
func (UpdateMetadata) Validate ¶ added in v0.3.0
func (m UpdateMetadata) Validate() error
type WorkloadBindingPlan ¶
type WorkloadBindingPlan struct {
RuntimeIdentityServices []string
FileSecretsByService map[string][]string
}
func (WorkloadBindingPlan) Empty ¶
func (p WorkloadBindingPlan) Empty() bool
type WorkloadConfig ¶
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)
Source Files
¶
- access.go
- backup_metadata.go
- capability_model.go
- contract.go
- generated_secrets.go
- manifest.go
- network.go
- plan.go
- postgres_backup.go
- provider_registry.go
- recovery_metadata.go
- repository_manifest.go
- runtime_contract.go
- runtime_identity.go
- runtime_identity_workload.go
- runtime_inspect.go
- runtime_lifecycle.go
- runtime_ports.go
- runtime_postgres.go
- runtime_shape.go
- secure_binding.go
- store.go
- update_metadata.go
- workload.go