project

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyProjectName     = "PROJECT_NAME"
	EnvKeyProjectVersion  = "PROJECT_VERSION"
	EnvKeyProjectOwner    = "PROJECT_OWNER"
	EnvKeyProjectGroup    = "PROJECT_GROUP"
	EnvKeyProjectFeature  = "PROJECT_FEATURE"
	EnvKeyProjectSelector = "PROJECT_SELECTOR"

	EnvKeyCICommitSHA   = "DRONE_COMMIT_SHA"
	EnvKeyCIBranch      = "DRONE_BRANCH"
	EnvKeyDeploymentUID = "DEPLOYMENT_UID"

	EnvKeyDockerRegistryKey = "PROFZONE_DOCKER_REGISTRY"
)
View Source
const (
	STAGE_TEST   = "test"
	STAGE_BUILD  = "build"
	STAGE_SHIP   = "ship"
	STAGE_DEPLOY = "deploy"
)

Variables

View Source
var (
	DefaultConfigFile = "project.yml"
	DockerRegistry    string
)
View Source
var DefaultCICache = CICache{
	Key:       "${CI_BUILD_REF}_${CI_BUILD_REF_NAME}",
	UnTracked: true,
}
View Source
var DockerfileYmlOrders = []string{
	"build/dockerfile.default.yml",
	"build/dockerfile.yml",
}
View Source
var InvalidShippingProcessorType = errors.New("invalid ShippingProcessorType")
View Source
var PresetWorkflows = Workflows{}
View Source
var RegisteredBuilders = Builders{}
View Source
var VersionRegexp = regexp.MustCompile("(\\d+)\\.(\\d+)\\.(\\d+)")

Functions

func CommandsForShipping

func CommandsForShipping(p *Project, push bool) (commands []*exec.Cmd)

func LoadEnv

func LoadEnv(envName string, feature string) map[string]string

func ProcessDeployment

func ProcessDeployment(p *Project, env, deployConfig, serviceConfig string) error

func RegisterBuilder

func RegisterBuilder(name string, builder *Builder)

func RegisterWorkFlow

func RegisterWorkFlow(name string, flow *Workflow)

func SetEnv

func SetEnv(k string, v string)

func WrapEnv

func WrapEnv(s string) string

Types

type AliyunLoginResponse added in v1.0.18

type AliyunLoginResponse struct {
	Data AliyunLoginResponseData `json:"data"`
}

type AliyunLoginResponseData added in v1.0.18

type AliyunLoginResponseData struct {
	AuthorizationToken string `json:"authorizationToken"`
	TempUserName       string `json:"tempUserName"`
	ExpireDate         uint64 `json:"expireDate"`
}

type AliyunShippingProcessor added in v1.0.18

type AliyunShippingProcessor struct{}

func (*AliyunShippingProcessor) Login added in v1.0.18

func (a *AliyunShippingProcessor) Login(p *Project) []*exec.Cmd

func (*AliyunShippingProcessor) Push added in v1.0.18

func (a *AliyunShippingProcessor) Push(p *Project, image string) []*exec.Cmd

type BranchFlow

type BranchFlow struct {
	Skip    bool              `yaml:"skip,omitempty"`
	Extends string            `yaml:"extends,omitempty"`
	Env     map[string]string `yaml:"env,omitempty"`
	Jobs    Jobs              `yaml:"jobs,inline,omitempty"`
}

func (BranchFlow) Merge

func (branchFlow BranchFlow) Merge(nextBranchFlow *BranchFlow) BranchFlow

func (*BranchFlow) UnmarshalYAML

func (branchFlow *BranchFlow) UnmarshalYAML(unmarshal func(interface{}) error) error

type BranchFlows

type BranchFlows map[string]BranchFlow

func (BranchFlows) Merge

func (branchFlows BranchFlows) Merge(nextBranches BranchFlows) BranchFlows

type Builder

type Builder struct {
	ProgramLanguage string
	Image           string
	WorkingDir      string
	// contains filtered or unexported fields
}

type Builders

type Builders map[string]*Builder

func (Builders) GetBuilderBy

func (bs Builders) GetBuilderBy(programLanguage string) *Builder

func (Builders) SupportProgramLanguages

func (bs Builders) SupportProgramLanguages() (list []string)

type CIArtifact

type CIArtifact struct {
	UnTracked bool     `yaml:"untracked,omitempty"`
	When      string   `yaml:"when,omitempty"`
	Name      string   `yaml:"name,omitempty"`
	Paths     []string `yaml:"paths,omitempty"`
	ExpireIn  string   `yaml:"expire_in,omitempty"`
}

type CICache

type CICache struct {
	UnTracked bool     `yaml:"untracked,omitempty"`
	Key       string   `yaml:"key,omitempty"`
	Paths     []string `yaml:"paths,omitempty"`
}

type CIConfig

