specs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2024 Daniele Rondina <geaaru@macaronios.org> See AUTHORS and LICENSE for the license details and contributors.

Index

Constants

View Source
const (
	SSH_COMPOSE_CONFIGNAME = ".ssh-compose"
	SSH_COMPOSE_ENV_PREFIX = "ssh_COMPOSE"
	SSH_COMPOSE_VERSION    = `0.5.0`
)
View Source
const (
	HookPreProject   = "pre-project"
	HookPreGroup     = "pre-group"
	HookPreNodeSync  = "pre-node-sync"
	HookPostNodeSync = "post-node-sync"
	HookPostGroup    = "post-group"
	HookPostProject  = "post-project"
)
View Source
const (
	AuthMethodPassword  = "password"
	AuthMethodPublickey = "publickey"
)

Variables

This section is empty.

Functions

func GenDefault

func GenDefault(viper *v.Viper)

func GetSshCRemotesDefaultConfDir

func GetSshCRemotesDefaultConfDir() (string, error)

Types

type Remote

type Remote struct {
	Host     string `json:"host,omitempty" yaml:"host,omitempty"`
	Port     int    `json:"port,omitempty" yaml:"port,omitempty"`
	Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"`
	// See RFC4252. Values: publickey|password
	AuthMethod     string `json:"auth_type,omitempty" yaml:"auth_type,omitempty"`
	PrivateKeyFile string `json:"privatekey_file,omitempty" yaml:"privatekey_file,omitempty"`
	PrivateKeyPass string `json:"privatekey_pass,omitempty" yaml:"privatekey_pass,omitempty"`
	PrivateKeyRaw  string `json:"privatekey_raw,omitempty" yaml:"privatekey_raw,omitempty"`
	User           string `json:"user,omitempty" yaml:"user,omitempty"`
	Pass           string `json:"pass,omitempty" yaml:"pass,omitempty"`
}

func NewRemote

func NewRemote(host, protocol, authMethod string, port int) *Remote

func (*Remote) GetAuthMethod

func (r *Remote) GetAuthMethod() string

func (*Remote) GetHost

func (r *Remote) GetHost() string

func (*Remote) GetPass

func (r *Remote) GetPass() string

func (*Remote) GetPort

func (r *Remote) GetPort() int

func (*Remote) GetPrivateKeyFile

func (r *Remote) GetPrivateKeyFile() string

func (*Remote) GetPrivateKeyPass

func (r *Remote) GetPrivateKeyPass() string

func (*Remote) GetPrivateKeyRaw

func (r *Remote) GetPrivateKeyRaw() string

func (*Remote) GetProtocol

func (r *Remote) GetProtocol() string

func (*Remote) GetUser

func (r *Remote) GetUser() string

func (*Remote) SetPass

func (r *Remote) SetPass(p string)

func (*Remote) SetPrivateKeyFile

func (r *Remote) SetPrivateKeyFile(f string)

func (*Remote) SetPrivateKeyPass

func (r *Remote) SetPrivateKeyPass(p string)

func (*Remote) SetPrivateKeyRaw

func (r *Remote) SetPrivateKeyRaw(p string)

func (*Remote) SetUser

func (r *Remote) SetUser(u string)

type RemotesConfig

type RemotesConfig struct {
	File          string             `json:"-" yaml:"-"`
	DefaultRemote string             `json:"default-remote,omitempty" yaml:"default-remote,omitempty"`
	Remotes       map[string]*Remote `json:"remotes,omitempty" yaml:"remotes,omitempty"`
}

func LoadRemotesConfig

func LoadRemotesConfig(remotesconfdir string) (*RemotesConfig, error)

func NewRemotesConfig

func NewRemotesConfig() *RemotesConfig

func RemotesConfigFromFile

func RemotesConfigFromFile(file string) (*RemotesConfig, error)

func RemotesConfigFromYaml

func RemotesConfigFromYaml(data []byte, file string) (*RemotesConfig, error)

func (*RemotesConfig) AddRemote

func (rc *RemotesConfig) AddRemote(name string, r *Remote)

func (*RemotesConfig) DelRemote

func (rc *RemotesConfig) DelRemote(name string)

func (*RemotesConfig) GetAbsConfigDir

func (rc *RemotesConfig) GetAbsConfigDir() (string, error)

func (*RemotesConfig) GetDefault

func (rc *RemotesConfig) GetDefault() string

func (*RemotesConfig) GetRemote

func (rc *RemotesConfig) GetRemote(remote string) *Remote

func (*RemotesConfig) HasRemote

func (rc *RemotesConfig) HasRemote(remote string) bool

