cmd

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GCPCloudRunDeployImage

func GCPCloudRunDeployImage(f ConfigFile, image GCPArtifactRegistryContainerImage) []string

GCPCloudRunDeployImage builds arguments for running a service on Cloud Run given an Artifact Registry image.

func Genesis

func Genesis() (err error)

Genesis command runs the Genesis service and seeds the database.

func LoadEnv

func LoadEnv(env Env) (err error)

LoadEnv conditionally sets the environment from a config file relative to whichever environment is being set. If Existing is passed as EnvConfig, the current environment is used and not overridden.

func NewEncryptionKey

func NewEncryptionKey()

NewEncryptionKey generates a random 256-bit key and prints it to standard out. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue. Taken from https://github.com/gtank/cryptopasta/blob/master/encrypt.go

func PSQLArgs

func PSQLArgs(up bool) ([]string, error)

PSQLArgs takes a slice of DDL files to be executed and builds a sequence of command line arguments using the appropriate flags psql needs to execute files. The arguments returned for psql are as follows:

-w flag is set to never prompt for a password as we are running this as a script

-d flag sets the database connection using a Connection URI string.

-f flag is sent before each file to tell it to process the file

func Run

func Run(args []string) (err error)

Run parses command line flags and starts the server

Types

type ConfigCueFilePaths

type ConfigCueFilePaths struct {
	// Input defines the list of paths for files to be taken as input for CUE
	Input []string
	// Output defines the path for the JSON output of CUE
	Output string
}

ConfigCueFilePaths defines the paths for config files processed through CUE.

func CUEGenesisPaths

func CUEGenesisPaths() ConfigCueFilePaths

CUEGenesisPaths returns the ConfigCueFilePaths for the Genesis config. Paths are relative to the project root.

func CUEPaths

func CUEPaths(env Env) (ConfigCueFilePaths, error)

CUEPaths returns the ConfigCueFilePaths given the environment. Paths are relative to the project root.

type ConfigFile

type ConfigFile struct {
	Config struct {
		HTTPServer struct {
			ListenPort int `json:"listenPort"`
		} `json:"httpServer"`
		Logger struct {
			MinLogLevel   string `json:"minLogLevel"`
			LogLevel      string `json:"logLevel"`
			LogErrorStack bool   `json:"logErrorStack"`
		} `json:"logger"`
		Database struct {
			Host       string `json:"host"`
			Port       int    `json:"port"`
			Name       string `json:"name"`
			User       string `json:"user"`
			Password   string `json:"password"`
			SearchPath string `json:"searchPath"`
		} `json:"database"`
		EncryptionKey string `json:"encryptionKey"`
		GCP           struct {
			ProjectID        string `json:"projectID"`
			ArtifactRegistry struct {
				RepoLocation string `json:"repoLocation"`
				RepoName     string `json:"repoName"`
				ImageID      string `json:"imageID"`
				Tag          string `json:"tag"`
			} `json:"artifactRegistry"`
			CloudSQL struct {
				InstanceName           string `json:"instanceName"`
				InstanceConnectionName string `json:"instanceConnectionName"`
			} `json:"cloudSQL"`
			CloudRun struct {
				ServiceName string `json:"serviceName"`
			} `json:"cloudRun"`
		} `json:"gcp"`
	} `json:"config"`
}

ConfigFile defines the configuration file. It is the superset of fields for the various environments/builds. For example, when setting the local environment based on the ConfigFile, you do not need to fill any of the GCP fields.

func NewConfigFile

func NewConfigFile(env Env) (ConfigFile, error)

NewConfigFile initializes a ConfigFile struct from a JSON file at a predetermined file path for each environment (paths are relative to project root)

Production: ./config/production.json

Staging: ./config/staging.json

Local: ./config/local.json

type Env

type Env uint8

Env defines the environment

const (
	// Existing environment - current environment is not overridden
	Existing Env = iota
	// Local environment (Local machine)
	Local
	// Staging environment (GCP)
	Staging
	// Production environment (GCP)
	Production

	// Invalid defines an invalid environment option
	Invalid Env = 99
)

func ParseEnv

func ParseEnv(envStr string) Env

ParseEnv converts an env string into an Env value. returns Invalid if the input string does not match known values.

func (Env) String

func (e Env) String() string

type GCPArtifactRegistryContainerImage

type GCPArtifactRegistryContainerImage struct {
	ProjectID          string
	RepositoryLocation string
	RepositoryName     string
	ImageName          string
	ImageTag           string
}

GCPArtifactRegistryContainerImage defines a GCP Artifact Registry build image according to https://cloud.google.com/artifact-registry/docs/docker/names The String method prints the build string needed to build to Artifact Registry using gcloud as well as deploy it to Cloud Run.

func (GCPArtifactRegistryContainerImage) String

String outputs the Google Artifact Registry image name. LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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