configuration

package
v0.0.0-...-470703e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ORGANIZATION                   string = "org"
	DEBUG                          string = "debug"
	DEBUG_FORMAT                   string = "debug_format"
	INSECURE_HTTPS                 string = "insecure"
	PROXY_AUTHENTICATION_MECHANISM string = "proxy_auth"
	INPUT_DIRECTORY                string = "targetDirectory"
	FIPS_ENABLED                   string = "gofips"

	// flags
	FLAG_EXPERIMENTAL       string = "experimental"
	FLAG_INCLUDE_IGNORES    string = "include-ignores"
	FLAG_SEVERITY_THRESHOLD string = "severity-threshold"

	// snyk_ constants
	API_URL              string = "snyk_api" // AKA "endpoint" in the config file
	AUTHENTICATION_TOKEN string = "snyk_token"
	//nolint:gosec // not a token value, a configuration key
	AUTHENTICATION_BEARER_TOKEN     string = "snyk_oauth_token"
	INTEGRATION_NAME                string = "snyk_integration_name"
	INTEGRATION_VERSION             string = "snyk_integration_version"
	INTEGRATION_ENVIRONMENT         string = "snyk_integration_environment"
	INTEGRATION_ENVIRONMENT_VERSION string = "snyk_integration_environment_version"
	ANALYTICS_DISABLED              string = "snyk_disable_analytics"
	TEMP_DIR_PATH                   string = "snyk_tmp_path"
	CACHE_PATH                      string = "snyk_cache_path"
	TIMEOUT                         string = "snyk_timeout_secs"
	LOG_LEVEL                       string = "snyk_log_level" // string that defines the log level based on zerolog levels (trace,debug,info,...)

	// internal constants
	CUSTOM_CONFIG_FILES            string = "internal_custom_config_files"
	WORKFLOW_USE_STDIO             string = "internal_wflstdio"
	RAW_CMD_ARGS                   string = "internal_raw_cmd_args"
	WEB_APP_URL                    string = "internal_snyk_app"
	MAX_THREADS                    string = "internal_max_thread_count"
	WORKING_DIRECTORY              string = "internal_working_dir"
	IS_FEDRAMP                     string = "internal_is_fedramp"
	ORGANIZATION_SLUG              string = "internal_org_slug"
	AUTHENTICATION_SUBDOMAINS      string = "internal_auth_subdomain"             // array of additional subdomains to add authentication for
	AUTHENTICATION_ADDITIONAL_URLS string = "internal_additional_auth_urls"       // array of additional urls to add authentication for
	ADD_TRUSTED_CA_FILE            string = "internal_additional_trusted_ca_file" // pem file location containing additional CAs to trust
	PREVIEW_FEATURES_ENABLED       string = "internal_preview_features_enabled"   // boolean indicates if preview features shall be enabled
	UNKNOWN_ARGS                   string = "internal_unknown_arguments"          // arguments unknown to the current application but maybe relevant for delegated application calls
	IN_MEMORY_THRESHOLD_BYTES      string = "internal_in_memory_threshold_bytes"  // threshold to determine where to store workflow.Data
	// feature flags
	FF_OAUTH_AUTH_FLOW_ENABLED string = "internal_snyk_oauth_enabled"
	FF_CODE_CONSISTENT_IGNORES string = "internal_snyk_code_ignores_enabled"
	FF_TRANSFORMATION_WORKFLOW string = "internal_snyk_transformation_workflow_enabled"
)

Variables

This section is empty.

Functions

func CreateConfigurationFile

func CreateConfigurationFile(filename string) (string, error)

CreateConfigurationFile creates a configuration file with the given name.

Types

type Configuration

