flow

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 36 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")
)
View Source
var ErrArtifactNotFound = errors.New("artifact not found")

ErrArtifactNotFound should be returned by implementations of ArtifactReadStorage to indicate that an artifact was not found.

Functions

func PushArtifactToReleaseManager added in v0.6.0

func PushArtifactToReleaseManager(ctx context.Context, releaseManagerClient *httpinternal.Client, artifactFileName, resourceRoot string) (string, error)

PushArtifactToReleaseManager pushes an artifact to the release manager

Types

type Actor added in v0.0.15

type Actor struct {
	Email string
	Name  string
}

type ArtifactReadStorage added in v0.6.0

type ArtifactReadStorage interface {
	// ArtifactExists returns whether an artifact with id artifactID is available.
	ArtifactExists(ctx context.Context, service, artifactID string) (bool, error)

	// ArtifactSpecification returns the artifact specification for a given
	// service and artifact ID.
	ArtifactSpecification(ctx context.Context, service, artifactID string) (artifact.Spec, error)

	// ArtifactPaths returns file system paths for the artifact specification
	// (specPath) and yaml resources directory (resourcesPath) available on the
	// file system for copying to releases. The returned close function is
	// responsible for clean up of the persisted files.
	ArtifactPaths(ctx context.Context, service, environment, branch, artifactID string) (specPath, resourcesPath string, close func(context.Context), err error)

	// LatestArtifactSpecification returns the latest artifact specification for a
	// given service and branch.
	LatestArtifactSpecification(ctx context.Context, service, branch string) (artifact.Spec, error)

	// LatestArtifactPaths returns file system paths for the artifact
	// specification (specPath) and yaml resources directory (resourcesPath)
	// available on the file system for copying to releases of the latest artifact
	// for provided service and branch. The returned close function is responsible
	// for clean up of the persisted files.
	LatestArtifactPaths(ctx context.Context, service, environment, branch string) (specPath, resourcesPath string, close func(context.Context), err error)

	// ArtifactSpecifications returns a list of n newest artifact specifications
	// for service. They should be ordered by newest first.
	ArtifactSpecifications(ctx context.Context, service string, n int, branch string) ([]artifact.Spec, error)
}

type DescribeReleaseResponse added in v0.0.33

type DescribeReleaseResponse struct {
	Releases []Release
}

type Environment

