config

package
v0.0.0-...-9a99cb8 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogger

func ConfigureLogger(opts LoggerOptions)

Types

type AuthMode

type AuthMode string

Auth-mode

const (
	AuthModeCluster AuthMode = "cluster"
	AuthModeToken   AuthMode = "token"
	AuthModeLocal   AuthMode = "local"
)

type Config

type Config struct {
	AuthMode          AuthMode `mapstructure:"auth-mode"`
	AllowedNamespaces []string `mapstructure:"allowed-namespaces"`
	KubeConfig        string   `mapstructure:"kube-config"`

	// server options
	Server struct {
		Addr             string `validate:"omitempty,hostname_port"`
		BasePath         string `mapstructure:"base-path"`
		GinMode          string `mapstructure:"gin-mode" validate:"omitempty,oneof=debug release"`
		AgentDispatchUrl string `mapstructure:"agent-dispatch-url"`

		// session options
		Session struct {
			Secret string

			// cookie options
			Cookie struct {
				Name     string
				Path     string
				Domain   string
				MaxAge   int `mapstructure:"max-age"`
				Secure   bool
				HttpOnly bool          `mapstructure:"http-only"`
				SameSite http.SameSite `mapstructure:"same-site"`
			}
		}

		// csrf options
		CSRF struct {
			Enabled   bool
			Secret    string
			FieldName string `mapstructure:"field-name"`

			// cookie options
			Cookie struct {
				Name     string
				Path     string
				Domain   string
				MaxAge   int `mapstructure:"max-age"`
				Secure   bool
				HttpOnly bool              `mapstructure:"http-only"`
				SameSite csrf.SameSiteMode `mapstructure:"same-site"`
			}
		}

		// logging options
		Logging struct {
			// enable logging
			Enabled bool

			// log level
			Level string `validate:"oneof=debug info warn error disabled"`

			// log format
			Format string `validate:"oneof=json pretty"`

			// access-log options
			AccessLog struct {
				// enable access-log
				Enabled bool

				// hide health checks
				HideHealthChecks bool `mapstructure:"hide-health-checks"`
			} `mapstructure:"access-log"`
		}

		// TLS options
		TLS struct {
			// enable tls termination
			Enabled bool

			// TLS certificate file
			CertFile string `mapstructure:"cert-file" validate:"omitempty,file"`

			// TLS certificate key file
			KeyFile string `mapstructure:"key-file" validate:"omitempty,file"`
		}
	}

	// agent options
	Agent struct {
		Addr             string `validate:"omitempty,hostname_port"`
		ContainerLogsDir string `mapstructure:"container-logs-dir"`

		// TLS options
		TLS struct {
			// enable tls termination
			Enabled bool

			// TLS certificate file
			CertFile string `mapstructure:"cert-file" validate:"omitempty,file"`

			// TLS certificate key file
			KeyFile string `mapstructure:"key-file" validate:"omitempty,file"`
		}

		// logging options
		Logging struct {
			// enable logging
			Enabled bool

			// log level
			Level string `validate:"oneof=debug info warn error disabled"`

			// log format
			Format string `validate:"oneof=json pretty"`
		}
	}
}

Application configuration

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(v *viper.Viper, f string) (*Config, error)

type LoggerOptions

type LoggerOptions struct {
	Enabled bool
	Level   string
	Format  string
}

Logging options

Jump to

Keyboard shortcuts

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