func (*RemotesConfig) Sanitize

func (rc *RemotesConfig) Sanitize()

func (*RemotesConfig) SetDefault

func (rc *RemotesConfig) SetDefault(remote string)

func (*RemotesConfig) Write

func (rc *RemotesConfig) Write() error

type SshCCommand

type SshCCommand struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description" yaml:"description"`
	Project     string `json:"project" yaml:"project"`
	ApplyAlias  bool   `json:"apply_alias,omitempty" yaml:"apply_alias,omitempty"`

	SkipSync bool `json:"skip_sync,omitempty" yaml:"skip_sync,omitempty"`
	Destroy  bool `json:"destroy,omitempty" yaml:"destroy,omitempty"`

	EnableFlags  []string `json:"enable_flags,omitempty" yaml:"enable_flags,omitempty"`
	DisableFlags []string `json:"disable_flags,omitempty" yaml:"disable_flags,omitempty"`

	EnableGroups  []string `json:"enable_groups,omitempty" yaml:"enable_groups,omitempty"`
	DisableGroups []string `json:"disable_groups,omitempty" yaml:"disable_groups,omitempty"`

	Envs     SshCEnvVars `json:"envs,omitempty" yaml:"envs,omitempty"`
	VarFiles []string    `json:"vars_files,omitempty" yaml:"vars_files,omitempty"`

	IncludeHooksFiles []string `json:"include_hooks_files,omitempty" yaml:"include_hooks_files,omitempty"`
}

func CommandFromFile

func CommandFromFile(file string) (*SshCCommand, error)

func CommandFromYaml

func CommandFromYaml(data []byte) (*SshCCommand, error)

func (*SshCCommand) GetDescription

func (c *SshCCommand) GetDescription() string

func (*SshCCommand) GetDestroy

func (c *SshCCommand) GetDestroy() bool

func (*SshCCommand) GetDisableFlags

func (c *SshCCommand) GetDisableFlags() []string

func (*SshCCommand) GetDisableGroups

func (c *SshCCommand) GetDisableGroups() []string

func (*SshCCommand) GetEnableFlags

func (c *SshCCommand) GetEnableFlags() []string

func (*SshCCommand) GetEnableGroups

func (c *SshCCommand) GetEnableGroups() []string

func (*SshCCommand) GetEnvs

func (c *SshCCommand) GetEnvs() SshCEnvVars

func (*SshCCommand) GetName

func (c *SshCCommand) GetName() string

func (*SshCCommand) GetProject

func (c *SshCCommand) GetProject() string

func (*SshCCommand) GetSkipSync

func (c *SshCCommand) GetSkipSync() bool

func (*SshCCommand) GetVarFiles

func (c *SshCCommand) GetVarFiles() []string

type SshCConfigTemplate

type SshCConfigTemplate struct {
	Source      string `json:"source" yaml:"source"`
	Destination string `json:"dst" yaml:"dst"`
}

type SshCEnvVars

type SshCEnvVars struct {
	EnvVars map[string]interface{} `json:"envs,omitempty" yaml:"envs,omitempty"`
}

func EnvVarsFromYaml

func EnvVarsFromYaml(data []byte) (*SshCEnvVars, error)

func NewEnvVars

func NewEnvVars() *SshCEnvVars

func (*SshCEnvVars) AddKV

func (e *SshCEnvVars) AddKV(key, value string) error

func (*SshCEnvVars) AddKVAggregated

func (e *SshCEnvVars) AddKVAggregated(aggregatedEnv string) error

type SshCEnvironment

type SshCEnvironment struct {
	Version string `json:"version,omitempty" yaml:"version,omitempty"`
	File    string `json:"-" yaml:"-"`

	TemplateEngine SshCTemplateEngine `json:"template_engine,omitempty" yaml:"template_engine,omitempty"`

	Projects []SshCProject `json:"projects" yaml:"projects"`

	Commands             []SshCCommand `json:"commands,omitempty" yaml:"commands,omitempty"`
	IncludeCommandsFiles []string      `json:"include_commands_files,omitempty" yaml:"include_commands_files,omitempty"`

	PackExtra *SshCPackExtra `json:"pack_extra,omitempty" yaml:"pack_extra,omitempty"`
}

func EnvironmentFromYaml

func EnvironmentFromYaml(data []byte, file string) (*SshCEnvironment, error)

func (*SshCEnvironment) AddCommand

func (e *SshCEnvironment) AddCommand(cmd *SshCCommand)

func (*SshCEnvironment) GetBaseFile

func (e *SshCEnvironment) GetBaseFile() string

