flow

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownEnvironment            = errors.New("unknown environment")
	ErrNamespaceNotAllowedByArtifact = errors.New("namespace not allowed by artifact")
	ErrUnknownConfiguration          = errors.New("unknown configuration")
	ErrNothingToRelease              = errors.New("nothing to release")
	ErrReleaseProhibited             = errors.New("release prohibited")
)

Functions

func PushArtifact added in v0.0.4

func PushArtifact(ctx context.Context, gitSvc *git.Service, artifactFileName, resourceRoot string) (string, error)

PushArtifact pushes an artifact into the configuration repository.

The resourceRoot specifies the path to the artifact files. All files in this path will be pushed.

Types

type Actor added in v0.0.15

type Actor struct {
	Email string
	Name  string
}

type DescribeReleaseResponse added in v0.0.33

type DescribeReleaseResponse struct {
	DefaultNamespaces bool
	Artifact          artifact.Spec
	ReleasedAt        time.Time
	ReleasedByEmail   string
	ReleasedByName    string
}

type Environment

type Environment struct {
	Tag                   string    `json:"tag,omitempty"`
	Committer             string    `json:"committer,omitempty"`
	Author                string    `json:"author,omitempty"`
	Message               string    `json:"message,omitempty"`
	Date                  time.Time `json:"date,omitempty"`
	BuildURL              string    `json:"buildUrl,omitempty"`
	HighVulnerabilities   int64     `json:"highVulnerabilities,omitempty"`
	MediumVulnerabilities int64     `json:"mediumVulnerabilities,omitempty"`
	LowVulnerabilities    int64     `json:"lowVulnerabilities,omitempty"`
}

type FluxReleaseMessage added in v0.3.0

type FluxReleaseMessage struct {
	Environment  string
	Service      string
	ArtifactID   string
	GitAuthor    string
	GitCommitter string
}

type NotifyReleaseOptions added in v0.0.12

type NotifyReleaseOptions struct {
	Environment string
	Namespace   string
	Service     string
	Releaser    string
	Spec        artifact.Spec
}

type PromoteEvent added in v0.1.0

type PromoteEvent struct {
	Hash        string `json:"hash,omitempty"`
	Service     string `json:"service,omitempty"`
	Environment string `json:"environment,omitempty"`
	Namespace   string `json:"namespace,omitempty"`
	Actor       Actor  `json:"actor,omitempty"`
}

func (PromoteEvent) Marshal added in v0.1.0

func (p PromoteEvent) Marshal() ([]byte, error)

func (PromoteEvent) Type added in v0.1.0

func (PromoteEvent) Type() string

func (*PromoteEvent) Unmarshal added in v0.1.0

func (p *PromoteEvent) Unmarshal(data []byte) error

type PromoteResult added in v0.0.18

type PromoteResult struct {
	ReleaseID            string
	OverwritingNamespace string
}

type ReleaseArtifactIDEvent added in v0.1.0

type ReleaseArtifactIDEvent struct {
	Service     string `json:"service,omitempty"`
	Environment string `json:"environment,omitempty"`
	Namespace   string `json:"namespace,omitempty"`
	ArtifactID  string `json:"artifactID,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Actor       Actor  `json:"actor,omitempty"`
}

func (ReleaseArtifactIDEvent) Marshal added in v0.1.0

func (p ReleaseArtifactIDEvent) Marshal() ([]byte, error)

func (ReleaseArtifactIDEvent) Type added in v0.1.0

func (*ReleaseArtifactIDEvent) Unmarshal added in v0.1.0

func (p *ReleaseArtifactIDEvent) Unmarshal(data []byte) error

type ReleaseBranchEvent added in v0.1.0

type ReleaseBranchEvent struct {
	Service     string `json:"service,omitempty"`
	Environment string `json:"environment,omitempty"`
	Namespace   string `json:"namespace,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Actor       Actor  `json:"actor,omitempty"`
}

func (ReleaseBranchEvent) Marshal added in v0.1.0

func (p ReleaseBranchEvent) Marshal() ([]byte, error)

func (ReleaseBranchEvent) Type added in v0.1.0

func (ReleaseBranchEvent) Type() string

func (*ReleaseBranchEvent) Unmarshal added in v0.1.0

func (p *ReleaseBranchEvent) Unmarshal(data []byte) error

type RollbackEvent added in v0.1.0

type RollbackEvent struct {
	Service           string `json:"service,omitempty"`
	Environment       string `json:"environment,omitempty"`
	Namespace         string `json:"namespace,omitempty"`
	CurrentArtifactID string `json:"currentArtifactID,omitempty"`
	NewHash           string `json:"newHash,omitempty"`
	Actor             Actor  `json:"actor,omitempty"`
}

func (RollbackEvent) Marshal added in v0.1.0

func (p RollbackEvent) Marshal() ([]byte, error)

func (RollbackEvent) Type added in v0.1.0