type Configuration interface {
	Clone() Configuration

	Set(key string, value interface{})
	Get(key string) interface{}
	Unset(key string)
	IsSet(key string) bool
	GetString(key string) string
	GetStringSlice(key string) []string
	GetBool(key string) bool
	GetInt(key string) int
	GetFloat64(key string) float64
	GetUrl(key string) *url.URL
	GetWithError(key string) (interface{}, error)

	AddFlagSet(flagset *pflag.FlagSet) error
	AllKeys() []string
	AddDefaultValue(key string, defaultValue DefaultValueFunction)
	AddAlternativeKeys(key string, altKeys []string)
	GetAlternativeKeys(key string) []string
	GetAllKeysThatContainValues(key string) []string
	GetKeyType(key string) KeyType

	// PersistInStorage ensures that when Set is called with the given key, it will be persisted in the config file.
	PersistInStorage(key string)
	SetStorage(storage Storage)
	GetStorage() Storage

	AutomaticEnv()
	GetAutomaticEnv() bool
	SetSupportedEnvVars(envVars ...string)
	GetSupportedEnvVars() []string
	SetSupportedEnvVarPrefixes(prefixes ...string)
	GetSupportedEnvVarPrefixes() []string
	SetFiles(files ...string)
	GetFiles() []string
	ReloadConfig() error
}

Configuration is an interface for managing configuration values.

func New

func New() Configuration

New creates a new snyk configuration file.

func NewFromFiles deprecated

func NewFromFiles(files ...string) Configuration

Deprecated: Use NewWithOpts with configuration.WithFiles() and configuration.WithAutomaticEnv() options instead

NewFromFiles creates a new Configuration instance from the given files.

func NewInMemory deprecated

func NewInMemory() Configuration

Deprecated: Use NewWithOpts with configuration.WithAutomaticEnv() option instead

NewInMemory creates a new Configuration instance that is not persisted to disk.

func NewWithOpts

func NewWithOpts(opts ...Opts) Configuration

NewWithOpts creates a new snyk configuration file with optional parameters

type DefaultValueFunction

type DefaultValueFunction func(existingValue interface{}) (interface{}, error)

func StandardDefaultValueFunction

func StandardDefaultValueFunction(defaultValue interface{}) DefaultValueFunction

StandardDefaultValueFunction is a default value function that returns the default value if the existing value is nil.

type EmptyStorage

type EmptyStorage struct{}

func (*EmptyStorage) Lock

func (*EmptyStorage) Refresh

func (*EmptyStorage) Set

func (*EmptyStorage) Set(string, any) error

func (*EmptyStorage) Unlock

func (*EmptyStorage) Unlock() error

type JsonOption

type JsonOption func(*JsonStorage)

func WithConfiguration

func WithConfiguration(c Configuration) JsonOption

type JsonStorage

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

func NewJsonStorage

func NewJsonStorage(path string, options ...JsonOption) *JsonStorage

func (*JsonStorage) Lock

func (s *JsonStorage) Lock(ctx context.Context, retryDelay time.Duration) error

func (*JsonStorage) Refresh

func (s *JsonStorage) Refresh(config Configuration, key string) error

func (*JsonStorage) Set

func (s *JsonStorage) Set(key string, value any) error

func (*JsonStorage) Unlock

func (s *JsonStorage) Unlock() error

type KeyType

type KeyType int
const (
	EnvVarKeyType      KeyType = iota
	UnspecifiedKeyType KeyType = iota
)

type Opts

type Opts = func(config Configuration)

func WithAutomaticEnv

func WithAutomaticEnv() Opts

func WithFiles

func WithFiles(files ...string) Opts

func WithSupportedEnvVarPrefixes

func WithSupportedEnvVarPrefixes(prefixes ...string) Opts

func WithSupportedEnvVars

func WithSupportedEnvVars(envVars ...string) Opts

type Storage

type Storage interface {
	Set(key string, value any) error
	Refresh(config Configuration, key string) error
	Lock(ctx context.Context, retryDelay time.Duration) error
	Unlock() error
}

Jump to

Keyboard shortcuts

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