config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPermission = errors.New("permission denied")
)

const errors

Functions

func CreateDirIfNotExist added in v0.2.1

func CreateDirIfNotExist(path string) error

func HasGitHubReleaseBlock

func HasGitHubReleaseBlock(pkgs []Package) bool

HasGitHubReleaseBlock returns true if release block is included in one package at least

func HasSudoInCommandBuildSteps

func HasSudoInCommandBuildSteps(pkgs []Package) bool

HasSudoInCommandBuildSteps returns true if sudo command is included in one build step of given package at least

func Validate

func Validate(pkgs []Package) error

Validate validates if packages are not violated some rules

func ValidateGHExtension added in v0.2.0

func ValidateGHExtension(fl validator.FieldLevel) bool

func WalkDir

func WalkDir(path string) ([]string, error)

WalkDir walks given directory path and returns full-path of all yaml files

Types

type Build

type Build struct {
	Steps     []string          `yaml:"steps" validate:"required"`
	Env       map[string]string `yaml:"env"`
	Directory string            `yaml:"directory"`
}

Build is

type Command

type Command struct {
	Build   *Build            `yaml:"build"`
	Link    []*Link           `yaml:"link" validate:"required"`
	Env     map[string]string `yaml:"env"`
	Alias   map[string]string `yaml:"alias"`
	Snippet string            `yaml:"snippet"`
	If      string            `yaml:"if"`
}

Command is

func (c Command) GetLink(pkg Package) ([]Link, error)

GetLink is

func (Command) Init

func (c Command) Init(pkg Package) error

Init returns necessary things which should be loaded when executing commands

func (Command) Install

func (c Command) Install(pkg Package) error

Install is

func (Command) Installed

func (c Command) Installed(pkg Package) bool

Installed returns true ...

func (c Command) Unlink(pkg Package) error

type Config

type Config struct {
	GitHub []*GitHub `yaml:"github,omitempty"`
	Gist   []*Gist   `yaml:"gist,omitempty"`
	Local  []*Local  `yaml:"local,omitempty"`
	HTTP   []*HTTP   `yaml:"http,omitempty"`

	Main *Main `yaml:"main,omitempty"`
}

Config structure for file describing deployment. This includes the module source, inputs dependencies, backend etc. One config element is connected to a single deployment

func Read

func Read(path string) (Config, error)

Read reads yaml file based on given path

func (Config) Contains added in v0.1.14

func (c Config) Contains(args ...string) Config

func (Config) Get added in v0.1.14

func (c Config) Get(args ...string) Config

func (Config) Parse

func (c Config) Parse() ([]Package, error)

Parse parses a config given via yaml files and converts it into package interface

type GHExtension added in v0.2.0

type GHExtension struct {
	Name     string `yaml:"name" validate:"required,startswith=gh-"`
	Tag      string `yaml:"tag"`
	RenameTo string `yaml:"rename-to" validate:"startswith-gh-if-not-empty,excludesall=/"`
}

func (GHExtension) GetHome added in v0.2.0

func (gh GHExtension) GetHome() string

func (GHExtension) GetTag added in v0.2.0

func (gh GHExtension) GetTag() string

func (GHExtension) Install added in v0.2.0

func (gh GHExtension) Install(ctx context.Context, owner, repo, tag string) error

func (GHExtension) InstallFromRelease added in v0.2.0

func (gh GHExtension) InstallFromRelease(ctx context.Context, owner, repo, tag string) error

type Gist

type Gist struct {
	Name string `yaml:"name" validate:"required"`

	Owner       string `yaml:"owner" validate:"required"`
	ID          string `yaml:"id" validate:"required"`
	Description string `yaml:"description"`

	Plugin  *Plugin  `yaml:"plugin"`
	Command *Command `yaml:"command"`

	DependsOn []string `yaml:"depends-on"`
}

Gist represents

func (Gist) Check added in v0.1.18

func (c Gist) Check(ctx context.Context, status chan<- Status) error

func (Gist) GetCommandBlock

func (c Gist) GetCommandBlock() Command

GetCommandBlock is

func (Gist) GetDependsOn

func (c Gist) GetDependsOn() []string

func (Gist) GetHome

func (c Gist) GetHome() string

GetHome returns a path

func (Gist) GetName

func (c Gist) GetName() string

GetName returns a name

func (Gist) GetPluginBlock

func (c Gist) GetPluginBlock() Plugin

GetPluginBlock is

func (Gist) GetResource

func (c Gist) GetResource() state.Resource

func (Gist) HasCommandBlock

func (c Gist) HasCommandBlock() bool

HasCommandBlock is

func (Gist) HasPluginBlock

func (c Gist) HasPluginBlock() bool

HasPluginBlock is

func (Gist) Init

func (c Gist) Init() error

Init is

func (Gist) Install