func (*SshCEnvironment) GetCommand

func (e *SshCEnvironment) GetCommand(name string) (*SshCCommand, error)

func (*SshCEnvironment) GetCommands

func (e *SshCEnvironment) GetCommands() *[]SshCCommand

func (*SshCEnvironment) GetProjectByName

func (e *SshCEnvironment) GetProjectByName(pName string) *SshCProject

func (*SshCEnvironment) GetProjects

func (e *SshCEnvironment) GetProjects() *[]SshCProject

type SshCGeneral

type SshCGeneral struct {
	Debug            bool   `mapstructure:"debug,omitempty" json:"debug,omitempty" yaml:"debug,omitempty"`
	RemotesConfDir   string `mapstructure:"remotes_confdir,omitempty" json:"remotes_confdir,omitempty" yaml:"remotes_confdir,omitempty"`
	EnvSessionPrefix string `mapstructure:"env_session_prefix,omitempty" json:"env_session_prefix,omitempty" yaml:"env_session_prefix,omitempty"`
}

func (*SshCGeneral) HasDebug

func (g *SshCGeneral) HasDebug() bool

type SshCGroup

type SshCGroup struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Connection  string `json:"connection,omitempty" yaml:"connection,omitempty"`

	CommonProfiles []string          `json:"common_profiles,omitempty" yaml:"common_profiles,omitempty"`
	Config         map[string]string `json:"config,omitempty" yaml:"config,omitempty"`

	Ephemeral bool `json:"ephemeral,omitempty" yaml:"ephemeral,omitempty"`

	Nodes []SshCNode `json:"nodes" yaml:"nodes"`

	Hooks             []SshCHook           `json:"hooks" yaml:"hooks"`
	IncludeHooksFiles []string             `json:"include_hooks_files,omitempty" yaml:"include_hooks_files,omitempty"`
	ConfigTemplates   []SshCConfigTemplate `json:"config_templates,omitempty" yaml:"config_templates,omitempty"`
}

func GroupFromYaml

func GroupFromYaml(data []byte) (*SshCGroup, error)

func (*SshCGroup) AddHooks

func (g *SshCGroup) AddHooks(h *SshCHooks)

func (*SshCGroup) GetConnection

func (g *SshCGroup) GetConnection() string

func (*SshCGroup) GetDescription

func (g *SshCGroup) GetDescription() string

func (*SshCGroup) GetHooks

func (g *SshCGroup) GetHooks(event string) []SshCHook

func (*SshCGroup) GetHooks4Nodes

func (g *SshCGroup) GetHooks4Nodes(event string, nodes []string) []SshCHook

func (*SshCGroup) GetName

func (g *SshCGroup) GetName() string

func (*SshCGroup) GetNodes

func (g *SshCGroup) GetNodes() *[]SshCNode

func (*SshCGroup) Init

func (g *SshCGroup) Init()

func (*SshCGroup) ToProcess

func (g *SshCGroup) ToProcess(groupsEnabled, groupsDisabled []string) bool

type SshCHook

type SshCHook struct {
	Event      string   `json:"event" yaml:"event"`
	Node       string   `json:"node" yaml:"node"`
	Commands   []string `json:"commands,omitempty" yaml:"commands,omitempty"`
	Out2Var    string   `json:"out2var,omitempty" yaml:"out2var,omitempty"`
	Err2Var    string   `json:"err2var,omitempty" yaml:"err2var,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`
	Flags      []string `json:"flags,omitempty" yaml:"flags,omitempty"`
	Disable    bool     `json:"disable,omitempty" yaml:"disable,omitempty"`

	// Pull resources
	PullResources      []*SshCSyncResource `json:"pull,omitempty" yaml:"pull,omitempty"`
	PullKeepSourcePath bool                `json:"pull_keep_sourcepath,omitempty" yaml:"pull_keep_sourcepath,omitempty"`
}

func FilterHooks4Node

func FilterHooks4Node(hooks *[]SshCHook, nodes []string) []SshCHook

func (*SshCHook) Clone

func (h *SshCHook) Clone() *SshCHook

func (*SshCHook) ContainsFlag

func (h *SshCHook) ContainsFlag(flag string) bool

func (*SshCHook) For

func (h *SshCHook) For(node string) bool

func (*SshCHook) HasPullResources

func (h *SshCHook) HasPullResources() bool

func (*SshCHook) SetNode

func (h *SshCHook) SetNode(node string)

func (*SshCHook) ToProcess

func (h *SshCHook) ToProcess(enabledFlags, disabledFlags []string) bool

type SshCHooks

