config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBoolValue

func GetBoolValue(config interface{}, fieldPath string, defaultValue bool) bool

GetBoolValue retrieves a boolean value from a nested struct based on a dot-separated path. It returns the provided defaultValue if the specified field is not explicitly set or is nil.

func GetPRTempPath

func GetPRTempPath(cfg *Config, VCSURL, Namespace, RepoName string, PRId int) string

GetPRTempPath constructs the path to the temporary folder for a pull request based on the VCS URL, namespace, and repository name.

func GetRepositoryPath

func GetRepositoryPath(cfg *Config, VCSURL, repoWithNamespace string) string

GetRepositoryPath constructs the path to a repository based on the VCS URL and repository namespace.

func GetScanioHome

func GetScanioHome(cfg *Config) string

GetScanioHome returns the Scanio home directory from the configuration.

func GetScanioMode

func GetScanioMode(cfg *Config) string

GetScanioMode returns the Scanio mode from the configuration.

func GetScanioPluginsHome

func GetScanioPluginsHome(cfg *Config) string

GetScanioPluginsHome returns the Scanio plugins directory from the configuration.

func GetScanioProjectsHome

func GetScanioProjectsHome(cfg *Config) string

GetScanioProjectsHome returns the Scanio projects directory from the configuration.

func GetScanioResultsHome

func GetScanioResultsHome(cfg *Config) string

GetScanioResultsHome returns the Scanio results directory from the configuration.

func GetScanioTempHome

func GetScanioTempHome(cfg *Config) string

GetScanioTempHome returns the Scanio temporary directory from the configuration.

func IsCI

func IsCI(cfg *Config) bool

IsCI returns true if the Scanio mode is set to "CI", indicating a continuous integration environment.

func SetThen

func SetThen[T any](value T, defaultValue T) T

SetThen returns the first value if it is set; otherwise, it returns the default value.

func SetThenPtr

func SetThenPtr[T any](value *T, defaultValue T) T

SetThenPtr returns the dereferenced value if the pointer is not nil; otherwise, it returns the default value.

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig checks if the global configurations have valid values.

func ValidateGitConfig

func ValidateGitConfig(gitConfig *GitClient) error

ValidateGitConfig checks if the Git configurations have valid values.

func ValidateHTTPConfig

func ValidateHTTPConfig(httpConfig *HTTPClient) error

ValidateHTTPConfig checks if the HTTP configurations have valid values.

func ValidateScanioConfig

func ValidateScanioConfig(cfg *Config) error

ValidateScanioConfig checks if the Scanio configurations have valid values.

Types

type BaseHTTPConfig

type BaseHTTPConfig struct {
	RetryCount       int           // Number of retries for failed requests
	RetryWaitTime    time.Duration // Wait time between retries
	RetryMaxWaitTime time.Duration // Maximum wait time for retries
	Timeout          time.Duration // Timeout for requests
	TLSClientConfig  *tls.Config   // TLS configuration
	Proxy            string        // Proxy address
}

BaseHTTPConfig holds common HTTP client configuration settings.

func DefaultHTTPConfig

func DefaultHTTPConfig() BaseHTTPConfig

DefaultHTTPConfig returns a base configuration for HTTP clients with default values.

type BitbucketPlugin

type BitbucketPlugin struct {
	Username       string `yaml:"username"`         // Username for Bitbucket integrations.
	Token          string `yaml:"token"`            // Access token for Bitbucket.
	SSHKeyPassword string `yaml:"ssh_key_password"` // Password for the SSH key used in fetching operations.
}

BitbucketPlugin holds configuration specific to the Bitbucket plugin.

type CodeQLPlugin

type CodeQLPlugin struct {
	DBLanguage string `yaml:"db_language"` // Language for building the CodeQL DB.
}

CodeQLPlugin holds configuration specific to the CodeQL plugin.

type Config

type Config struct {
	Scanio          Scanio          `yaml:"scanio"`           // Scanio configuration settings.
	BitbucketPlugin BitbucketPlugin `yaml:"bitbucket_plugin"` // Bitbucket plugin configuration settings.
	GithubPlugin    GithubPlugin    `yaml:"github_plugin"`    // Github plugin configuration settings.
	GitlabPlugin    GithubPlugin    `yaml:"gitlab_plugin"`    // Gitlab plugin configuration settings.
	CodeQLPlugin    CodeQLPlugin    `yaml:"codeql_plugin"`    // CodeQL plugin configuration settings.
	Logger          Logger          `yaml:"logger"`           // Logger configuration settings.
	HTTPClient      HTTPClient      `yaml:"http_client"`      // HTTP client configuration settings.
	GitClient       GitClient       `yaml:"git_client"`       // Git client configuration settings.
}