func (c Gist) Install(ctx context.Context, status chan<- Status) error

Install is

func (Gist) Installed

func (c Gist) Installed() bool

Installed is

func (Gist) Uninstall

func (c Gist) Uninstall(ctx context.Context) error

Uninstall is

type GitHub

type GitHub struct {
	Name string `yaml:"name" validate:"required"`

	Owner       string `yaml:"owner"       validate:"required"`
	Repo        string `yaml:"repo"        validate:"required"`
	Description string `yaml:"description"`

	Branch string        `yaml:"branch"`
	Option *GitHubOption `yaml:"with"`

	Release *GitHubRelease `yaml:"release"`

	Plugin  *Plugin   `yaml:"plugin"`
	Command *Command  `yaml:"command" validate:"required_with=Release"` // TODO: (not required Release)
	As      *GitHubAs `yaml:"as"`

	DependsOn []string `yaml:"depends-on"`
}

GitHub represents GitHub repository

func (GitHub) Check added in v0.1.18

func (c GitHub) Check(ctx context.Context, status chan<- Status) error

func (GitHub) Clone

func (c GitHub) Clone(ctx context.Context) error

Clone runs git clone

func (GitHub) GetCommandBlock

func (c GitHub) GetCommandBlock() Command

func (GitHub) GetDependsOn

func (c GitHub) GetDependsOn() []string

func (GitHub) GetHome

func (c GitHub) GetHome() string

GetHome returns a path

func (GitHub) GetName

func (c GitHub) GetName() string

GetName returns a name

func (GitHub) GetPluginBlock

func (c GitHub) GetPluginBlock() Plugin

func (GitHub) GetReleaseTag added in v0.2.0

func (c GitHub) GetReleaseTag() string

func (GitHub) GetResource

func (c GitHub) GetResource() state.Resource

func (GitHub) HasCommandBlock

func (c GitHub) HasCommandBlock() bool

func (GitHub) HasPluginBlock

func (c GitHub) HasPluginBlock() bool

func (GitHub) HasReleaseBlock

func (c GitHub) HasReleaseBlock() bool

func (GitHub) Init

func (c GitHub) Init() error

Init runs initialization step related to GitHub packages

func (GitHub) Install

func (c GitHub) Install(ctx context.Context, status chan<- Status) error

Install installs from GitHub repository with git clone command

func (GitHub) InstallFromRelease

func (c GitHub) InstallFromRelease(ctx context.Context) error

InstallFromRelease runs install from GitHub release, from not repository

func (GitHub) Installed

func (c GitHub) Installed() bool

Installed returns true the GitHub package is already installed

func (GitHub) IsGHExtension added in v0.2.0

func (c GitHub) IsGHExtension() bool

func (GitHub) Uninstall

func (c GitHub) Uninstall(ctx context.Context) error

type GitHubAs added in v0.2.0

type GitHubAs struct {
	GHExtension *GHExtension `yaml:"gh-extension"`
}

type GitHubOption

type GitHubOption struct {
	Depth int `yaml:"depth"`
}

type GitHubRelease

type GitHubRelease struct {
	Name string `yaml:"name" validate:"required"`
	Tag  string `yaml:"tag"`

	Asset GitHubReleaseAsset `yaml:"asset"`
}

GitHubRelease represents a GitHub release structure

type GitHubReleaseAsset added in v0.1.14

type GitHubReleaseAsset struct {
	Filename     string            `yaml:"filename"`
	Replacements map[string]string `yaml:"replacements"`
}

type HTTP

type HTTP struct {
	Name string `yaml:"name" validate:"required"`

	URL         string `yaml:"url" validate:"required,url"`
	Description string `yaml:"description"`

	Plugin  *Plugin  `yaml:"plugin"`
	Command *Command `yaml:"command"`

	DependsOn []string  `yaml:"depends-on"`
	Templates Templates `yaml:"templates"`
}

HTTP represents

func (HTTP) Check added in v0.1.18

func (c HTTP) Check(ctx context.Context, status chan<- Status) error

func (HTTP) GetCommandBlock

func (c HTTP) GetCommandBlock() Command

GetCommandBlock is

func (HTTP) GetDependsOn

func (c HTTP) GetDependsOn() []string

func (HTTP) GetHome

func (c HTTP) GetHome() string

GetHome returns a path

func (HTTP) GetName

func (c HTTP) GetName() string

GetName returns a name

func (HTTP) GetPluginBlock

func (c HTTP) GetPluginBlock() Plugin

GetPluginBlock is

func (HTTP) GetResource

func (c HTTP) GetResource() state.Resource

func (HTTP) HasCommandBlock

func (c HTTP) HasCommandBlock() bool

HasCommandBlock is

func (HTTP) HasPluginBlock

func (c HTTP) HasPluginBlock() bool

HasPluginBlock is

