config

package
v3.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFlagName = "config"
	LevelFlagName  = "level"
)

Note: The application uses viper for configuration management. Viper merges configurations from various sources such as files, environment variables, and command line flags. After merging, viper unmarshals the configuration into the Configuration struct, which is then used throughout the application.

Variables

This section is empty.

Functions

func SystemShell added in v3.16.0

func SystemShell() string

Types

type AppConfig added in v3.14.3

type AppConfig struct {
	// embedded config
	*Config

	// application specific configuration
	AppName string
	V       *viper.Viper
}

func NewAppConfig added in v3.14.3

func NewAppConfig(appName string, opts ...AppConfigOption) (*AppConfig, error)

NewAppConfig creates a new AppConfig and applies any provided options.

func (*AppConfig) ConfigDirName added in v3.14.3

func (ac *AppConfig) ConfigDirName() string

ConfigDirName returns the name of the configuration directory.

func (*AppConfig) DefaultConfigFile added in v3.14.3

func (ac *AppConfig) DefaultConfigFile() string

func (*AppConfig) GetConfig added in v3.14.3

func (ac *AppConfig) GetConfig() *Config

GetConfig returns a configuration created from the viper configuration.

func (*AppConfig) GetConfigDir added in v3.14.3

func (ac *AppConfig) GetConfigDir() string

GetConfigDir returns the full path to the configuration directory

func (*AppConfig) GetConfigFile added in v3.14.3

func (ac *AppConfig) GetConfigFile() string

GetConfigFile returns the configuration file

func (*AppConfig) GetLogDir added in v3.14.3

func (ac *AppConfig) GetLogDir() string

func (*AppConfig) UpdateViperConfig added in v3.14.3

func (ac *AppConfig) UpdateViperConfig(expression string) (*Config, error)

UpdateViperConfig update the viper configuration with the given expression. expression should be a value such as "agent.model=gpt-4o-mini" The input is a viper configuration because we leverage viper to handle setting most keys. However, in some special cases we use custom functions. This is why we return a Config object.

type AppConfigOption added in v3.14.3

type AppConfigOption func(*AppConfig) error

AppConfigOption is a functional option for configuring AppConfig.

func WithViper added in v3.14.3

func WithViper(cmd *cobra.Command) AppConfigOption

WithViperCmd binds the config flag to the command line flags.

func WithViperInstance added in v3.14.3

func WithViperInstance(v *viper.Viper, cmd *cobra.Command) AppConfigOption

WithViper allows setting a custom viper instance in AppConfig.

type AssistantServerConfig

type AssistantServerConfig struct {
	// BindAddress is the address to bind to. Default is 0.0.0.0
	BindAddress string `json:"bindAddress" yaml:"bindAddress"`

	// Port is the port for the server
	Port int `json:"port" yaml:"port"`

	// HttpMaxReadTimeout is the max read duration.
	// Ref: https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts
	HttpMaxReadTimeout time.Duration `json:"httpMaxReadTimeout" yaml:"httpMaxReadTimeout"`

	// HttpMaxWriteTimeout is the max write duration.
	HttpMaxWriteTimeout time.Duration `json:"httpMaxWriteTimeout" yaml:"httpMaxWriteTimeout"`

	// CorsOrigins is a list of allowed origins for CORS requests
	CorsOrigins []string `json:"corsOrigins" yaml:"corsOrigins"`

	// StaticAssets is the path to the static assets to serve
	StaticAssets string `json:"staticAssets" yaml:"staticAssets"`

	// RunnerService starts the Runme runner service if true otherwise it doesn't start the runner service.
	RunnerService bool `json:"runnerService" yaml:"runnerService"`

	// RunnerReconnect is a flag to enable automatic reconnecting to the runner from the frontend.
	RunnerReconnect bool `json:"runnerReconnect,omitempty" yaml:"runnerReconnect,omitempty"`

	// ParserService starts the Runme parser service if true otherwise it doesn't start the parser service.
	ParserService bool `json:"parserService" yaml:"parserService"`

	// OIDC configuration
	OIDC *OIDCConfig `json:"oidc,omitempty" yaml:"oidc,omitempty"`

	// TLSConfig is the TLS configuration
	TLSConfig *TLSConfig `json:"tlsConfig,omitempty" yaml:"tlsConfig,omitempty"`

	// webAppURL is an optional URL to use for the SPA rather than serving it out of the server.
	// if configured the server will redirect to that URL for the SPA.
	// This is primarily useful during development when the SPA could be running on a separate development server.
	WebAppURL string `json:"webAppURL" yaml:"webAppURL"`
}

