deploy

package
v1.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2019 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectHelmChartDir            = ".helm"
	ProjectDefaultSecretValuesFile = ProjectHelmChartDir + "/secret-values.yaml"
	ProjectSecretDir               = ProjectHelmChartDir + "/secret"

	DappChartDecodedSecretDir = "decoded-secret"
	DappChartMoreValuesDir    = "more-values"
)
View Source
const (
	DefaultHelmTimeout = 24 * time.Hour
)
View Source
const (
	TemplateEmptyValue = "\"-\""
)

Variables

View Source
var DappChartHelpersTpl = []byte(`{{- define "dapp_secret_file" -}}
{{-   $relative_file_path := index . 0 -}}
{{-   $context := index . 1 -}}
{{-   $context.Files.Get (print "` + DappChartDecodedSecretDir + `/" $relative_file_path) -}}
{{- end -}}

{{- define "_dimg" -}}
{{-   $context := index . 0 -}}
{{-   if not $context.Values.global.dapp.is_nameless_dimg -}}
{{-     required "No dimg specified for template" nil -}}
{{-   end -}}
{{    $context.Values.global.dapp.dimg.docker_image }}
{{- end -}}

{{- define "_dimg2" -}}
{{-   $name := index . 0 -}}
{{-   $context := index . 1 -}}
{{-   if $context.Values.global.dapp.is_nameless_dimg -}}
{{-     required (printf "No dimg should be specified for template, got '%s'" $name) nil -}}
{{-   end -}}
{{    index (required (printf "Unknown dimg '%s' specified for template" $name) (pluck $name $context.Values.global.dapp.dimg | first)) "docker_image" }}
{{- end -}}

{{- define "dimg" -}}
{{-   if eq (typeOf .) "chartutil.Values" -}}
{{-     $context := . -}}
{{      tuple $context | include "_dimg" }}
{{-   else if (ge (len .) 2) -}}
{{-     $name := index . 0 -}}
{{-     $context := index . 1 -}}
{{      tuple $name $context | include "_dimg2" }}
{{-   else -}}
{{-     $context := index . 0 -}}
{{      tuple $context | include "_dimg" }}
{{-   end -}}
{{- end -}}

{{- define "_dapp_container__imagePullPolicy" -}}
{{-   $context := index . 0 -}}
{{-   if $context.Values.global.dapp.ci.is_branch -}}
imagePullPolicy: Always
{{-   end -}}
{{- end -}}

{{- define "_dapp_container__image" -}}
{{-   $context := index . 0 -}}
image: {{ tuple $context | include "_dimg" }}
{{- end -}}

{{- define "_dapp_container__image2" -}}
{{-   $name := index . 0 -}}
{{-   $context := index . 1 -}}
image: {{ tuple $name $context | include "_dimg2" }}
{{- end -}}

{{- define "dapp_container_image" -}}
{{-   if eq (typeOf .) "chartutil.Values" -}}
{{-     $context := . -}}
{{      tuple $context | include "_dapp_container__image" }}
{{      tuple $context | include "_dapp_container__imagePullPolicy" }}
{{-   else if (ge (len .) 2) -}}
{{-     $name := index . 0 -}}
{{-     $context := index . 1 -}}
{{      tuple $name $context | include "_dapp_container__image2" }}
{{      tuple $context | include "_dapp_container__imagePullPolicy" }}
{{-   else -}}
{{-     $context := index . 0 -}}
{{      tuple $context | include "_dapp_container__image" }}
{{      tuple $context | include "_dapp_container__imagePullPolicy" }}
{{-   end -}}
{{- end -}}

{{- define "_dimg_id" -}}
{{-   $context := index . 0 -}}
{{-   if not $context.Values.global.dapp.is_nameless_dimg -}}
{{-     required "No dimg specified for template" nil -}}
{{-   end -}}
{{    $context.Values.global.dapp.dimg.docker_image_id }}
{{- end -}}

{{- define "_dimg_id2" -}}
{{-   $name := index . 0 -}}
{{-   $context := index . 1 -}}
{{-   if $context.Values.global.dapp.is_nameless_dimg -}}
{{-     required (printf "No dimg should be specified for template, got '%s'" $name) nil -}}
{{-   end -}}
{{    index (required (printf "Unknown dimg '%s' specified for template" $name) (pluck $name $context.Values.global.dapp.dimg | first)) "docker_image_id" }}
{{- end -}}

{{- define "dimg_id" -}}
{{-   if eq (typeOf .) "chartutil.Values" -}}
{{-     $context := . -}}
{{      tuple $context | include "_dimg_id" }}
{{-   else if (ge (len .) 2) -}}
{{-     $name := index . 0 -}}
{{-     $context := index . 1 -}}
{{      tuple $name $context | include "_dimg_id2" }}
{{-   else -}}
{{-     $context := index . 0 -}}
{{      tuple $context | include "_dimg_id" }}
{{-   end -}}
{{- end -}}

{{- define "_dapp_container_env" -}}
{{-   $context := index . 0 -}}
{{-   if $context.Values.global.dapp.ci.is_branch -}}
- name: DOCKER_IMAGE_ID
  value: {{ tuple $context | include "_dimg_id" }}
{{-   end -}}
{{- end -}}

{{- define "_dapp_container_env2" -}}
{{-   $name := index . 0 -}}
{{-   $context := index . 1 -}}
{{-   if $context.Values.global.dapp.ci.is_branch -}}
- name: DOCKER_IMAGE_ID
  value: {{ tuple $name $context | include "_dimg_id2" }}
{{-   end -}}
{{- end -}}

{{- define "dapp_container_env" -}}
{{-   if eq (typeOf .) "chartutil.Values" -}}
{{-     $context := . -}}
{{      tuple $context | include "_dapp_container_env" }}
{{-   else if (ge (len .) 2) -}}
{{-     $name := index . 0 -}}
{{-     $context := index . 1 -}}
{{      tuple $name $context | include "_dapp_container_env2" }}
{{-   else -}}
{{-     $context := index . 0 -}}
{{      tuple $context | include "_dapp_container_env" }}
{{-   end -}}
{{- end -}}
`)