type CIConfig struct {
	Stages    []string `yaml:"stages"`
	Cache     CICache  `yaml:"cache,omitempty"`
	CommonJob CIJob    `yaml:"common_job,inline,omitempty"`
	CIJobMap  `yaml:"jobs,inline"`
}

func NewCIConfig

func NewCIConfig() *CIConfig

func (CIConfig) AddJob

func (c CIConfig) AddJob(name string, job *CIJob) *CIConfig

func (CIConfig) AddJobWithDependencies

func (c CIConfig) AddJobWithDependencies(name string, job *CIJob, dependencies ...string) *CIConfig

func (CIConfig) WithCache

func (c CIConfig) WithCache(cache CICache) *CIConfig

func (CIConfig) WithCommon

func (c CIConfig) WithCommon(job *CIJob) *CIConfig

func (CIConfig) WithStages

func (c CIConfig) WithStages(stages ...string) *CIConfig

func (*CIConfig) WriteToFile

func (c *CIConfig) WriteToFile()

type CIEnv

type CIEnv struct {
	Name string `yaml:"name"`
}

type CIJob

type CIJob struct {
	Stage string `yaml:"stage,omitempty"`

	Image        string   `yaml:"image,omitempty"`
	Tags         []string `yaml:"tags,omitempty"`
	Services     []string `yaml:"services,omitempty"`
	Dependencies []string `yaml:"dependencies,omitempty"`

	Variables map[string]string `yaml:"variables,omitempty"`

	Environment CIEnv `yaml:"environment,omitempty"`

	BeforeScript []string `yaml:"before_script,omitempty"`
	AfterScript  []string `yaml:"after_script,omitempty"`
	Script       []string `yaml:"script,omitempty"`

	AllowFailure bool `yaml:"allow_failure,omitempty"`

	Artifacts *CIArtifact `yaml:"artifacts,omitempty"`

	Only     []string `yaml:"only,omitempty"`
	Except   []string `yaml:"except,omitempty"`
	When     string   `yaml:"when,omitempty"`
	Coverage string   `yaml:"coverage,omitempty"`
}

func NewCIJob

func NewCIJob(stage string) *CIJob

func (CIJob) AllowFail

func (c CIJob) AllowFail() *CIJob

func (CIJob) WithArtifacts

func (c CIJob) WithArtifacts(artifact *CIArtifact) *CIJob

func (CIJob) WithDependencies

func (c CIJob) WithDependencies(dependencies ...string) *CIJob

func (CIJob) WithEnv

func (c CIJob) WithEnv(name string) *CIJob

func (CIJob) WithExcept

func (c CIJob) WithExcept(except ...string) *CIJob

func (CIJob) WithImage

func (c CIJob) WithImage(image string) *CIJob

func (CIJob) WithOnly

func (c CIJob) WithOnly(only ...string) *CIJob

func (CIJob) WithScript

func (c CIJob) WithScript(script ...string) *CIJob

func (CIJob) WithTags

func (c CIJob) WithTags(tags ...string) *CIJob

func (CIJob) WithVariable

func (c CIJob) WithVariable(key string, value string) CIJob

func (CIJob) WithWhen

func (c CIJob) WithWhen(when string) *CIJob

type CIJobMap

type CIJobMap map[string]*CIJob

type FullImage

type FullImage string

func (FullImage) String

func (i FullImage) String() string

type Job

type Job struct {
	Stage     string      `yaml:"stage,omitempty"`
	Skip      bool        `yaml:"skip,omitempty"`
	Builder   string      `yaml:"builder,omitempty"`
	Run       Script      `yaml:"run,omitempty"`
	Artifacts *CIArtifact `yaml:"artifacts,omitempty"`
}

func (Job) MarshalYAML

func (job Job) MarshalYAML() (interface{}, error)

func (Job) Merge

func (job Job) Merge(nextJob *Job) Job

func (*Job) UnmarshalYAML

func (job *Job) UnmarshalYAML(unmarshal func(interface{}) error) error

type Jobs

type Jobs []Job

func (Jobs) Find

func (jobs Jobs) Find(stage string) (int, *Job)

func (Jobs) Merge

func (jobs Jobs) Merge(nextJobs Jobs) Jobs

func (Jobs) Remove

func (jobs Jobs) Remove(index int) (Jobs, error)

type Project

type Project struct {
	Name            string            `env:"name" yaml:"name"`
	Group           string            `env:"group" yaml:"group,omitempty"`
	Owner           string            `env:"owner" yaml:"owner,omitempty"`
	Version         Version           `env:"version" yaml:"version"`
	Desc            string            `env:"description" yaml:"description"`
	ProgramLanguage string            `env:"program_language" yaml:"program_language"`
	Workflow        Workflow          `yaml:"workflow,omitempty"`
	Scripts         map[string]Script `yaml:"scripts,omitempty"`
	Feature         string            `yaml:"feature,omitempty"`
	Selector        string            `env:"selector" yaml:"-"`
}

