config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: GPL-3.0 Imports: 20 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthContext

func NewAuthContext() *authContext

func NewDeviceContext

func NewDeviceContext() *deviceContext

in: cookbook - the cookbook in context

Types

type AuthContext

type AuthContext interface {
	Reset() error

	Load(input io.Reader) error
	Save(output io.Writer) error

	SetToken(token *oauth2.Token)
	GetToken() *oauth2.Token

	SetPublicKey(keyID, keyData string)
	GetPublicKey() (string, string)

	IsLoggedIn() bool
}

provides an interface for saving and retrieving an oauth token

type Config

type Config interface {
	Reset() error

	Load() error
	Save() error

	GetConfigAsOf() int64
	SetConfigAsOf(asOf int64)

	EULAAccepted() bool
	SetEULAAccepted()

	Initialized() bool
	SetInitialized()

	HasPassphrase() bool
	SetPassphrase(passphrase string)

	SetKeyTimeout(timeout time.Duration)
	AuthContext() AuthContext
	DeviceContext() DeviceContext
	TargetContext() TargetContext

	SetLoggedInUser(userID, userName string) error

	ContextVars() map[string]string
}

provides an interface for managing application configuration

func InitFileConfig

func InitFileConfig(
	path string,
	cookbook *cookbook.Cookbook,
	getPassphrase GetPassphrase,
	uploadConfig UploadConfig,
) (Config, error)

initializes file based configuration

in: path - the path of the config file in: cookbook - the embedded cookbook the config should be

associated with

in: getPassphrase - callback to get the passphrase that will be

used for encrytion of sensitive information

in: uploadConfig - config upload function

out: a Config instance containing the global

configuration for CloudBuilder

type DeviceContext

type DeviceContext interface {
	Reset() error

	Load(input io.Reader) error
	Save(output io.Writer) error

	NewDevice() (*userspace.Device, error)
	SetDeviceID(deviceIDKey, deviceID, name string) *userspace.Device
	GetDevice() *userspace.Device
	GetDeviceIDKey() string
	GetDeviceID() (string, bool)
	GetDeviceName() (string, bool)

	NewManagedDevice() (*userspace.Device, error)
	GetManagedDevice(deviceName string) *userspace.Device
	GetManagedDevices() []*userspace.Device
	DeleteManageDevice(deviceID string)

	NewOwnerUser(userID, name string) (*userspace.User, error)
	GetOwner() *userspace.User
	GetOwnerUserID() (string, bool)
	GetOwnerUserName() (string, bool)
	IsAuthorizedUser(name string) bool

	NewGuestUser(userID, name string) (*userspace.User, error)
	AddGuestUser(user *userspace.User)
	GetGuestUsers() []*userspace.User
	GetGuestUser(name string) (*userspace.User, bool)
	ResetGuestUsers() map[string]*userspace.User

	SetLoggedInUser(userID, userName string)
	GetLoggedInUserID() string
	GetLoggedInUserName() string
	GetLoggedInUser() (*userspace.User, error)
}

provides an interface for saving and retrieving an oauth token

type GetPassphrase

type GetPassphrase func() string

type GetSystemPassphrase

type GetSystemPassphrase func() string
var SystemPassphrase GetSystemPassphrase

Function to retrieve a passphrase to encrypt temporarily saved keys. By default this will be the timestamp of the executable for this program.

type TargetContext

type TargetContext interface {
	Reset() error

	Load(input io.Reader) error
	Save(output io.Writer) error

	Cookbook() *cookbook.Cookbook
	GetCookbookRecipe(recipe, iaas string) (cookbook.Recipe, error)
	SaveCookbookRecipe(recipe cookbook.Recipe)

	CloudProviderTemplates() []provider.CloudProvider
	GetCloudProvider(iaas string) (provider.CloudProvider, error)
	SaveCloudProvider(provider provider.CloudProvider)

	NewTarget(recipeKey, recipeIaas string) (*target.Target, error)
	TargetSet() *target.TargetSet
	HasTarget(name string) bool
	GetTarget(name string) (*target.Target, error)
	SaveTarget(key string, target *target.Target)
	DeleteTarget(key string)

	IsDirty() bool
}

provides an interface for managing the configuration context

func NewConfigContext

func NewConfigContext(cookbook *cookbook.Cookbook) (TargetContext, error)

in: cookbook - the cookbook in context

type UploadConfig

type UploadConfig func(key string, configData []byte, asOf int64) (int64, error)

Jump to

Keyboard shortcuts

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