func (HTTP) Init

func (c HTTP) Init() error

Init is

func (HTTP) Install

func (c HTTP) Install(ctx context.Context, status chan<- Status) error

Install is

func (HTTP) Installed

func (c HTTP) Installed() bool

Installed is

func (*HTTP) ParseURL added in v0.1.17

func (c *HTTP) ParseURL()

func (HTTP) Uninstall

func (c HTTP) Uninstall(ctx context.Context) error

Uninstall is

type Handler

type Handler interface {
	GetHome() string
	GetName() string

	HasPluginBlock() bool
	HasCommandBlock() bool
	GetPluginBlock() Plugin
	GetCommandBlock() Command

	GetDependsOn() []string
	GetResource() state.Resource
}

Handler is an interface of package handler

type Installer

type Installer interface {
	Install(context.Context, chan<- Status) error
	Uninstall(context.Context) error
	Installed() bool
	Check(context.Context, chan<- Status) error
}

Installer is an interface related to installation of a package

type Link struct {
	From string `yaml:"from" validate:"required"`
	To   string `yaml:"to"`
}

Link is

func (*Link) UnmarshalYAML

func (l *Link) UnmarshalYAML(b []byte) error

type Loader

type Loader interface {
	Init() error
}

Loader is an interface related to initialize a package

type Local

type Local struct {
	Name string `yaml:"name" validate:"required"`

	Directory   string `yaml:"directory" validate:"required"`
	Description string `yaml:"description"`

	Plugin  *Plugin  `yaml:"plugin"`
	Command *Command `yaml:"command"`

	DependsOn []string `yaml:"depends-on"`
}

Local represents

func (Local) Check added in v0.1.18

func (c Local) Check(ctx context.Context, status chan<- Status) error

func (Local) GetCommandBlock

func (c Local) GetCommandBlock() Command

GetCommandBlock is

func (Local) GetDependsOn

func (c Local) GetDependsOn() []string

func (Local) GetHome

func (c Local) GetHome() string

GetHome returns a path

func (Local) GetName

func (c Local) GetName() string

GetName returns a name

func (Local) GetPluginBlock

func (c Local) GetPluginBlock() Plugin

GetPluginBlock is

func (Local) GetResource

func (c Local) GetResource() state.Resource

func (Local) HasCommandBlock

func (c Local) HasCommandBlock() bool

HasCommandBlock is

func (Local) HasPluginBlock

func (c Local) HasPluginBlock() bool

HasPluginBlock is

func (Local) Init

func (c Local) Init() error

Init is

func (Local) Install

func (c Local) Install(ctx context.Context, status chan<- Status) error

Install is

func (Local) Installed

func (c Local) Installed() bool

Installed is

func (Local) Uninstall

func (c Local) Uninstall(ctx context.Context) error

Uninstall is

type Main added in v0.1.15

type Main struct {
	Shell     string            `yaml:"shell"`
	FilterCmd string            `yaml:"filter_command"`
	Env       map[string]string `yaml:"env"`
}

Main represents configurations of this application itself

var DefaultMain Main = Main{
	Shell:     "bash",
	FilterCmd: "fzf --ansi --no-preview --height=50% --reverse",
	Env:       map[string]string{},
}

DefaultMain is default settings of Main Basically this will be overridden by user config if given

type Package

type Package interface {
	Loader
	Handler
	Installer
}

Package is an interface related to package itself

func Sort

func Sort(given []Package) ([]Package, error)

type Plugin

type Plugin struct {
	Sources        []string          `yaml:"sources" validate:"required"`
	Env            map[string]string `yaml:"env"`
	Snippet        string            `yaml:"snippet"`
	SnippetPrepare string            `yaml:"snippet-prepare"`
	If             string            `yaml:"if"`
}

Plugin is

func (Plugin) GetSources

func (p Plugin) GetSources(pkg Package) []string

func (Plugin) Init

func (p Plugin) Init(pkg Package) error

Init returns the file list which should be loaded as shell plugins

func (Plugin) Install

func (p Plugin) Install(pkg Package) error

Install runs nothing on plugin installation

func (Plugin) Installed

func (p Plugin) Installed(pkg Package) bool

Installed returns true if sources exist at least one or more

func (*Plugin) UnmarshalYAML added in v0.1.16

func (p *Plugin) UnmarshalYAML(b []byte) error

type Progress

type Progress struct {
	Status map[string]Status
}

func NewProgress

func NewProgress(pkgs []Package) Progress

func (Progress) Print

func (p Progress) Print(completion chan Status)

type Status

type Status struct {
	Name    string
	Done    bool
	Err     bool
	Message string
	NoColor bool
}

type Templates added in v0.1.14

type Templates struct {
	Replacements map[string]string `yaml:"replacements"`
}

Jump to

Keyboard shortcuts

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