provider

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package provider contains target-platform adapters. It never owns Pack rules, plan lifecycle, or HTTP presentation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCredentialFileMissing    = errors.New("credential file is missing")
	ErrCredentialFileUnreadable = errors.New("credential file is unreadable")
	ErrCredentialJSONInvalid    = errors.New("credential file is not valid JSON")
	ErrCredentialServiceAccount = errors.New("credential file is not a Firebase service account")
	ErrCredentialFieldsMissing  = errors.New("credential file is missing required fields")
)
View Source
var (
	ErrNotConfigured = errors.New("provider is not configured")
	ErrUnauthorized  = errors.New("provider unauthorized")
	ErrUnavailable   = errors.New("provider unavailable")
	ErrValidation    = errors.New("provider validation failed")
	ErrETagMismatch  = errors.New("provider etag mismatch")
)

Functions

func CredentialErrorMessage

func CredentialErrorMessage(err error) string

CredentialErrorMessage is suitable for the CLI. The server must use its own stable, path-free response messages when rendering browser errors.

func CredentialPathDisplay

func CredentialPathDisplay(credentialsPath string) string

CredentialPathDisplay intentionally reveals only the final file name.

func LoadCredentialReference

func LoadCredentialReference(workspace, environmentID string) (string, error)

LoadCredentialReference reads only a filesystem reference. The service account JSON itself remains outside the workspace and is never copied here.

func SafeError

func SafeError(err error) error

func SaveCredentialReference

func SaveCredentialReference(workspace, environmentID, credentialsPath string) error

SaveCredentialReference stores a local path reference under .conflow, which is ignored by Git. It never copies service account JSON into the workspace.

func ValidateFirebaseServiceAccount

func ValidateFirebaseServiceAccount(credentialsPath string) error

ValidateFirebaseServiceAccount verifies that a local path can be used by Firebase without retaining or returning the credential's private contents.

Types

type Adapter

type Adapter interface {
	Connect(context.Context) error
	Status(context.Context) Status
	Pull(context.Context) (Template, error)
	Validate(context.Context, []byte) error
	Capabilities() Capabilities
}

Adapter owns only provider protocol calls. Credentials are represented by a local reference and are never returned by this interface.

type Capabilities

type Capabilities struct {
	Pull     bool `json:"pull"`
	Validate bool `json:"validate"`
	Publish  bool `json:"publish"`
	Rollback bool `json:"rollback"`
}

type CredentialValidationError

type CredentialValidationError struct {
	Kind    error
	Path    string
	Missing []string
}

CredentialValidationError retains only local validation metadata. It never carries JSON content, so callers cannot accidentally echo a private key.

func (*CredentialValidationError) Error

func (e *CredentialValidationError) Error() string

func (*CredentialValidationError) Unwrap

func (e *CredentialValidationError) Unwrap() error

type Firebase

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

func NewFirebase

func NewFirebase(config FirebaseConfig) *Firebase

func (*Firebase) Capabilities

func (f *Firebase) Capabilities() Capabilities

func (*Firebase) Connect

func (f *Firebase) Connect(ctx context.Context) error

func (*Firebase) ListVersions

func (f *Firebase) ListVersions(ctx context.Context) ([]Version, error)

ListVersions is intentionally metadata-only. The Remote Config REST API has no secret-bearing version endpoint; this query is safe to expose only through application orchestration.

func (*Firebase) Publish

func (f *Firebase) Publish(ctx context.Context, input []byte, expectedETag string) (Template, error)

Publish performs the only destructive Firebase operation. The caller must have already compared the current ETag; If-Match closes the race afterwards.

func (*Firebase) Pull

func (f *Firebase) Pull(ctx context.Context) (Template, error)

func (*Firebase) PullVersion

func (f *Firebase) PullVersion(ctx context.Context, version string) (Template, error)

PullVersion performs a read-only fetch of a historical Firebase template. Firebase accepts the version selector on the same Remote Config resource.

func (*Firebase) Status

func (f *Firebase) Status(context.Context) Status

func (*Firebase) String

func (f *Firebase) String() string

func (*Firebase) Validate

func (f *Firebase) Validate(ctx context.Context, input []byte) error

type FirebaseConfig

type FirebaseConfig struct {
	ProjectID       string
	CredentialsPath string
	BaseURL         string // Test-only override; production uses the Firebase REST origin.
	HTTPClient      *http.Client
}

type Publisher

type Publisher interface {
	Adapter
	Publish(context.Context, []byte, string) (Template, error)
}

Publisher is deliberately separate from Adapter so read-only test doubles and future providers do not accidentally advertise a destructive capability.

type Status

type Status struct {
	Status       string
	Capabilities Capabilities
}

type Template

type Template struct {
	Raw        []byte
	ETag       string
	Version    string
	ObservedAt time.Time
}

type Version

type Version struct {
	Version     string    `json:"version"`
	CreatedAt   time.Time `json:"created_at"`
	Description string    `json:"description,omitempty"`
}

Version is a metadata-only historical Firebase Remote Config version. It deliberately contains no template values.

type VersionReader

type VersionReader interface {
	Adapter
	ListVersions(context.Context) ([]Version, error)
	PullVersion(context.Context, string) (Template, error)
}

VersionReader is optional because rollback can use the protected release snapshot, while provider implementations may additionally expose historical platform versions without granting mutation authority.

Jump to

Keyboard shortcuts

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