config

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config provides commands for a CLI config management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEnvironmentToConfig

func AddEnvironmentToConfig(c *cli.Context, cfg *CLIConfig, environmentID string) error

AddEnvironmentToConfig adds a new environment to CLIConfig.

func BuildFileName

func BuildFileName(dirname string) string

BuildFileName builds a config filename.

func CommandList

func CommandList() []*cli.Command

CommandList returns available commands for a CLI config management.

func GetDirname

func GetDirname() (string, error)

GetDirname returns the CLI config path located in the current user's home directory.

func GetFilename

func GetFilename() (string, error)

GetFilename returns the CLI config filename located in the current user's home directory.

func SaveConfig

func SaveConfig(filename string, cfg *CLIConfig) error

SaveConfig persists a CLI config.

Types

type CLIConfig

type CLIConfig struct {
	CurrentEnvironment string                 `yaml:"current_environment" json:"current_environment"`
	Environments       map[string]Environment `yaml:"environments" json:"environments"`
}

CLIConfig defines a format of CLI configuration.

func Load

func Load(filename string) (*CLIConfig, error)

Load loads a CLI config by a provided filename.

type Duration

type Duration time.Duration

Duration defines a custom duration type.

func (*Duration) Duration

func (d *Duration) Duration() time.Duration

Duration retrieves duration from a custom type.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON marshals json duration.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML marshals yaml duration.

func (Duration) String

func (d Duration) String() string

String returns formatted duration.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON un-marshals json duration.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML marshals yaml duration.

type Environment

type Environment struct {
	EnvironmentID  string     `yaml:"-" json:"environment_id"`
	URL            string     `yaml:"url" json:"url"`
	Token          string     `yaml:"token" json:"token"`
	Insecure       bool       `yaml:"insecure" json:"insecure"`
	RequestTimeout Duration   `yaml:"request_timeout,omitempty" json:"request_timeout,omitempty"`
	Forwarding     Forwarding `yaml:"forwarding" json:"forwarding"`
}

Environment defines a format of environment configuration.

type Forwarding

type Forwarding struct {
	ServerURL    string `yaml:"server_url" json:"server_url"`
	LocalPort    string `yaml:"local_port" json:"local_port"`
	IdentityFile string `yaml:"identity_file" json:"identity_file"`
}

Forwarding defines configuration for port forwarding.

Jump to

Keyboard shortcuts

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