hxctx

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnvVarKeyCommitSha        = "CI_COMMIT_SHA"
	EnvVarKeyCommitRefName    = "CI_COMMIT_REF_NAME"
	EnvVarKeyProjectNamespace = "CI_PROJECT_NAMESPACE"
	EnvVarKeyProjectName      = "CI_PROJECT_NAME"
	EnvVarKeyCommitMessage    = "CI_COMMIT_MESSAGE"
)

Functions

func CommandForDeploy

func CommandForDeploy(w *Workspace) (namespace, data string)

func GetFeatAndEnv

func GetFeatAndEnv(commitRef string) (feat string, env string)

func GetShortSha

func GetShortSha() string

func MustMarshalToEnvs

func MustMarshalToEnvs(envs map[string]string, v interface{}, prefix string)

func MustWriteYAML

func MustWriteYAML(filename string, v interface{})

func ResolveEnvVars

func ResolveEnvVars(envVars map[string]string, data []byte) []byte

func SetEnviron

func SetEnviron(envs map[string]string)

Types

type Context

type Context struct {
	Feature   string
	DeployEnv string
	Workspace string

	MainWorkspace *Workspace
	Workspaces    []*Workspace
}

func (*Context) Init

func (ctx *Context) Init()

func (*Context) Range

func (ctx *Context) Range(fn func(w *Workspace))

type DeployOpt

type DeployOpt struct {
	DryRun bool
}

type DeployResource

type DeployResource struct {
	runtime.Object `json:"object"`
	FromFiles      []string `json:"fromFiles"`
}

type EnvVarSet

type EnvVarSet struct {
	Values    map[string]string `json:"values,omitempty"`
	Defaults  map[string]string `json:"defaults,omitempty"`
	FromFiles []string          `json:"fromFiles,omitempty"`
}

type Project

type Project struct {
	Name        string         `env:"name" json:"name"`
	Feature     string         `env:"feature"  json:"feature,omitempty"`
	Version     semver.Version `env:"version" json:"version"`
	Group       string         `env:"group"  json:"group,omitempty"`
	Description string         `env:"description" yaml:"description,omitempty" json:"description,omitempty"`
	Image       string         `env:"image" json:"image"`
}

func (Project) DefaultImageTag

func (p Project) DefaultImageTag() string

func (Project) FullName

func (p Project) FullName() string

type Refer

type Refer struct {
	ReferName    string `json:"referName"`
	ReferVersion string `json:"referVersion"`
}

type Refers

type Refers []Refer

type Template

type Template struct {
	// contains filtered or unexported fields
}

func MustNewTemplate

func MustNewTemplate(data []byte) *Template

func NewTemplate

func NewTemplate(tpl []byte) (*Template, error)

func (*Template) Execute

func (t *Template) Execute(values map[string]string) []byte

type Workspace

type Workspace struct {
	IsMain          bool   `json:"-"`
	ProjectRoot     string `json:"-"`
	WorkspaceRoot   string `json:"-"`
	Project         `json:"project"`
	EnvVarSet       EnvVarSet        `json:"envVars,omitempty"`
	DeployEnv       string           `json:"deployEnv"`
	DeployResources []DeployResource `json:"deployResources,omitempty"`

	spec.Spec
	DefaultEnvs      map[string]string
	Environment      string
	Version          string
	Templates        map[string][]byte
	ReferFiles       Refers
	CommitShaMessage string
	CommitSha        string
}

func NewWorkspace

func NewWorkspace(workspaceRoot string, projectRoot string, setDefault func(w *Workspace)) *Workspace

func (*Workspace) InitProject

func (w *Workspace) InitProject()

func (*Workspace) Path

func (w *Workspace) Path(f string) string

func (*Workspace) WriteTo

func (w *Workspace) WriteTo(writer io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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