config

package
v0.0.0-...-25a572b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package config resolves shared configuration for services, and provides functions to access this configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key, fallback string) string

GetEnv looks up the given key from the environment, returning its value if it exists, and otherwise returning the given fallback value.

func GetEnvInt

func GetEnvInt(key, fallback string, errVal int) int

GetEnvInt performs GetEnv(key, fallback) and parses the result as int. If parsing fails, returns errVal.

func OnCloudRun

func OnCloudRun() bool

OnCloudRun reports whether the current process is running on Cloud Run.

Types

type Config

type Config struct {
	// ProjectID is the Google Cloud ProjectID where the resources live.
	ProjectID string

	// VersionID is the identifier for the version currently running.
	// We do not use the version ID from Cloud Run (see
	// https://cloud.google.com/run/docs/reference/container-contract).
	// Instead, we use the DOCKER_IMAGE environment variable, set
	// in the Cloud Build deploy file.
	VersionID string

	// LocationID is the location for the GCP project.
	LocationID string

	// ServiceID names the Cloud Run service.
	ServiceID string

	// StaticPath is the directory containing static files.
	StaticPath template.TrustedSource

	// ServiceAccount is the email of the service account that this process
	// is running as when on GCP.
	ServiceAccount string

	// UseErrorReporting determines whether errors go to the Error Reporting API.
	UseErrorReporting bool

	// BigQueryDataset is the BigQuery dataset to write results to.
	BigQueryDataset string

	// QueueName is the name of the Cloud Tasks queue.
	QueueName string

	// QueueURL is the URL that the Cloud Tasks queue should send requests to.
	// It should be used when the worker is not on AppEngine.
	QueueURL string

	// LocalQueueWorkers is the number of concurrent requests to the fetch service,
	// when running locally.
	LocalQueueWorkers int

	// MonitoredResource represents the resource that is running the current binary.
	// It might be a Google AppEngine app, a Cloud Run service, or a Kubernetes pod.
	// See https://cloud.google.com/monitoring/api/resources for more details:
	// "An object representing a resource that can be used for monitoring, logging,
	// billing, or other purposes. Examples include virtual machine instances,
	// databases, and storage devices such as disks.""
	MonitoredResource *mrpb.MonitoredResource

	// DevMode indicates whether the server is running in development mode.
	DevMode bool

	// VulnDBBucketProjectID is the project ID for the vuln DB bucket and its
	// associated load balancer.
	VulnDBBucketProjectID string

	// BinaryBucket holds binaries for govulncheck scanning.
	BinaryBucket string

	// BinaryDir is the local directory for binaries.
	BinaryDir string

	// VulnDBDir is the local directory of the vulnerability database.
	VulnDBDir string

	// PkgsiteDBHost is the host of the pkgsite db used to find modules to scan.
	PkgsiteDBHost string
	// PkgsiteDBPort is the port of the pkgsite db used to find modules to scan.
	PkgsiteDBPort string
	// PkgsiteDBName is the name of the pkgsite db used to find modules to scan.
	PkgsiteDBName string
	// PkgsiteDBUser is the user of the pkgsite db used to find modules to scan.
	PkgsiteDBUser string
	// PkgsiteDBSecret is the name of the secret holding the pkgsite db password.
	PkgsiteDBSecret string

	// Insecure runs analysis binaries without sandbox.
	Insecure bool

	// ProxyURL is the url for the Go module proxy.
	ProxyURL string
}

Config holds configuration information for the worker server.

func Init

func Init(ctx context.Context) (_ *Config, err error)

Init resolves all configuration values provided by the config package. It must be called before any configuration values are used.

func (*Config) Dump

func (c *Config) Dump(w io.Writer) error

Dump outputs the current config information to the given Writer.

func (*Config) Validate

func (c *Config) Validate() error

Jump to

Keyboard shortcuts

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