types

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName = "config.yaml"
	ConfigDir      = ".config/gws"
	DirectionUp    = "up"
	DirectionDown  = "down"
)
View Source
const TokenFileName = "token.yaml"

Variables

This section is empty.

Functions

func DefaultConfigDir

func DefaultConfigDir() (newConfigPath, userHomeDir string)

func GetTokenFilePath

func GetTokenFilePath() (string, error)

func LoadToken

func LoadToken() (*oauth2.Token, error)

func ReadGWSFile

func ReadGWSFile(fileName string) (absoluteFile string, data []byte, err error)

func SaveToken

func SaveToken(token oauth2.Token) error

func SetToken

func SetToken(token oauth2.Token) error

Types

type Config

type Config struct {
	Contexts           map[string]*Context  `validate:"required,dive,required" yaml:"contexts"`
	CurrentContextName string               `                                  yaml:"currentContext"`
	FilePath           string               `                                  yaml:"-"`
	TokenCheck         bool                 `                                  yaml:"-"`
	FilePatches        map[string]FilePatch `                                  yaml:"filePatches,omitempty"`
	SSHTimeoutSeconds  int                  `                                  yaml:"sshTimeoutSeconds,omitempty"`

	Token *TokenStorage `                                  yaml:"-"`
	// contains filtered or unexported fields
}

func (*Config) CurrentContext

func (c *Config) CurrentContext() *Context

func (*Config) Load

func (c *Config) Load(fileName string) error

func (*Config) SSHTimeout

func (c *Config) SSHTimeout() time.Duration

func (*Config) SetToken

func (c *Config) SetToken(token oauth2.Token) error

func (*Config) SwitchContext

func (c *Config) SwitchContext(newContext string, force bool) error

func (*Config) Validate added in v0.2.10

func (c *Config) Validate() error

type Context

type Context struct {
	Host           string `validate:"required"       yaml:"host"`
	Port           int    `validate:"required"       yaml:"port"`
	User           string `                          yaml:"user"`
	PrivateKeyFile string `validate:"omitempty,file" yaml:"privateKeyFile"`
	KnownHostsFile string `validate:"omitempty,file" yaml:"knownHostsFile"`

	PostConnectCommand []string `yaml:"postConnectCommand,omitempty"`

	GCloud *GCloud `yaml:"gcloud"`

	Dirs  []Dir  `yaml:"dirs,omitempty"`
	Files []File `yaml:"files,omitempty" validate:"dive,required"`
}

func (Context) HostAddr

func (c Context) HostAddr() string

type Dir

type Dir struct {
	Path        string `yaml:"path"`
	Permissions string `yaml:"permissions,omitempty"`
}

type File

type File struct {
	SourcePath  string `validate:"required"                yaml:"sourcePath"`
	Path        string `validate:"required"                yaml:"path"`
	Permissions string `                                   yaml:"permissions"`
	Direction   string `validate:"omitempty,oneof=up down" yaml:"direction"`
}

type FilePatch

type FilePatch struct {
	File     string `yaml:"file"`
	Indent   string `yaml:"indent,omitempty"`
	OldBlock string `yaml:"oldBlock,omitempty"`
	NewBlock string `yaml:"newBlock,omitempty"`
}

type GCloud

type GCloud struct {
	Project string `yaml:"project"`
	Region  string `yaml:"region"`
	Cluster string `yaml:"cluster"`
	Config  string `yaml:"config"`
	Name    string `yaml:"name"`
}

type TokenStorage

type TokenStorage struct {
	Token oauth2.Token `yaml:"token"`
}

Jump to

Keyboard shortcuts

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