Functions

func ConstructNameByTemplate

func ConstructNameByTemplate(template string, projectName string) error

func DeployHelmChart

func DeployHelmChart(chartPath string, releaseName string, namespace string, opts HelmChartOptions) error

func GetServiceValues

func GetServiceValues(projectName, repo, namespace, dockerTag string, localGit GitInfoGetter, images []DimgInfoGetter, opts ServiceValuesOptions) (map[string]interface{}, error)

func HelmCmd

func HelmCmd(args ...string) (stdout string, stderr string, err error)

func HelmVersion

func HelmVersion() (*version.Version, error)

func Init

func Init() error

func PurgeHelmRelease

func PurgeHelmRelease(releaseName string, opts CommonHelmOptions) error

func RunDeploy

func RunDeploy(projectDir, repo, tag, release, namespace string, dappfile *config.Dappfile, opts DeployOptions) error

func RunDismiss

func RunDismiss(release, namespace, kubeContext string, opts DismissOptions) error

func RunLint

func RunLint(projectDir string, dappfile *config.Dappfile, opts LintOptions) error

func RunRender

func RunRender(projectDir string, dappfile *config.Dappfile, opts RenderOptions) error

Types

type ChartConfig

type ChartConfig struct {
	Name string `json:"name"`
}

type ChartTemplates

type ChartTemplates []*Template

func (*ChartTemplates) ByKind

func (templates *ChartTemplates) ByKind(kind string) []*Template

func (*ChartTemplates) DaemonSets

func (templates *ChartTemplates) DaemonSets() []*Template

func (*ChartTemplates) Deployments

func (templates *ChartTemplates) Deployments() []*Template

func (*ChartTemplates) Jobs

func (templates *ChartTemplates) Jobs() []*Template

func (*ChartTemplates) Pods

func (templates *ChartTemplates) Pods() []*Template

func (*ChartTemplates) StatefulSets

func (templates *ChartTemplates) StatefulSets() []*Template

type CommonHelmOptions

type CommonHelmOptions struct {
	KubeContext string
}

type DappChart

type DappChart struct {
	ChartDir  string
	Values    []string
	Set       []string
	SetString []string
	// contains filtered or unexported fields
}