type SshCHooks struct {
	Hooks []SshCHook `json:"hooks,omitempty" yaml:"hooks,omitempty"`
}

func HooksFromYaml

func HooksFromYaml(data []byte) (*SshCHooks, error)

type SshCLogging

type SshCLogging struct {
	// Path of the logfile
	Path string `mapstructure:"path,omitempty" json:"path,omitempty" yaml:"path,omitempty"`
	// Enable/Disable logging to file
	EnableLogFile bool `mapstructure:"enable_logfile,omitempty" json:"enable_logfile,omitempty" yaml:"enable_logfile,omitempty"`
	// Enable JSON format logging in file
	JsonFormat bool `mapstructure:"json_format,omitempty" json:"json_format,omitempty" yaml:"json_format,omitempty"`

	// Log level
	Level string `mapstructure:"level,omitempty" json:"level,omitempty" yaml:"level,omitempty"`

	// Enable emoji
	EnableEmoji bool `mapstructure:"enable_emoji,omitempty" json:"enable_emoji,omitempty" yaml:"enable_emoji,omitempty"`
	// Enable/Disable color in logging
	Color bool `mapstructure:"color,omitempty" json:"color,omitempty" yaml:"color,omitempty"`

	// Enable/Disable commands output logging
	RuntimeCmdsOutput bool `mapstructure:"runtime_cmds_output,omitempty" json:"runtime_cmds_output,omitempty" yaml:"runtime_cmds_output,omitempty"`
	CmdsOutput        bool `mapstructure:"cmds_output,omitempty" json:"cmds_output,omitempty" yaml:"cmds_output,omitempty"`
}

type SshCNode

