config

package
v0.0.0-...-880cb89 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RepoID = "repo_id"

	// Corso passphrase in config
	CorsoPassphrase = "passphrase"
	CorsoUser       = "corso_user"
	CorsoHost       = "corso_host"
)

Variables

This section is empty.

Functions

func AddConfigFlags

func AddConfigFlags(cmd *cobra.Command)

adds the persistent flag --config-file to the provided command.

func GetAndInsertCorso

func GetAndInsertCorso(passphase string) credentials.Corso

GetCorso is a helper for aggregating Corso secrets and credentials.

func GetM365

func GetM365(m365Cfg account.M365Config) credentials.M365

M365 is a helper for aggregating m365 secrets and credentials.

func GetStorageProviderFromConfigFile

func GetStorageProviderFromConfigFile(ctx context.Context) (storage.ProviderType, error)

GetStorageProviderFromConfigFile reads the storage provider from the config file. Storage provider can only be sourced from config file with the exception of commands that create or connect to a repo.

func GetViper

func GetViper(ctx context.Context) *viper.Viper

Gets a viper instance from the context. If no viper instance is found, returns the default (global) viper instance.

func InitCmd

func InitCmd(cmd *cobra.Command, args []string) error

InitCmd provides a func that lazily initializes viper and verifies that the configuration was able to read a file.

func InitConfig

func InitConfig(
	ctx context.Context,
	userDefinedConfigFile string,
) (context.Context, error)

InitConfig allows sdk consumers to initialize viper.

func Read

func Read(ctx context.Context) error

Read reads the config from the viper instance in the context. Primarily used as a test-check to ensure the instance was set up properly.

func Seed

func Seed(ctx context.Context) context.Context

Seed embeds a viper instance in the context.

func SetViper

func SetViper(ctx context.Context, vpr *viper.Viper) context.Context

Adds a viper instance to the context. If vpr is nil, sets the default (global) viper.

func WriteRepoConfig

func WriteRepoConfig(
	ctx context.Context,
	wcs storage.WriteConfigToStorer,
	m365Config account.M365Config,
	repoOpts repository.Options,
	repoID string,
) error

WriteRepoConfig currently just persists corso config to the config file It does not check for conflicts or existing data.

Types

type RepoDetails

type RepoDetails struct {
	Storage  storage.Storage
	Account  account.Account
	RepoID   string
	RepoUser string
	RepoHost string
}

RepoDetails holds the repository configuration retrieved from the .corso.toml configuration file.

func ReadCorsoConfig

func ReadCorsoConfig(
	ctx context.Context,
	provider storage.ProviderType,
	readFromFile bool,
	mustMatchFromConfig bool,
	overrides map[string]string,
) (RepoDetails, error)

ReadCorsoConfig creates a storage and account instance by mediating all the possible data sources (config file, env vars, flag overrides) and the config file.

Jump to

Keyboard shortcuts

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