func GenerateDappChart

func GenerateDappChart(projectDir string, m secret.Manager) (*DappChart, error)

func PrepareDappChart

func PrepareDappChart(projectDir string, targetDir string, m secret.Manager) (*DappChart, error)

func (*DappChart) Deploy

func (chart *DappChart) Deploy(releaseName string, namespace string, opts HelmChartOptions) error

func (*DappChart) Lint

func (chart *DappChart) Lint() error

func (*DappChart) Render

func (chart *DappChart) Render(namespace string) (string, error)

func (*DappChart) SetGlobalAnnotation

func (chart *DappChart) SetGlobalAnnotation(name, value string) error

func (*DappChart) SetSecretValuesFile

func (chart *DappChart) SetSecretValuesFile(path string, m secret.Manager) error

func (*DappChart) SetValues

func (chart *DappChart) SetValues(values map[string]interface{}) error

func (*DappChart) SetValuesFile

func (chart *DappChart) SetValuesFile(path string) error

func (*DappChart) SetValuesSet

func (chart *DappChart) SetValuesSet(set string) error

func (*DappChart) SetValuesSetString

func (chart *DappChart) SetValuesSetString(setString string) error

type DeployOptions

type DeployOptions struct {
	Values          []string
	SecretValues    []string
	Set             []string
	SetString       []string
	Timeout         time.Duration
	WithoutRegistry bool

	Release     string
	Namespace   string
	Environment string
	KubeContext string
}

type DimgInfo

type DimgInfo struct {
	Config          *config.Dimg
	WithoutRegistry bool
	Repo            string
	Tag             string
}

func (*DimgInfo) GetImageId

func (d *DimgInfo) GetImageId() (string, error)

func (*DimgInfo) GetImageName

func (d *DimgInfo) GetImageName() string

func (*DimgInfo) GetName

func (d *DimgInfo) GetName() string

func (*DimgInfo) IsNameless

func (d *DimgInfo) IsNameless() bool

type DimgInfoGetter

type DimgInfoGetter interface {
	IsNameless() bool
	GetName() string
	GetImageName() string
	GetImageId() (string, error)
}

type DimgInfoGetterStub

type DimgInfoGetterStub struct {
	Name     string
	ImageTag string
	Repo     string
}

func (*DimgInfoGetterStub) GetImageId

func (d *DimgInfoGetterStub) GetImageId() (string, error)

func (*DimgInfoGetterStub) GetImageName

func (d *DimgInfoGetterStub) GetImageName() string

func (*DimgInfoGetterStub) GetName

func (d *DimgInfoGetterStub) GetName() string

func (*DimgInfoGetterStub) IsNameless

func (d *DimgInfoGetterStub) IsNameless() bool

type DismissOptions

type DismissOptions struct {
	WithNamespace bool
	KubeContext   string
}

type GitInfoGetter

type GitInfoGetter interface {
	IsBranchState() bool
	GetCurrentBranchName() string
	IsTagState() bool
	GetCurrentTagName() string
	GetHeadCommit() string
}

type HelmChartOptions

type HelmChartOptions struct {
	Set       []string
	SetString []string
	Values    []string
	DryRun    bool
	Debug     bool
	Timeout   time.Duration
	CommonHelmOptions
}

type LintOptions

type LintOptions struct {
	Values       []string
	SecretValues []string
	Set          []string
	SetString    []string
}

type RenderOptions

type RenderOptions struct {
	Values       []string
	SecretValues []string
	Set          []string
	SetString    []string
}

type ServiceValuesOptions

type ServiceValuesOptions struct {
	ForceTag    string
	ForceBranch string
}

type Template

type Template struct {
	Version  string `yaml:"apiVersion"`
	Kind     string `yaml:"kind,omitempty"`
	Metadata *struct {
		Name        string            `yaml:"name"`
		Namespace   string            `yaml:"namespace"`
		Annotations map[string]string `yaml:"annotations"`
		Uid         string            `yaml:"uid"`
	} `yaml:"metadata,omitempty"`
	Status string `yaml:"status,omitempty"`
}

func (*Template) Namespace

func (t *Template) Namespace(namespace string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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