type SshCNode struct {
	Name string `json:"name" yaml:"name"`

	Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`

	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Config map[string]string `json:"config,omitempty" yaml:"config,omitempty"`

	SourceDir string `json:"source_dir,omitempty" yaml:"source_dir,omitempty"`

	Entrypoint []string `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`

	ConfigTemplates []SshCConfigTemplate `json:"config_templates,omitempty" yaml:"config_templates,omitempty"`
	SyncResources   []SshCSyncResource   `json:"sync_resources,omitempty" yaml:"sync_resources,omitempty"`

	Hooks             []SshCHook `json:"hooks" yaml:"hooks"`
	IncludeHooksFiles []string   `json:"include_hooks_files,omitempty" yaml:"include_hooks_files,omitempty"`
}

func (*SshCNode) AddHooks

func (n *SshCNode) AddHooks(h *SshCHooks)

func (*SshCNode) GetAllHooks

func (n *SshCNode) GetAllHooks(event string) []SshCHook

func (*SshCNode) GetHooks

func (n *SshCNode) GetHooks(event string) []SshCHook

func (*SshCNode) GetName

func (n *SshCNode) GetName() string

func (*SshCNode) Init

func (n *SshCNode) Init()

func (*SshCNode) IsSourcePathRelative

func (n *SshCNode) IsSourcePathRelative() bool

func (*SshCNode) ToJson

func (n *SshCNode) ToJson() (string, error)

type SshCPackExtra

type SshCPackExtra struct {
	Dirs   []string                 `json:"dirs,omitempty" yaml:"dirs,omitempty"`
	Files  []string                 `json:"files,omitempty" yaml:"files,omitempty"`
	Rename []*tarf_specs.RenameRule `json:"rename,omitempty" yaml:"rename,omitempty"`
}

type SshCProject

type SshCProject struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	IncludeGroupFiles []string `json:"include_groups_files,omitempty" yaml:"include_groups_files,omitempty"`
	IncludeEnvFiles   []string `json:"include_env_files,omitempty" yaml:"include_env_files,omitempty"`
	IncludeHooksFiles []string `json:"include_hooks_files,omitempty" yaml:"include_hooks_files,omitempty"`

	Environments []SshCEnvVars `json:"vars,omitempty" yaml:"vars,omitempty"`

	Groups []SshCGroup `json:"groups" yaml:"groups"`

	Hooks           []SshCHook           `json:"hooks" yaml:"hooks"`
	ConfigTemplates []SshCConfigTemplate `json:"config_templates,omitempty" yaml:"config_templates,omitempty"`
}

func (*SshCProject) AddEnvironment

func (p *SshCProject) AddEnvironment(e *SshCEnvVars)

func (*SshCProject) AddGroup

func (p *SshCProject) AddGroup(grp *SshCGroup)

func (*SshCProject) AddHooks

func (p *SshCProject) AddHooks(h *SshCHooks)

func (*SshCProject) GetDescription

func (p *SshCProject) GetDescription() string

func (*SshCProject) GetEnvsMap

func (p *SshCProject) GetEnvsMap() (map[string]string, error)

func (*SshCProject) GetGroupByName

func (p *SshCProject) GetGroupByName(name string) *SshCGroup

func (*SshCProject) GetGroups

func (p *SshCProject) GetGroups() *[]SshCGroup

func (*SshCProject) GetHooks

func (p *SshCProject) GetHooks(event string) []SshCHook

func (*SshCProject) GetHooks4Nodes

func (p *SshCProject) GetHooks4Nodes(event string, nodes []string) []SshCHook

func (*SshCProject) GetName

func (p *SshCProject) GetName() string

func (*SshCProject) Init

func (p *SshCProject) Init()

func (*SshCProject) LoadEnvVarsFile

func (p *SshCProject) LoadEnvVarsFile(file string) error

func (*SshCProject) Sanitize

func (p *SshCProject) Sanitize() *SshCProjectSanitized

type SshCProjectSanitized

type SshCProjectSanitized struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	IncludeGroupFiles []string `json:"include_groups_files,omitempty" yaml:"include_groups_files,omitempty"`
	IncludeEnvFiles   []string `json:"include_env_files,omitempty" yaml:"include_env_files,omitempty"`
	IncludeHooksFiles []string `json:"include_hooks_files,omitempty" yaml:"include_hooks_files,omitempty"`

	Groups []SshCGroup `json:"groups" yaml:"groups"`

	Hooks           []SshCHook           `json:"hooks" yaml:"hooks"`
	ConfigTemplates []SshCConfigTemplate `json:"config_templates,omitempty" yaml:"config_templates,omitempty"`
}

func (*SshCProjectSanitized) GetDescription

func (p *SshCProjectSanitized) GetDescription() string

func (*SshCProjectSanitized) GetGroups

func (p *SshCProjectSanitized) GetGroups() *[]SshCGroup

func (*SshCProjectSanitized) GetName

func (p *SshCProjectSanitized) GetName() string

type SshCSyncResource

type SshCSyncResource struct {
	Source      string `json:"source" yaml:"source"`
	Destination string `json:"dst" yaml:"dst"`
}

type SshCTemplateEngine

type SshCTemplateEngine struct {
	Engine string   `json:"engine" yaml:"engine"`
	Opts   []string `json:"opts,omitempty" yaml:"opts,omitempty"`
}

type SshComposeConfig

type SshComposeConfig struct {
	Viper *v.Viper `yaml:"-" json:"-"`

	General         SshCGeneral `mapstructure:"general" json:"general,omitempty" yaml:"general,omitempty"`
	Logging         SshCLogging `mapstructure:"logging" json:"logging,omitempty" yaml:"logging,omitempty"`
	EnvironmentDirs []string    `mapstructure:"env_dirs,omitempty" json:"env_dirs,omitempty" yaml:"env_dirs,omitempty"`

	RenderDefaultFile   string                 `mapstructure:"render_default_file,omitempty" json:"render_default_file,omitempty" yaml:"render_default_file,omitempty"`
	RenderValuesFile    string                 `mapstructure:"render_values_file,omitempty" json:"render_values_file,omitempty" yaml:"render_values_file,omitempty"`
	RenderEnvsVars      map[string]interface{} `mapstructure:"-" json:"-" yaml:"-"`
	RenderTemplatesDirs []string               `mapstructure:"render_templates_dirs,omitempty" json:"render_templates_dirs,omitempty" yaml:"render_templates_dirs,omitempty"`
}

func NewSshComposeConfig

func NewSshComposeConfig(viper *v.Viper) *SshComposeConfig

func (*SshComposeConfig) Clone

func (c *SshComposeConfig) Clone() *SshComposeConfig

func (*SshComposeConfig) GetEnvironmentDirs

func (c *SshComposeConfig) GetEnvironmentDirs() []string

func (*SshComposeConfig) GetGeneral

func (c *SshComposeConfig) GetGeneral() *SshCGeneral

func (*SshComposeConfig) GetLogging

func (c *SshComposeConfig) GetLogging() *SshCLogging

func (*SshComposeConfig) IsEnableRenderEngine

func (c *SshComposeConfig) IsEnableRenderEngine() bool

func (*SshComposeConfig) SetRenderEnvs

func (c *SshComposeConfig) SetRenderEnvs(envs []string) error

func (*SshComposeConfig) Unmarshal

func (c *SshComposeConfig) Unmarshal() error

func (*SshComposeConfig) Yaml

func (c *SshComposeConfig) Yaml() ([]byte, error)

Jump to

Keyboard shortcuts

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