formula

package
v0.0.0-...-873fb03 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReposDir           = "repos"
	TmpDir             = "tmp"
	DefaultConfig      = "config.json"
	PwdEnv             = "CURRENT_PWD"
	CtxEnv             = "CONTEXT"
	Env                = "ENVIRONMENT"
	VerboseEnv         = "VERBOSE_MODE"
	DockerExecutionEnv = "DOCKER_EXECUTION"
	BinUnix            = "run.sh"
	BinWindows         = "run.bat"
	BinDir             = "bin"
	EnvPattern         = "%s=%s"
)
View Source
const (
	GoLang            = "Go"
	JavaLang          = "Java"
	NodeLang          = "Node"
	PhpLang           = "Php"
	PythonLang        = "Python"
	ShellLang         = "Shell"
	NameBin           = "{{bin-name}}"
	NameModule        = "{{nameModule}}"
	NameBinFirstUpper = "{{bin-name-first-upper}}"
)
View Source
const (
	RepoCacheTime   = 24 * time.Hour
	RepoCommonsName = RepoName("commons")
)
View Source
const (
	DefaultWorkspaceName = "Default"
	DefaultWorkspaceDir  = "ritchie-formulas-local"
	WorkspacesFile       = "formula_workspaces.json"
)

Variables

View Source
var RunnerTypes = []string{"local", "docker"}

Functions

This section is empty.

Types

type BuildInfo

type BuildInfo struct {
	FormulaPath string
	DockerImg   string
	Workspace   Workspace
}

type Builder

type Builder interface {
	Build(info BuildInfo) error
}

type Cache

type Cache struct {
	Active   bool   `json:"active"`
	Qty      int    `json:"qty"`
	NewLabel string `json:"newLabel"`
}

type Condition

