config

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthRBACSimplified = "simplified"
	AuthRBACExternal   = "external"
)

Variables

View Source
var DefaultLocalBSPath = "~/.jiaozifs/blockstore"

Functions

func InitConfig

func InitConfig(cfgFile string) error

Types

type APIConfig

type APIConfig struct {
	Listen string `mapstructure:"listen"`
}

type AuthConfig

type AuthConfig struct {
	SecretKey string `mapstructure:"secretKey"`

	UIConfig struct {
		RBAC               string   `mapstructure:"rbac"`
		LoginURL           string   `mapstructure:"login_url"`
		LoginFailedMessage string   `mapstructure:"login_failed_message"`
		FallbackLoginURL   *string  `mapstructure:"fallback_login_url"`
		FallbackLoginLabel *string  `mapstructure:"fallback_login_label"`
		LoginCookieNames   []string `mapstructure:"login_cookie_names"`
		LogoutURL          string   `mapstructure:"logout_url"`
	} `mapstructure:"ui_config"`
}

type BlockStoreConfig

type BlockStoreConfig struct {
	Type                   string  `mapstructure:"type" validate:"required" json:"type"`
	DefaultNamespacePrefix *string `mapstructure:"default_namespace_prefix" json:"default_namespace_prefix"`

	Local *struct {
		Path                    string   `mapstructure:"path" json:"path"`
		ImportEnabled           bool     `mapstructure:"import_enabled" json:"import_enabled"`
		ImportHidden            bool     `mapstructure:"import_hidden" json:"import_hidden"`
		AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes" json:"allowed_external_prefixes"`
	} `mapstructure:"local" json:"local"`
	S3 *struct {
		S3AuthInfo                    `mapstructure:",squash"`
		Region                        string        `mapstructure:"region" json:"region"`
		Endpoint                      string        `mapstructure:"endpoint" json:"endpoint"`
		MaxRetries                    int           `mapstructure:"max_retries" json:"max_retries"`
		ForcePathStyle                bool          `mapstructure:"force_path_style" json:"force_path_style"`
		DiscoverBucketRegion          bool          `mapstructure:"discover_bucket_region" json:"discover_bucket_region"`
		SkipVerifyCertificateTestOnly bool          `mapstructure:"skip_verify_certificate_test_only" json:"skip_verify_certificate_test_only"`
		ServerSideEncryption          string        `mapstructure:"server_side_encryption" json:"server_side_encryption"`
		ServerSideEncryptionKmsKeyID  string        `mapstructure:"server_side_encryption_kms_key_id" json:"server_side_encryption_kms_key_id"`
		PreSignedExpiry               time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
		DisablePreSigned              bool          `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
		DisablePreSignedUI            bool          `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
		ClientLogRetries              bool          `mapstructure:"client_log_retries" json:"client_log_retries"`
		ClientLogRequest              bool          `mapstructure:"client_log_request" json:"client_log_request"`
		WebIdentity                   *struct {
			SessionDuration     time.Duration `mapstructure:"session_duration" json:"session_duration"`
			SessionExpiryWindow time.Duration `mapstructure:"session_expiry_window" json:"session_expiry_window"`
		} `mapstructure:"web_identity"`
	} `mapstructure:"s3" json:"s3"`
	Azure *struct {
		TryTimeout         time.Duration `mapstructure:"try_timeout" json:"try_timeout"`
		StorageAccount     string        `mapstructure:"storage_account" json:"storage_account"`
		StorageAccessKey   string        `mapstructure:"storage_access_key" json:"storage_access_key"`
		PreSignedExpiry    time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
		DisablePreSigned   bool          `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
		DisablePreSignedUI bool          `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
		// TestEndpointURL for testing purposes
		TestEndpointURL string `mapstructure:"test_endpoint_url" json:"test_endpoint_url"`
	} `mapstructure:"azure" json:"azure"`
	GS *struct {
		S3Endpoint         string        `mapstructure:"s3_endpoint" json:"s3_endpoint"`
		CredentialsFile    string        `mapstructure:"credentials_file" json:"credentials_file"`
		CredentialsJSON    string        `mapstructure:"credentials_json" json:"credentials_json"`
		PreSignedExpiry    time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
		DisablePreSigned   bool          `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
		DisablePreSignedUI bool          `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
	} `mapstructure:"gs" json:"gs"`
}

func (*BlockStoreConfig) BlockstoreAzureParams

func (c *BlockStoreConfig) BlockstoreAzureParams() (params.Azure, error)

func (*BlockStoreConfig) BlockstoreGSParams

func (c *BlockStoreConfig) BlockstoreGSParams() (params.GS, error)

func (*BlockStoreConfig) BlockstoreLocalParams

func (c *BlockStoreConfig) BlockstoreLocalParams() (params.Local, error)

func (*BlockStoreConfig) BlockstoreS3Params

func (c *BlockStoreConfig) BlockstoreS3Params() (params.S3, error)

func (*BlockStoreConfig) BlockstoreType

func (c *BlockStoreConfig) BlockstoreType() string

type Config

type Config struct {
	Path     string         `mapstructure:"config"`
	Log      LogConfig      `mapstructure:"log"`
	API      APIConfig      `mapstructure:"api"`
	Database DatabaseConfig `mapstructure:"database"`
	Auth     AuthConfig     `mapstructure:"auth"`

	Blockstore BlockStoreConfig `mapstructure:"blockstore"`
}

func LoadConfig

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

LoadConfig reads in config file and ENV variables if set.

type DatabaseConfig

type DatabaseConfig struct {
	Connection string `mapstructure:"connection"`
	Debug      bool   `mapstructure:"debug"`
}

type LogConfig

type LogConfig struct {
	Level string `mapstructure:"level"`
}

type S3AuthInfo

type S3AuthInfo struct {
	CredentialsFile string `mapstructure:"credentials_file" json:"credentials_file"`
	Profile         string
	Credentials     *struct {
		AccessKeyID     SecureString `mapstructure:"access_key_id" json:"access_key_id"`
		SecretAccessKey SecureString `mapstructure:"secret_access_key" json:"secret_access_key"`
		SessionToken    SecureString `mapstructure:"session_token" json:"session_token"`
	}
}

S3AuthInfo holds S3-style authentication.

type SecureString

type SecureString string

func (SecureString) SecureValue

func (s SecureString) SecureValue() string

SecureValue returns the actual value of s as a string.

func (SecureString) String

func (SecureString) String() string

String returns an elided version. It is safe to call for logging.

Jump to

Keyboard shortcuts

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