Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetSharedConfig ¶
func SetSharedConfig(ctx context.Context, c SharedConfig) context.Context
Types ¶
type Config ¶
type Config struct {
// API Keys (optional, increase rate limits)
NVDAPIKey string `env:"NVD_API_KEY" envDefault:""`
GitHubToken string `env:"GITHUB_TOKEN" envDefault:""`
// Cache Configuration
CacheBackend string `env:"CACHE_BACKEND" envDefault:"filesystem"`
CacheMaxAgeDays int `env:"HTTP_CACHE_MAX_AGE_DAYS" envDefault:"2"`
MetadataBackend string `env:"METADATA_BACKEND" envDefault:"filesystem"`
BackendGCSBucket string `env:"BACKEND_GCS_BUCKET" envDefault:"risk-guard-package-data"`
KeyPrefix string `env:"GCS_PREFIX" envDefault:"v3"`
HTTPGCSBucket string `env:"HTTP_GCS_BUCKET" envDefault:"oss-risk-guard-http-cache"`
HTTPGCSPrefix string `env:"HTTP_GCS_PREFIX" envDefault:"v1"`
ValkeyURL string `env:"VALKEY_URL" envDefault:"redis://localhost:6379"`
// HIGH_MEM_SERVER is the URL of a high-memory server running the /artifact endpoint.
// When set, artifact extraction is delegated to this server instead of running locally.
HighMemServer string `env:"HIGH_MEM_SERVER" envDefault:"https://api-mem.ossriskguard.app"`
// HIGH_MEM_AUDIENCE is the audience for ID token authentication.
// Defaults to "risk-guard-api" which is configured as a custom audience on the Cloud Run service.
HighMemAudience string `env:"HIGH_MEM_AUDIENCE" envDefault:"risk-guard-api"`
GoogleCloudProject string `env:"GOOGLE_CLOUD_PROJECT" envDefault:"oss-risk-guard"`
ScorePackageWorkflow string `env:"SCORE_PACKAGE_WORKFLOW" envDefault:"projects/oss-risk-guard/locations/us-central1/workflows/package-workflow"`
ScoreSourceWorkflow string `env:"SCORE_SOURCE_WORKFLOW" envDefault:"projects/oss-risk-guard/locations/us-central1/workflows/source-workflow"`
ScoreDepsWorkflow string `env:"SCORE_DEPS_WORKFLOW" envDefault:"projects/oss-risk-guard/locations/us-central1/workflows/score-deps-workflow"`
ServiceName string `env:"SERVICE_NAME" envDefault:"risk-guard"`
SecureGit bool `env:"SECURE_GIT" envDefault:"false"`
}
Config holds all validated environment variables for Risk Guard. This provides type-safe access to configuration with validation and prevents runtime errors from missing or invalid environment variables.
func Load ¶
Load validates and returns environment configuration. It automatically loads .env file if present in the current directory. Returns an error if any validation fails.
func (*Config) GetCacheMaxAge ¶
GetCacheMaxAge returns the cache max age as a time.Duration.
func (*Config) GetHighMemAudience ¶
func (*Config) GetHighMemServer ¶
func (*Config) GetSecureGit ¶
type SharedConfig ¶
type SharedConfig interface {
}
SharedConfig is the minimal config contract used by code shared between the local CLI and the server. Each binary supplies its own implementation.
func GetSharedConfig ¶
func GetSharedConfig(ctx context.Context) SharedConfig
GetSharedConfig retrieves the shared config from the context. Panics if missing to enforce initialization in the root command.