type Environment struct {
	Name                  string    `json:"name,omitempty"`
	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 GenericEvent added in v0.6.0

type GenericEvent 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 (*GenericEvent) Unmarshal added in v0.6.0

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

type GitService added in v0.9.4

type GitService interface {
	SyncMaster(context.Context) error
	Clone(context.Context, string) (*git.Repository, error)
	MasterPath() string
	Commit(ctx context.Context, rootPath, changesPath, msg string) error
	LocateServiceReleaseRollbackSkip(ctx context.Context, r *git.Repository, env, service string, n uint) (plumbing.Hash, error)
	Checkout(ctx context.Context, rootPath string, hash plumbing.Hash) error
}

type MockGitService added in v0.9.4

type MockGitService struct {
	mock.Mock
}

MockGitService is an autogenerated mock type for the GitService type

func (*MockGitService) Checkout added in v0.9.4

func (_m *MockGitService) Checkout(ctx context.Context, rootPath string, hash plumbing.Hash) error

Checkout provides a mock function with given fields: ctx, rootPath, hash

func (*MockGitService) Clone added in v0.9.4

func (_m *MockGitService) Clone(_a0 context.Context, _a1 string) (*git.Repository, error)

Clone provides a mock function with given fields: _a0, _a1

func (*MockGitService) Commit added in v0.9.4

func (_m *MockGitService) Commit(ctx context.Context, rootPath string, changesPath string, msg string) error

Commit provides a mock function with given fields: ctx, rootPath, changesPath, msg

func (*MockGitService) LocateServiceReleaseRollbackSkip added in v0.9.4

func (_m *MockGitService) LocateServiceReleaseRollbackSkip(ctx context.Context, r *git.Repository, env string, service string, n uint) (plumbing.Hash, error)

LocateServiceReleaseRollbackSkip provides a mock function with given fields: ctx, r, env, service, n

func (*MockGitService) MasterPath added in v0.9.4

func (_m *MockGitService) MasterPath() string

MasterPath provides a mock function with given fields:

func (*MockGitService) SyncMaster added in v0.9.4

func (_m *MockGitService) SyncMaster(_a0 context.Context) error

SyncMaster provides a mock function with given fields: _a0

type NewArtifactEvent added in v0.7.0

type NewArtifactEvent struct {
	Service    string `json:"service,omitempty"`
	ArtifactID string `json:"artifactId,omitempty"`
}

func (NewArtifactEvent) Marshal added in v0.7.0

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

func (NewArtifactEvent) Type added in v0.7.0

func (NewArtifactEvent) Type() string

func (*NewArtifactEvent) Unmarshal added in v0.7.0

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

type NotifyReleaseFailedOptions added in v0.26.0

type NotifyReleaseFailedOptions struct {
	PodName     string   `json:"podName,omitempty"`
	Namespace   string   `json:"namespace,omitempty"`
	Errors      []string `json:"errors,omitempty"`
	AuthorEmail string   `json:"authorEmail,omitempty"`
	Environment string   `json:"environment,omitempty"`
	ArtifactID  string   `json:"artifactId,omitempty"`
	Squad       string   `json:"squad,omitempty"`
	AlertSquad  string   `json:"alertSquad,omitempty"`
}

type NotifyReleaseOptions added in v0.0.12

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

type NotifyReleaseSucceededOptions added in v0.25.0

type NotifyReleaseSucceededOptions struct {
	Name          string
	Namespace     string
	ResourceType  string
	AvailablePods int32
	DesiredPods   int32
	ArtifactID    string
	AuthorEmail   string
	Environment   string
}

type Release added in v0.9.0

type Release struct {
	DefaultNamespaces bool
	ReleaseIndex      int
	Artifact          artifact.Spec
	ReleasedAt        time.Time
	ReleasedByEmail   string
	ReleasedByName    string
	Intent            intent.Intent
}

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"`
	Intent      intent.Intent `json:"intent,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 ReleaseSpec added in v0.19.0

type ReleaseSpec struct {
	Spec        artifact.Spec
	Environment string
}

type Service added in v0.0.15

type Service struct {
	ArtifactFileName string
	UserMappings     map[string]string
	Slack            *slack.Client
	Git              GitService
	Tracer           tracing.Tracer
	CanRelease       func(ctx context.Context, svc, branch, env string) (bool, error)
	Storage          ArtifactReadStorage
	Policy           *policy.Service
	Copier           *copy.Copier

	PublishReleaseArtifactID func(context.Context, ReleaseArtifactIDEvent) error
	PublishNewArtifact       func(context.Context, NewArtifactEvent) 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)

	// NotifyReleaseSucceededHook is triggered in a Go routine when a release has
	// succeeded. The context.Context is cancelled if the originating flow call is
	// cancelled.
	NotifyReleaseSucceededHook func(ctx context.Context, options NotifyReleaseSucceededOptions)

	// NotifyReleaseFailedHook is trigger in a Go routine when a release has failed.
	NotifyReleaseFailedHook func(ctx context.Context, options NotifyReleaseFailedOptions)
}

func (*Service) DescribeArtifact added in v0.0.33

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

DescribeArtifact returns n artifacts for a service.

func (*Service) DescribeLatestArtifact added in v0.8.0

func (s *Service) DescribeLatestArtifact(ctx context.Context, service, branch string) (artifact.Spec, error)

DescribeLatestArtifact returns the latest artifact for a service and branch

func (*Service) DescribeRelease added in v0.0.33

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

DescribeRelease returns information about a specific release in an environment.

func (*Service) ExecNewArtifact added in v0.7.0

func (s *Service) ExecNewArtifact(ctx context.Context, e NewArtifactEvent) error

ExecNewArtifact is handling behavior of release manager when new artifacts are generated and ready

func (*Service) ExecReleaseArtifactID added in v0.1.0

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

func (*Service) NewArtifact added in v0.7.0

func (s *Service) NewArtifact(ctx context.Context, service, artifactID string) error

NewArtifact should be triggered when a new artifact is ready

func (*Service) NotifyK8SDeployEvent added in v0.5.0

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

func (*Service) NotifyK8SJobErrorEvent added in v0.12.4

func (s *Service) NotifyK8SJobErrorEvent(ctx context.Context, event *http.JobErrorEvent) error

func (*Service) NotifyK8SPodErrorEvent added in v0.5.0

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

func (*Service) ReleaseArtifactID added in v0.0.15

func (s *Service) ReleaseArtifactID(ctx context.Context, actor Actor, environment, service, artifactID string, intent intent.Intent) (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) 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"`
	Environments      []Environment `json:"environments,omitempty"`
}

Jump to

Keyboard shortcuts

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