type Condition struct {
	Variable string `json:"variable"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

type Config

type Config struct {
	DockerIB             string   `json:"dockerImageBuilder"`
	Inputs               Inputs   `json:"inputs"`
	Volumes              []string `json:"dockerVolumes"`
	RequireLatestVersion bool     `json:"requireLatestVersion"`
}

type ConfigRunner

type ConfigRunner interface {
	Create(runType RunnerType) error
	Find() (RunnerType, error)
}

type Create

type Create struct {
	FormulaCmd  string    `json:"formulaCmd"`
	Lang        string    `json:"lang"`
	Workspace   Workspace `json:"workspace"`
	FormulaPath string    `json:"formulaPath"`
}

func (Create) FormulaCmdName

func (c Create) FormulaCmdName() string

FormulaName remove rit from formulaCmd

func (Create) PkgName

func (c Create) PkgName() string

type CreateBuilder

type CreateBuilder interface {
	Creator
	Builder
}

func NewCreateBuilder

func NewCreateBuilder(creator Creator, builder Builder) CreateBuilder

type CreateBuilderManager

type CreateBuilderManager struct {
	Creator
	Builder
}

type Creator

type Creator interface {
	Create(cf Create) error
}

type Definition

type Definition struct {
	Path     string
	RepoName string
}

Definition type that represents a Formula

func (*Definition) BinFilePath

func (d *Definition) BinFilePath(fPath string) string

BinFilePath builds the bin file path from formula path

func (*Definition) BinName

func (d *Definition) BinName() string

func (*Definition) BinPath

func (d *Definition) BinPath(fPath string) string

BinFilePath builds the bin file path from formula path

func (*Definition) ConfigPath

func (d *Definition) ConfigPath(formulaPath string) string

ConfigPath builds the config path from formula path and config name

func (*Definition) FormulaPath

func (d *Definition) FormulaPath(home string) string

FormulaPath builds the formula path from ritchie home

func (*Definition) TmpWorkDirPath

func (d *Definition) TmpWorkDirPath(home string) string

TmpWorkDirPath builds the tmp paths to run formula, first parameter is tmpDir created second parameter is tmpBinDir

func (*Definition) UnixBinFilePath

func (d *Definition) UnixBinFilePath(fPath string) string

type Delete

type Delete struct {
	GroupsFormula []string
	Workspace     Workspace
}

type ExecuteData

type ExecuteData struct {
	Def     Definition
	InType  api.TermInputType
	RunType RunnerType
	Verbose bool
	Flags   *pflag.FlagSet
}

type Executor

type Executor interface {
	Execute(exe ExecuteData) error
}

type Git

type Git struct {
	Repos       git.Repositories
	NewRepoInfo func(url string, token string) git.RepoInfo
}

type Help

type Help struct {
	Short string `json:"short"`
	Long  string `json:"long"`
}

type Input

type Input struct {
	Name        string      `json:"name"`
	Type        string      `json:"type"`
	Default     string      `json:"default"`
	Label       string      `json:"label"`
	Items       Items       `json:"items"`
	Cache       Cache       `json:"cache"`
	Condition   Condition   `json:"condition"`
	Pattern     Pattern     `json:"pattern"`
	RequestInfo RequestInfo `json:"requestInfo"`
	Tutorial    string      `json:"tutorial"`
	Required    *bool       `json:"required"`
}

type InputResolver

type InputResolver interface {
	Resolve(inType api.TermInputType) (InputRunner, error)
}

type InputRunner

type InputRunner interface {
	Inputs(cmd *exec.Cmd, setup Setup, flags *pflag.FlagSet) error
}

type Inputs

type Inputs []Input

type Items

type Items []string

func (Items) Contains

func (ii Items) Contains(item string) bool

type Lang

type Lang struct {
	Creator
	FileFormat   string
	StartFile    string
	Main         string
	Makefile     string
	WindowsBuild string
	Run          string
	Dockerfile   string
	PackageJson  string
	File         string
	Pkg          string
	Compiled     bool
	UpperCase    bool
}

type LangCreator

type LangCreator interface {
	Create(srcDir, pkg, pkgDir, dir string) error
}

type Pattern

type Pattern struct {
	Regex        string `json:"regex"`
	MismatchText string `json:"mismatchText"`
}

type PostRunner

type PostRunner interface {
	PostRun(p Setup, docker bool) error
}

type PreRunBuilder

type PreRunBuilder interface {
	Build(string) error
}

type PreRunChecker

type PreRunChecker interface {
	CheckVersionCompliance() error
}

type PreRunner

type PreRunner interface {
	PreRun(def Definition) (Setup, error)
}

type Rename

type Rename struct {
	OldFormulaCmd string
	NewFormulaCmd string
	Workspace     Workspace
	FOldPath      string
	FNewPath      string
}

type Repo

type Repo struct {
	Provider      RepoProvider `json:"provider"`
	Name          RepoName     `json:"name"`
	Version       RepoVersion  `json:"version"`
	Url           string       `json:"url"`
	Token         string       `json:"token,omitempty"`
	Priority      int          `json:"priority"`
	IsLocal       bool         `json:"isLocal"`
	TreeVersion   string       `json:"tree_version"`
	LatestVersion RepoVersion  `json:"latest_version"`
	Cache         time.Time    `json:"cache"`
}

func (Repo) CacheExpired

func (r Repo) CacheExpired() bool

func (Repo) EmptyVersion

func (r Repo) EmptyVersion() bool

func (*Repo) UpdateCache

func (r *Repo) UpdateCache()

type RepoName

type RepoName string

func (RepoName) String

func (r RepoName) String() string

type RepoProvider

type RepoProvider string

func (RepoProvider) String

func (r RepoProvider) String() string

type RepoProviders

type RepoProviders map[RepoProvider]Git

func NewRepoProviders

func NewRepoProviders() RepoProviders

func (RepoProviders) Add

func (re RepoProviders) Add(provider RepoProvider, git Git)

func (RepoProviders) List

func (re RepoProviders) List() []string

func (RepoProviders) Resolve

func (re RepoProviders) Resolve(provider RepoProvider) Git

type RepoVersion

type RepoVersion string

func (RepoVersion) String

func (r RepoVersion) String() string

type Repos

type Repos []Repo

func (Repos) Get

func (r Repos) Get(name string) (Repo, error)

func (Repos) Len

func (r Repos) Len() int

func (Repos) Less

func (r Repos) Less(i, j int) bool

func (Repos) Swap

func (r Repos) Swap(i, j int)

type RepositoryAddLister

type RepositoryAddLister interface {
	RepositoryAdder
	RepositoryLister
}

type RepositoryAdder

type RepositoryAdder interface {
	Add(repo Repo) error
}

type RepositoryCreator

type RepositoryCreator interface {
	Create(repo Repo) error
}

type RepositoryDeleter

type RepositoryDeleter interface {
	Delete(name RepoName) error
}

type RepositoryDetail

type RepositoryDetail interface {
	LatestTag(repo Repo) string
}

type RepositoryListDetailWriter

type RepositoryListDetailWriter interface {
	RepositoryLister
	RepositoryDetail
	RepositoryWriter
}

type RepositoryListUpdater

type RepositoryListUpdater interface {
	RepositoryLister
	RepositoryUpdater
}

type RepositoryListWriter

type RepositoryListWriter interface {
	RepositoryLister
	RepositoryWriter
}

type RepositoryLister

type RepositoryLister interface {
	List() (Repos, error)
}

type RepositoryPrioritySetter

type RepositoryPrioritySetter interface {
	SetPriority(name RepoName, priority int) error
}

type RepositoryUpdater

type RepositoryUpdater interface {
	Update(name RepoName, version RepoVersion) error
}

type RepositoryWriter

type RepositoryWriter interface {
	Write(repos Repos) error
}

type RequestInfo

type RequestInfo struct {
	Url      string `json:"url"`
	JsonPath string `json:"jsonPath"`
}

type Runner

type Runner interface {
	Run(def Definition, inputType api.TermInputType, verbose bool, flags *pflag.FlagSet) error
}

type RunnerType

type RunnerType int
const (
	DefaultRun RunnerType = iota - 1
	LocalRun
	DockerRun
)

func (RunnerType) Int

func (e RunnerType) Int() int

func (RunnerType) String

func (e RunnerType) String() string

type Runners

type Runners map[RunnerType]Runner

type Setup

type Setup struct {
	Pwd         string
	FormulaPath string
	BinName     string
	BinPath     string
	TmpDir      string
	Config      Config
	ContainerId string
}

type TermInputTypes

type TermInputTypes map[api.TermInputType]InputRunner

type Tree

type Tree struct {
	Version    string          `json:"version"`
	Commands   api.Commands    `json:"commands"`
	CommandsID []api.CommandID `json:"-"`
}

type TreeChecker

type TreeChecker interface {
	Check() []api.CommandID
}

type TreeGenerator

type TreeGenerator interface {
	Generate(repoPath string) (Tree, error)
}

type TreeManager

type TreeManager interface {
	Tree() (map[RepoName]Tree, error)
	MergedTree(core bool) Tree
	TreeByRepo(RepoName) (Tree, error)
}

type Workspace

type Workspace struct {
	Name string `json:"name"`
	Dir  string `json:"dir"`
}

type WorkspaceAddListHasher

type WorkspaceAddListHasher interface {
	WorkspaceAdder
	WorkspaceLister
	WorkspaceHasher
}

type WorkspaceAddLister

type WorkspaceAddLister interface {
	WorkspaceAdder
	WorkspaceLister
}

type WorkspaceAdder

type WorkspaceAdder interface {
	Add(workspace Workspace) error
}

type WorkspaceDeleter

type WorkspaceDeleter interface {
	Delete(workspace Workspace) error
}

type WorkspaceHasher

type WorkspaceHasher interface {
	CurrentHash(formulaPath string) (string, error)
	PreviousHash(formulaPath string) (string, error)
	UpdateHash(formulaPath string, hash string) error
}

type WorkspaceListDeleter

type WorkspaceListDeleter interface {
	WorkspaceDeleter
	WorkspaceLister
}

type WorkspaceListHasher

type WorkspaceListHasher interface {
	WorkspaceLister
	WorkspaceHasher
}

type WorkspaceListUpdater

type WorkspaceListUpdater interface {
	WorkspaceLister
	WorkspaceUpdater
}

type WorkspaceLister

type WorkspaceLister interface {
	List() (Workspaces, error)
}

type WorkspaceUpdater

type WorkspaceUpdater interface {
	Update(workspace Workspace) error
}

type Workspaces

type Workspaces map[string]string

Jump to

Keyboard shortcuts

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