config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

* Copyright The Microcks Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// InsecureTLS defines if TLS transport should accept insecure certs.
	InsecureTLS bool = false
	// CaCertPaths defines extra paths (comma-separated) of CRT files to add to system CA Roots.
	CaCertPaths string
	// Verbose represents a debug flag for HTTP Exchanges
	Verbose bool = false

	ConfigPath = filepath.Join(os.Getenv("HOME"), ".microcks-cli", "config.yaml")
)

Functions

func CreateTLSConfig

func CreateTLSConfig() *tls.Config

CreateTLSConfig wraps the creation of tls.Config object for use with HTTP Client for example.

func DefaultConfigDir

func DefaultConfigDir() (string, error)

DefaultConfigDir returns the local configuration path for settings such as cached authentication tokens.

func DefaultLocalConfigPath

func DefaultLocalConfigPath() (string, error)

DefaultLocalConfigPath returns the local configuration path for settings such as cached authentication tokens.

func DumpRequestIfRequired

func DumpRequestIfRequired(name string, req *http.Request, body bool)

DumpRequestIfRequired takes care of dumping request if configured that way

func DumpResponseIfRequired

func DumpResponseIfRequired(name string, resp *http.Response, body bool)

DumpResponseIfRequired takes care of dumping request if configured that way

func SaveConfig

func SaveConfig(path string, cfg *Config) error

func ValidateLocalConfig

func ValidateLocalConfig(config LocalConfig) error

func WriteLocalConfig

func WriteLocalConfig(config LocalConfig, configPath string) error

WriteLocalConfig writes a new local configuration file.

Types

type Auth

type Auth struct {
	Server       string
	ClientId     string
	ClientSecret string
}

type Config

type Config struct {
	Instance struct {
		Name        string `yaml:"name"`
		Image       string `yaml:"image"`
		Status      string `yaml:"status"`
		Port        string `yaml:"port"`
		ContainerID string `yaml:"containerID"`
		AutoRemove  bool   `yaml:"autoRemove"`
		Driver      string `yaml:"driver"`
	} `yaml:"instance"`
}

func EnsureConfig

func EnsureConfig(path string) (*Config, error)

func LoadConfig

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

type Context

type Context struct {
	Name     string
	User     User
	Server   Server
	Instance Instance
}

type ContextRef

type ContextRef struct {
	Name     string `yaml:"name"`
	Server   string `yaml:"server"`
	User     string `yaml:"user"`
	Instance string `yaml:"instance"`
}

type Instance

type Instance struct {
	Name        string `yaml:"name"`
	Image       string `yaml:"image"`
	Status      string `yaml:"status"`
	Port        string `yaml:"port"`
	ContainerID string `yaml:"containerID"`
	AutoRemove  bool   `yaml:"autoRemove"`
	Driver      string `yaml:"driver"`
}

type LocalConfig

type LocalConfig struct {
	CurrentContext string       `yaml:"current-context"`
	Contexts       []ContextRef `yaml:"contexts"`
	Servers        []Server     `yaml:"servers"`
	Users          []User       `yaml:"users"`
	Instances      []Instance   `yaml:"instances"`
	Auths          []Auth       `yaml:"auths"`
}

func ReadLocalConfig

func ReadLocalConfig(path string) (*LocalConfig, error)

ReadLocalConfig loads up the local configuration file. Returns nil if config does not exist

func (*LocalConfig) DeleteLocalConfig

func (l *LocalConfig) DeleteLocalConfig(configPath string) error

func (*LocalConfig) GetAuth

func (l *LocalConfig) GetAuth(server string) (*Auth, error)

func (*LocalConfig) GetInstance

func (l *LocalConfig) GetInstance(name string) (*Instance, error)

func (*LocalConfig) GetServer

func (l *LocalConfig) GetServer(name string) (*Server, error)

func (*LocalConfig) GetUser

func (l *LocalConfig) GetUser(name string) (*User, error)

func (*LocalConfig) IsEmpty

func (l *LocalConfig) IsEmpty() bool

func (*LocalConfig) RemoveAuth

func (l *LocalConfig) RemoveAuth(server string) bool

func (*LocalConfig) RemoveContext

func (l *LocalConfig) RemoveContext(serverName string) (string, bool)

func (*LocalConfig) RemoveInstance

func (l *LocalConfig) RemoveInstance(instanceName string) bool

Returns true if server was removed successfully

func (*LocalConfig) RemoveServer

func (l *LocalConfig) RemoveServer(serverName string) bool

Returns true if server was removed successfully

func (*LocalConfig) RemoveUser

func (l *LocalConfig) RemoveUser(serverName string) bool

Returns true if user was removed successfully

func (*LocalConfig) ResolveContext

func (l *LocalConfig) ResolveContext(name string) (*Context, error)

ResolveContext resolves the specified context. If unspecified, resolves the current context

func (*LocalConfig) UpserAuth

func (l *LocalConfig) UpserAuth(auth Auth)

func (*LocalConfig) UpserContext

func (l *LocalConfig) UpserContext(context ContextRef)

func (*LocalConfig) UpsertInstance

func (l *LocalConfig) UpsertInstance(instance Instance)

func (*LocalConfig) UpsertServer

func (l *LocalConfig) UpsertServer(server Server)

func (*LocalConfig) UpsertUser

func (l *LocalConfig) UpsertUser(user User)

type Server

type Server struct {
	Name            string `yaml:"name"`
	Server          string `yaml:"server"`
	InsecureTLS     bool   `yaml:"insecureTLS"`
	KeycloackEnable bool   `yaml:"keycloakEnable"`
}

type User

type User struct {
	Name         string `yaml:"name"`
	AuthToken    string `yaml:"auth-token"`
	RefreshToken string `yaml:"refresh-token"`
}

Jump to

Keyboard shortcuts

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