func (*AssistantServerConfig) GetBindAddress

func (c *AssistantServerConfig) GetBindAddress() string

func (*AssistantServerConfig) GetHttpMaxReadTimeout

func (c *AssistantServerConfig) GetHttpMaxReadTimeout() time.Duration

func (*AssistantServerConfig) GetHttpMaxWriteTimeout

func (c *AssistantServerConfig) GetHttpMaxWriteTimeout() time.Duration

func (*AssistantServerConfig) GetPort

func (c *AssistantServerConfig) GetPort() int

type CloudAssistantConfig

type CloudAssistantConfig struct {
	// VectorStores is the list of vector stores to use
	VectorStores []string `json:"vectorStores,omitempty" yaml:"vectorStores,omitempty"`
	AgentCookie  string   `json:"agentCookie,omitempty" yaml:"agentCookie,omitempty"`
	TargetURL    string   `json:"targetUrl,omitempty" yaml:"targetUrl,omitempty"`
	Model        string   `json:"model,omitempty" yaml:"model,omitempty"`
}

type Config

type Config struct {
	APIVersion string           `json:"apiVersion" yaml:"apiVersion" yamltags:"required"`
	Kind       string           `json:"kind" yaml:"kind" yamltags:"required"`
	Metadata   api.Metadata     `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Logging    Logging          `json:"logging" yaml:"logging"`
	Telemetry  *TelemetryConfig `json:"telemetry,omitempty" yaml:"telemetry,omitempty"`

	OpenAI *OpenAIConfig `json:"openai,omitempty" yaml:"openai,omitempty"`

	CloudAssistant  *CloudAssistantConfig  `json:"cloudAssistant,omitempty" yaml:"cloudAssistant,omitempty"`
	AssistantServer *AssistantServerConfig `json:"assistantServer,omitempty" yaml:"assistantServer,omitempty"`

	// WebAppConfig is the configuration for the web application.
	WebApp *agentv1.WebAppConfig `json:"webApp,omitempty" yaml:"webApp,omitempty"`

	// IAMPolicy is the IAM policy for the service. It only matters if OIDC is enabled in the AssistantServerConfig.
	IAMPolicy *api.IAMPolicy `json:"iamPolicy,omitempty" yaml:"iamPolicy,omitempty"`
	// contains filtered or unexported fields
}

Config represents the persistent configuration data.

Currently, the format of the data on disk and in memory is identical. In the future, we may modify this to simplify changes to the disk format and to store in-memory values that should not be written to disk. Could that be achieved by embedding it in a different struct which contains values that shouldn't be serialized?

func (*Config) DeepCopy

func (c *Config) DeepCopy() Config

DeepCopy returns a deep copy.

func (*Config) GetLogLevel

func (c *Config) GetLogLevel() string

func (*Config) IsValid

func (c *Config) IsValid() []string

IsValid validates the configuration and returns any errors.

func (*Config) UseHoneycomb

func (c *Config) UseHoneycomb() bool

func (*Config) Write

func (c *Config) Write(cfgFile string) error

Write saves the configuration to a file.

type GenericOIDCConfig

type GenericOIDCConfig struct {
	// ClientID is the OAuth2 client ID
	ClientID string `json:"clientID" yaml:"clientID"`
	// ClientSecret is the OAuth2 client secret
	ClientSecret string `json:"clientSecret" yaml:"clientSecret"`
	// RedirectURL is the URL to redirect users to after login
	RedirectURL string `json:"redirectURL" yaml:"redirectURL"`
	// DiscoveryURL is the URL for the OpenID Connect discovery document
	DiscoveryURL string `json:"discoveryURL" yaml:"discoveryURL"`
	// Scopes are the OAuth2 scopes to request (optional, defaults to ["openid", "email"])
	Scopes []string `json:"scopes" yaml:"scopes"`
	// Issuer allows overwriting the URL for the OpenID Connect issuer
	Issuer string `json:"issuer" yaml:"issuer"`
}

GenericOIDCConfig contains configuration for a generic OIDC provider

func (*GenericOIDCConfig) GetDiscoveryURL

func (c *GenericOIDCConfig) GetDiscoveryURL() string

GetDiscoveryURL returns the discovery URL for the generic OIDC provider

type GoogleOIDCConfig

type GoogleOIDCConfig struct {
	// ClientCredentialsFile is the path to the file containing the Google client credentials
	ClientCredentialsFile string `json:"clientCredentialsFile" yaml:"clientCredentialsFile"`
	// DiscoveryURL is the URL for the OpenID Connect discovery document
	DiscoveryURL string `json:"discoveryURL" yaml:"discoveryURL"`
}

GoogleOIDCConfig contains Google-specific OIDC configuration

func (*GoogleOIDCConfig) GetDiscoveryURL

func (c *GoogleOIDCConfig) GetDiscoveryURL() string

Add a helper method to get the discovery URL with a default

type HoneycombConfig

type HoneycombConfig struct {
	// APIKeyFile is the Honeycomb API key
	APIKeyFile string `json:"apiKeyFile" yaml:"apiKeyFile"`
}

type LogFields

type LogFields struct {
	Level   string `json:"level,omitempty" yaml:"level,omitempty"`
	Time    string `json:"time,omitempty" yaml:"time,omitempty"`
	Message string `json:"message,omitempty" yaml:"message,omitempty"`
}

LogFields is the fields to use when logging to structured logging

type LogSink

type LogSink struct {
	// Set to true to write logs in JSON format
	JSON bool `json:"json,omitempty" yaml:"json,omitempty"`
	// Path is the path to write logs to. Use "stderr" to write to stderr.
	// Use gcplogs:///projects/${PROJECT}/logs/${LOGNAME} to write to Google Cloud Logging
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

type Logging

type Logging struct {
	Level string `json:"level,omitempty" yaml:"level,omitempty"`
	// Use JSON logging
	JSON bool `json:"json,omitempty" yaml:"json,omitempty"`

	LogDir string `json:"logDir,omitempty" yaml:"logDir,omitempty"`
	// Sinks is a list of sinks to write logs to.
	// Use stderr to write to stderr.
	// Use gcplogs:///projects/${PROJECT}/logs/${LOGNAME} to write to Google Cloud Logging
	Sinks []LogSink `json:"sinks,omitempty" yaml:"sinks,omitempty"`

	LogFields *LogFields `json:"logFields,omitempty" yaml:"logFields,omitempty"`
}

type OIDCConfig

type OIDCConfig struct {
	// Google contains Google-specific OIDC configuration
	Google *GoogleOIDCConfig `json:"google,omitempty" yaml:"google,omitempty"`

	// Generic contains generic OIDC configuration
	Generic *GenericOIDCConfig `json:"generic,omitempty" yaml:"generic,omitempty"`

	// ForceApproval is a flag to force the user to approve the app again
	ForceApproval bool `json:"forceApproval" yaml:"forceApproval"`

	// ClientExchange if set to true the token exchange will happen on the client and not the server.
	// The server callback will just be used to load the appropriate page in the SPA.
	ClientExchange bool `json:"clientExchange" yaml:"clientExchange"`
}

OIDCConfig contains configuration for OIDC authentication

type OpenAIConfig

type OpenAIConfig struct {
	// APIKeyFile is the file containing the OpenAI API key
	APIKeyFile string `json:"apiKeyFile,omitempty" yaml:"apiKeyFile,omitempty"`
}

type TLSConfig

type TLSConfig struct {
	// Generate is a flag to generate a self-signed certificate if true.
	// If CertFile and KeyFile are also specified then the key is only generated if one doesn't already exist
	Generate bool `json:"generate" yaml:"generate"`

	// CertFile is the path to the TLS certificate file
	CertFile string `json:"certFile" yaml:"certFile"`
	// KeyFile is the path to the TLS key file
	KeyFile string `json:"keyFile" yaml:"keyFile"`
}

type TelemetryConfig

type TelemetryConfig struct {
	Honeycomb *HoneycombConfig `json:"honeycomb,omitempty" yaml:"honeycomb,omitempty"`
	// OtlpHTTPEndpoint is the endpoint for OTLP HTTP exporter (e.g., "localhost:4318").
	OtlpHTTPEndpoint string `json:"otlpHttpEndpoint,omitempty" yaml:"otlpHttpEndpoint,omitempty"`
}

Jump to

Keyboard shortcuts

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