config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config provides the configuration for the application.

Index

Constants

View Source
const (
	// PublicAssetGetURLExpiryViperKey is the viper key for the public asset get URL expiry
	PublicAssetGetURLExpiryViperKey = "api.assets.public-asset-get-url-expiry"
	// PrivateAssetGetURLExpiryViperKey is the viper key for the private asset get URL expiry
	PrivateAssetGetURLExpiryViperKey = "api.assets.private-asset-get-url-expiry"
	// RefreshAssetURLExpiryViperKey is the viper key for the refresh asset URL expiry
	RefreshAssetURLExpiryViperKey = "api.assets.refresh-asset-url-expiry"
	// APIListenViperKey is the viper key for the listen address
	APIListenViperKey = "api.listen"
	// APIHTTPViperKey is the viper key for the http server
	APIHTTPViperKey = "api.http"
	// APIHTTPListenViperKey is the viper key for the http listen address
	APIHTTPListenViperKey = "api.httplisten"
	// APITimeoutViperKey is the viper key for the timeout
	APITimeoutViperKey = "api.timeout"

	// DefaultPublicAssetGetURLExpiry is the default public asset get URL expiry
	DefaultPublicAssetGetURLExpiry = 7 * 24 * time.Hour
	// DefaultPrivateAssetGetURLExpiry is the default private asset get URL expiry
	DefaultPrivateAssetGetURLExpiry = 1 * time.Hour
	// DefaultRefreshAssetURLExpiry is the default refresh asset URL expiry
	DefaultRefreshAssetURLExpiry = 30 * time.Minute
)
View Source
const (
	// GCPStorageEmulatorViperKey is the viper key for the gcp storage emulator
	GCPStorageEmulatorViperKey = "gcp.storage.emulator"
	// GCPStorageBucketNameViperKey is the viper key for the gcp storage bucket name
	GCPStorageBucketNameViperKey = "gcp.storage.bucket-name"
	// GCPStorageCORSMaxAgeViperKey is the viper key for the gcp storage CORS max age
	GCPStorageCORSMaxAgeViperKey = "gcp.storage.cors.max-age"
	// GCPStorageCORSMethodsViperKey is the viper key for the gcp storage CORS methods
	GCPStorageCORSMethodsViperKey = "gcp.storage.cors.methods"
	// GCPStorageCORSOriginsViperKey is the viper key for the gcp storage CORS origins
	GCPStorageCORSOriginsViperKey = "gcp.storage.cors.origins"
	// GCPStorageCORSHeadersViperKey is the viper key for the gcp storage CORS headers
	GCPStorageCORSHeadersViperKey = "gcp.storage.cors.headers"
)
View Source
const (
	// GCloudServiceAccountViperKey is the viper key for the gcloud service account
	GCloudServiceAccountViperKey = "gcp.serviceaccount"
	// GCloudServiceAccountEmailViperKey is the viper key for the gcloud service account email
	GCloudServiceAccountEmailViperKey = "gcp.serviceaccount-email"
	// GCloudProjectIDViperKey is the viper key for the gcloud project id
	GCloudProjectIDViperKey = "gcp.projectid"
	// GCloudFirestoreEmulatorViperKey is the viper key for the gcloud firestore emulator
	GCloudFirestoreEmulatorViperKey = "gcp.firestore-emulator"
)

Variables

View Source
var (
	// ErrMissingGCPProjectID is returned when the GCP project ID is missing
	ErrMissingGCPProjectID = errors.New("missing GCP project ID")

	// ErrMissingGCPServiceAccountEmail is returned when the GCP service account email is missing
	ErrMissingGCPServiceAccountEmail = errors.New("missing GCP service account email")
)

Functions

func APIViperFlags

func APIViperFlags(root *cobra.Command)

APIViperFlags sets the viper flags for the API

func GCloudViperFlags

func GCloudViperFlags(root *cobra.Command)

GCloudViperFlags adds the gcloud flags to the root command

func StorageViperFlags

func StorageViperFlags(root *cobra.Command)

StorageViperFlags adds the cloud storage flags to the root command

func ViperFlags

func ViperFlags(root *cobra.Command)

ViperFlags adds the configuration flags to the root command

Types

type API

type API struct {
	PrivateAssetGetURLExpiry time.Duration
	PublicAssetGetURLExpiry  time.Duration
	RefreshAssetURLExpiry    time.Duration

	GRPCListen string
	HTTPListen string
	HTTP       bool
	Timeout    int
	// contains filtered or unexported fields
}

API holds the configuration for the API

func (*API) Configure

func (a *API) Configure()

Configure sets the API configuration

type CloudStorage

type CloudStorage struct {
	Emulator string
	Bucket   string
	CORS     storage.CORS

	PrivateAssetGetURLExpiry time.Duration
	PublicAssetGetURLExpiry  time.Duration
	RefreshAssetURLExpiry    time.Duration
	// contains filtered or unexported fields
}

CloudStorage holds the configuration for cloud storage

func (*CloudStorage) Configure

func (s *CloudStorage) Configure()

Configure sets the cloud storage configuration

func (*CloudStorage) StorageClient

func (s *CloudStorage) StorageClient(
	ctx context.Context, app *firebase.App, account string,
	opts ...cloudstorage.Opt,
) (*cloudstorage.CloudStorage, error)

StorageClient returns a new storage client

type Config

type Config struct {
	CloudStorage
	GCloud
	API
	// contains filtered or unexported fields
}

Config holds the configuration for the application

func New

func New(opts ...Opt) *Config

New creates a new configuration

type GCloud

type GCloud struct {
	ServiceAccount      string
	ServiceAccountEmail string
	ProjectID           string
	Emulator            string
	// contains filtered or unexported fields
}

GCloud holds the configuration for gcloud

func (*GCloud) Configure

func (g *GCloud) Configure()

Configure sets the gcloud configuration

func (*GCloud) Firebase

func (g *GCloud) Firebase(ctx context.Context) (*firebase.App, error)

Firebase returns a new firebase app

type Opt

type Opt func(*Config)

Opt is a functional option for Config

func WithLogger

func WithLogger(logger *zap.Logger) Opt

WithLogger sets the logger for the configuration

Jump to

Keyboard shortcuts

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