func (*Project) Command

func (p *Project) Command(args ...string) *exec.Cmd

func (*Project) Execute

func (p *Project) Execute(args ...string)

func (*Project) Run

func (p *Project) Run(commands ...*exec.Cmd)

func (*Project) RunScript

func (p *Project) RunScript(key string, inDocker bool) error

func (*Project) SetEnviron

func (p *Project) SetEnviron()

func (*Project) String

func (p *Project) String() string

func (*Project) UnmarshalFromFile

func (p *Project) UnmarshalFromFile(filePath, fileName string) error

func (Project) WithDesc

func (p Project) WithDesc(desc string) Project

func (Project) WithFeature

func (p Project) WithFeature(f string) Project

func (Project) WithGroup

func (p Project) WithGroup(group string) Project

func (Project) WithLanguage

func (p Project) WithLanguage(pl string) Project

func (Project) WithName

func (p Project) WithName(name string) Project

func (Project) WithOwner

func (p Project) WithOwner(owner string) Project

func (Project) WithScripts

func (p Project) WithScripts(key string, scripts ...string) Project

func (Project) WithVersion

func (p Project) WithVersion(s string) Project

func (Project) WithWorkflow

func (p Project) WithWorkflow(workflow string) Project

func (*Project) WriteToFile

func (p *Project) WriteToFile(filePath, fileName string)

type Script

type Script []string

func (Script) IsZero

func (s Script) IsZero() bool

func (Script) MarshalYAML

func (s Script) MarshalYAML() (interface{}, error)

func (Script) String

func (s Script) String() string

func (*Script) UnmarshalYAML

func (s *Script) UnmarshalYAML(unmarshal func(interface{}) error) error

type ShippingProcessor added in v1.0.18

type ShippingProcessor interface {
	Login(p *Project) []*exec.Cmd
	Push(p *Project, image string) []*exec.Cmd
}

func NewShippingProcessor added in v1.0.18

func NewShippingProcessor(typ ShippingProcessorType) ShippingProcessor

type ShippingProcessorType added in v1.0.18

type ShippingProcessorType uint8

api:enum

const (
	SHIPPING_PROCESSOR_TYPE_UNKNOWN          ShippingProcessorType = iota
	SHIPPING_PROCESSOR_TYPE__ALIYUN_REGISTRY                       // aliyun registry
)

打包处理器类型

func ParseShippingProcessorTypeFromLabelString added in v1.0.18

func ParseShippingProcessorTypeFromLabelString(s string) (ShippingProcessorType, error)

func ParseShippingProcessorTypeFromString added in v1.0.18

func ParseShippingProcessorTypeFromString(s string) (ShippingProcessorType, error)

func (ShippingProcessorType) EnumType added in v1.0.18

func (ShippingProcessorType) EnumType() string

func (ShippingProcessorType) Enums added in v1.0.18

func (ShippingProcessorType) Enums() map[int][]string

func (ShippingProcessorType) Label added in v1.0.18

func (v ShippingProcessorType) Label() string

func (ShippingProcessorType) MarshalText added in v1.0.18

func (v ShippingProcessorType) MarshalText() ([]byte, error)

func (ShippingProcessorType) String added in v1.0.18

func (v ShippingProcessorType) String() string

func (*ShippingProcessorType) UnmarshalText added in v1.0.18

func (v *ShippingProcessorType) UnmarshalText(data []byte) (err error)

type Version

type Version struct {
	Latest bool
	Suffix string
	Prefix string
	Major  int
	Minor  int
	Patch  int
}

func FromVersionString

func FromVersionString(s string) (*Version, error)

func (Version) IncreaseMajor

func (v Version) IncreaseMajor() Version

func (Version) IncreaseMinor

func (v Version) IncreaseMinor() Version

func (Version) IncreasePatch

func (v Version) IncreasePatch() Version

func (Version) IsStable

func (v Version) IsStable() bool

func (Version) MarshalYAML

func (v Version) MarshalYAML() (interface{}, error)

func (Version) String

func (v Version) String() string

func (*Version) UnmarshalYAML

func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error

type Workflow

type Workflow struct {
	Extends     string      `yaml:"extends,omitempty"`
	BranchFlows BranchFlows `yaml:"branch_flows,inline"`
}

func (Workflow) GetAvailableEnv

func (w Workflow) GetAvailableEnv() (envs map[string]string)

func (*Workflow) ToCIConfig

func (w *Workflow) ToCIConfig(project *Project) *CIConfig

func (*Workflow) ToDroneConfig

func (w *Workflow) ToDroneConfig(p *Project) *drone.CIDronePipelineDocker

func (Workflow) TryExtendsOrSetDefaults

func (w Workflow) TryExtendsOrSetDefaults() *Workflow

type Workflows

type Workflows map[string]*Workflow

func (Workflows) List

func (bs Workflows) List() (list []string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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