TODO: fix issue with sending pointer to plugins which are not sharing address space with the core by serializing json Config holds configuration settings parsed from a YAML config file.

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig reads a YAML config file and decodes it into a Config struct. If configPath is empty, it searches for a config file in default paths.

type GitClient

type GitClient struct {
	Depth       int           `yaml:"depth"`        // Level of depth for cloning and fetching.
	InsecureTLS *bool         `yaml:"insecure_tls"` // Flag to skip SSL certificates if true.
	Timeout     time.Duration `yaml:"timeout"`      // The maximum duration for the Git request before timing it out.

}

GitClient configures settings for Git operations.

type GithubPlugin

type GithubPlugin struct {
	Username       string `yaml:"username"`         // Username for Github integrations.
	Token          string `yaml:"token"`            // Access token for Github.
	SSHKeyPassword string `yaml:"ssh_key_password"` // Password for the SSH key used in fetching operations.
}

GithubPlugin holds configuration specific to the Github plugin.

type GitlabPlugin

type GitlabPlugin struct {
	Username       string `yaml:"username"`         // Username for Gitlab integrations.
	Token          string `yaml:"token"`            // Access token for Gitlab.
	SSHKeyPassword string `yaml:"ssh_key_password"` // Password for the SSH key used in fetching operations.
}

GitlabPlugin holds configuration specific to the Gitlab plugin.

type HTTPClient

type HTTPClient struct {
	RetryCount       int             `yaml:"retry_count"`         // The number of times to retry an HTTP request before failing.
	RetryWaitTime    time.Duration   `yaml:"retry_wait_time"`     // The duration to wait before the first retry of a failed HTTP request.
	RetryMaxWaitTime time.Duration   `yaml:"retry_max_wait_time"` // The maximum duration to wait before subsequent retries of a failed HTTP request.
	Timeout          time.Duration   `yaml:"timeout"`             // The maximum duration for the HTTP request before timing it out.
	TLSClientConfig  TLSClientConfig `yaml:"tls_client_config"`   // TLS configuration for HTTPS connections.
	Proxy            Proxy           `yaml:"proxy"`               // A proxy configuration.
}

HTTPClient configures settings for the HTTP client used within the application.

type Logger

type Logger struct {
	Level           string `yaml:"level"`            // Logging level (e.g., DEBUG, INFO, WARN).
	DisableTime     *bool  `yaml:"disable_time"`     // Flag to disable timestamp logging if true.
	JSONFormat      *bool  `yaml:"json_format"`      // Flag to output logs in JSON format if true.
	IncludeLocation *bool  `yaml:"include_location"` // Flag to include file and line number in logs if true.
}

Logger configures the hclog logging aspects of the application.

type Proxy

type Proxy struct {
	Host string `yaml:"host"` // Hostname or IP address of the proxy server with a scheme or without.
	Port int    `yaml:"port"` // Port number of the proxy server.
}

Proxy defines the parameters to set up proxy settings for HTTP connections.

type RestyHTTPClientConfig

type RestyHTTPClientConfig struct {
	BaseHTTPConfig
	Debug bool // Flag to enable Resty debug mode
}

RestyHTTPClientConfig holds additional configuration settings for the Resty HTTP client.

func DefaultRestyConfig

func DefaultRestyConfig() RestyHTTPClientConfig

DefaultRestyConfig returns a default configuration for the Resty HTTP client, extending the base HTTP configuration.

type Scanio

type Scanio struct {
	Mode           string `yaml:"mode"`            // Scanio mode cofiguration.
	HomeFolder     string `yaml:"home_folder"`     // The home directory for Scanio.
	PluginsFolder  string `yaml:"plugins_folder"`  // The directory where Scanio plugins are stored.
	ProjectsFolder string `yaml:"projects_folder"` // The directory where Scanio project files are stored.
	ResultsFolder  string `yaml:"results_folder"`  // The directory where Scanio results are stored.
	TempFolder     string `yaml:"temp_folder"`     // The directory for temporary files used by Scanio.

}

Scanio holds configuration specific to the Scanio application.

type TLSClientConfig

type TLSClientConfig struct {
	Verify *bool `yaml:"verify"` // Flag to verify SSL certificates if true.
}

TLSClientConfig configures the TLS aspects of HTTP connections.

Jump to

Keyboard shortcuts

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