func (RollbackEvent) Type() string

func (*RollbackEvent) Unmarshal added in v0.1.0

func (p *RollbackEvent) Unmarshal(data []byte) error

type RollbackResult added in v0.0.10

type RollbackResult struct {
	Previous             string
	New                  string
	OverwritingNamespace string
}

type Service added in v0.0.15

type Service struct {
	ArtifactFileName string
	UserMappings     map[string]string
	Slack            *slack.Client
	Git              *git.Service
	Tracer           tracing.Tracer
	CanRelease       func(ctx context.Context, svc, branch, env string) (bool, error)

	PublishPromote           func(context.Context, PromoteEvent) error
	PublishRollback          func(context.Context, RollbackEvent) error
	PublishReleaseArtifactID func(context.Context, ReleaseArtifactIDEvent) error
	PublishReleaseBranch     func(context.Context, ReleaseBranchEvent) error

	MaxRetries int

	// NotifyReleaseHook is triggered in a Go routine when a release is completed.
	// The context.Context is cancelled if the originating flow call is cancelled.
	NotifyReleaseHook func(ctx context.Context, options NotifyReleaseOptions)
}

func (*Service) DescribeArtifact added in v0.0.33

func (s *Service) DescribeArtifact(ctx context.Context, service string, n int) ([]artifact.Spec, error)

DescribeArtifact returns n artifacts for a service.

func (*Service) DescribeRelease added in v0.0.33

func (s *Service) DescribeRelease(ctx context.Context, namespace, environment, service string) (DescribeReleaseResponse, error)

DescribeRelease returns information about a specific release in an environment.

func (*Service) ExecPromote added in v0.1.0

func (s *Service) ExecPromote(ctx context.Context, p PromoteEvent) error

ExecPromote promotes a specific service to environment env.

By convention, promotion means:

Move released version of the previous environment into this environment

Promotion follows this convention

master -> dev -> staging -> prod

Flow

Checkout the current kubernetes configuration status and find the artifact.json spec for the service and previous environment. Use the artifact ID as a key for locating the artifacts.

Find the commit with the artifact ID and checkout the config repository at this point.

Copy artifacts from the current release into the new environment and commit the changes

func (*Service) ExecReleaseArtifactID added in v0.1.0

func (s *Service) ExecReleaseArtifactID(ctx context.Context, event ReleaseArtifactIDEvent) error

func (*Service) ExecReleaseBranch added in v0.1.0

func (s *Service) ExecReleaseBranch(ctx context.Context, event ReleaseBranchEvent) error

func (*Service) ExecRollback added in v0.1.0

func (s *Service) ExecRollback(ctx context.Context, event RollbackEvent) error

func (*Service) NotifyFluxEvent added in v0.3.0

func (s *Service) NotifyFluxEvent(ctx context.Context, event *http.FluxNotifyRequest) error

func (*Service) NotifyK8SDeployEvent added in v0.5.0

func (s *Service) NotifyK8SDeployEvent(ctx context.Context, event *http.ReleaseEvent) error

func (*Service) NotifyK8SPodErrorEvent added in v0.5.0

func (s *Service) NotifyK8SPodErrorEvent(ctx context.Context, event *http.PodErrorEvent) error

func (*Service) Promote added in v0.0.15

func (s *Service) Promote(ctx context.Context, actor Actor, environment, namespace, service string) (PromoteResult, error)

Promote promotes a specific service to environment env. The flow is async in that this method validates the inputs and publishes an event that is handled later on by ExecPromote.

func (*Service) ReleaseArtifactID added in v0.0.15

func (s *Service) ReleaseArtifactID(ctx context.Context, actor Actor, environment, service, artifactID string) (string, error)

ReleaseArtifactID releases a specific artifact to environment env.

Flow

Locate the commit of the artifact ID and checkout the config repository at this point.

Copy resources from the artifact commit into the environment and commit the changes

func (*Service) ReleaseBranch added in v0.0.15

func (s *Service) ReleaseBranch(ctx context.Context, actor Actor, environment, service, branch string) (string, error)

ReleaseBranch releases the latest artifact from a branch of a specific service to environment env.

Flow

Checkout the current kubernetes configuration status and find the artifact spec for the service and branch.

Copy artifacts from the artifacts into the environment and commit the changes.

func (*Service) Rollback added in v0.0.15

func (s *Service) Rollback(ctx context.Context, actor Actor, environment, namespace, service string) (RollbackResult, error)

func (*Service) Status added in v0.0.15

func (s *Service) Status(ctx context.Context, namespace, service string) (StatusResponse, error)

type StatusResponse

type StatusResponse struct {
	DefaultNamespaces bool        `json:"defaultNamespaces,omitempty"`
	Dev               Environment `json:"dev,omitempty"`
	Staging           Environment `json:"staging,omitempty"`
	Prod              Environment `json:"prod,omitempty"`
}

Jump to

Keyboard shortcuts

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