config

package
v0.27.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EnvName = "RHOASCONFIG"

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() (string, error)

DefaultDir returns the default parent directory of the config file

func HasCustomLocation added in v0.26.0

func HasCustomLocation() bool

Checks if config has custom location

Types

type Config

type Config struct {
	AccessToken       string           `json:"access_token,omitempty" doc:"Bearer access token."`
	RefreshToken      string           `json:"refresh_token,omitempty" doc:"Offline or refresh token."`
	MasAuthURL        string           `json:"mas_auth_url,omitempty"`
	MasAccessToken    string           `json:"mas_access_token,omitempty"`
	MasRefreshToken   string           `json:"mas_refresh_token,omitempty"`
	Services          ServiceConfigMap `json:"services,omitempty"`
	APIUrl            string           `` /* 166-byte string literal not displayed */
	AuthURL           string           `json:"auth_url,omitempty" doc:"URL of the authentication server"`
	ClientID          string           `json:"client_id,omitempty" doc:"OpenID client identifier."`
	Insecure          bool             `` /* 142-byte string literal not displayed */
	Scopes            []string         `` /* 172-byte string literal not displayed */
	DevPreviewEnabled bool             `json:"dev_preview_enabled,omitempty" doc:"Enables Developer preview commands"`
}

Config is a type which describes the properties which can be in the config

func (*Config) HasKafka

func (c *Config) HasKafka() bool

func (*Config) HasServiceRegistry added in v0.25.0

func (c *Config) HasServiceRegistry() bool

type File

type File struct{}

File is a type which describes a config file

func (*File) Load

func (c *File) Load() (*Config, error)

Load loads the configuration from the configuration file. If the configuration file doesn't exist it will return an empty configuration object.

func (*File) Location

func (c *File) Location() (path string, err error)

Location gets the path to the config file

func (*File) Remove

func (c *File) Remove() error

Remove removes the configuration file.

func (*File) Save

func (c *File) Save(cfg *Config) error

Save saves the given configuration to the configuration file.

type IConfig

type IConfig interface {
	Load() (*Config, error)
	Save(config *Config) error
	Remove() error
	Location() (string, error)
}

IConfig is an interface which describes the functions needed to read/write from a config

func NewFile

func NewFile() IConfig

NewFile creates a new config type

type IConfigMock

type IConfigMock struct {
	// LoadFunc mocks the Load method.
	LoadFunc func() (*Config, error)

	// LocationFunc mocks the Location method.
	LocationFunc func() (string, error)

	// RemoveFunc mocks the Remove method.
	RemoveFunc func() error

	// SaveFunc mocks the Save method.
	SaveFunc func(config *Config) error
	// contains filtered or unexported fields
}

IConfigMock is a mock implementation of IConfig.

    func TestSomethingThatUsesIConfig(t *testing.T) {

        // make and configure a mocked IConfig
        mockedIConfig := &IConfigMock{
            LoadFunc: func() (*Config, error) {
	               panic("mock out the Load method")
            },
            LocationFunc: func() (string, error) {
	               panic("mock out the Location method")
            },
            RemoveFunc: func() error {
	               panic("mock out the Remove method")
            },
            SaveFunc: func(config *Config) error {
	               panic("mock out the Save method")
            },
        }

        // use mockedIConfig in code that requires IConfig
        // and then make assertions.

    }

func (*IConfigMock) Load

func (mock *IConfigMock) Load() (*Config, error)

Load calls LoadFunc.

func (*IConfigMock) LoadCalls

func (mock *IConfigMock) LoadCalls() []struct{}

LoadCalls gets all the calls that were made to Load. Check the length with:

len(mockedIConfig.LoadCalls())

func (*IConfigMock) Location

func (mock *IConfigMock) Location() (string, error)

Location calls LocationFunc.

func (*IConfigMock) LocationCalls

func (mock *IConfigMock) LocationCalls() []struct{}

LocationCalls gets all the calls that were made to Location. Check the length with:

len(mockedIConfig.LocationCalls())

func (*IConfigMock) Remove

func (mock *IConfigMock) Remove() error

Remove calls RemoveFunc.

func (*IConfigMock) RemoveCalls

func (mock *IConfigMock) RemoveCalls() []struct{}

RemoveCalls gets all the calls that were made to Remove. Check the length with:

len(mockedIConfig.RemoveCalls())

func (*IConfigMock) Save

func (mock *IConfigMock) Save(config *Config) error

Save calls SaveFunc.

func (*IConfigMock) SaveCalls

func (mock *IConfigMock) SaveCalls() []struct {
	Config *Config
}

SaveCalls gets all the calls that were made to Save. Check the length with:

len(mockedIConfig.SaveCalls())

type KafkaConfig

type KafkaConfig struct {
	ClusterID string `json:"clusterId"`
}

KafkaConfig is the config for the Kafka service

type ServiceConfigMap

type ServiceConfigMap struct {
	Kafka           *KafkaConfig           `json:"kafka"`
	ServiceRegistry *ServiceRegistryConfig `json:"serviceregistry"`
}

ServiceConfigMap is a map of configs for the application services

type ServiceRegistryConfig added in v0.25.0

type ServiceRegistryConfig struct {
	InstanceID string `json:"instanceId"`
	Name       string `json:"name"`
}

Jump to

Keyboard shortcuts

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