Documentation
¶
Index ¶
- Variables
- func PushArtifact(ctx context.Context, gitSvc *git.Service, ...) (string, error)
- func PushArtifactToReleaseManager(ctx context.Context, releaseManagerClient *httpinternal.Client, ...) (string, error)
- type Actor
- type ArtifactReadStorage
- type DescribeReleaseResponse
- type Environment
- type FluxReleaseMessage
- type GenericEvent
- type NewArtifactEvent
- type NotifyReleaseOptions
- type PromoteEvent
- type PromoteResult
- type ReleaseArtifactIDEvent
- type ReleaseBranchEvent
- type RollbackEvent
- type RollbackResult
- type Service
- func (s *Service) DescribeArtifact(ctx context.Context, service string, n int) ([]artifact.Spec, error)
- func (s *Service) DescribeRelease(ctx context.Context, namespace, environment, service string) (DescribeReleaseResponse, error)
- func (s *Service) ExecNewArtifact(ctx context.Context, e NewArtifactEvent) error
- func (s *Service) ExecPromote(ctx context.Context, p PromoteEvent) error
- func (s *Service) ExecReleaseArtifactID(ctx context.Context, event ReleaseArtifactIDEvent) error
- func (s *Service) ExecReleaseBranch(ctx context.Context, event ReleaseBranchEvent) error
- func (s *Service) ExecRollback(ctx context.Context, event RollbackEvent) error
- func (s *Service) NewArtifact(ctx context.Context, service, artifactID string) error
- func (s *Service) NotifyFluxEvent(ctx context.Context, event *http.FluxNotifyRequest) error
- func (s *Service) NotifyK8SDeployEvent(ctx context.Context, event *http.ReleaseEvent) error
- func (s *Service) NotifyK8SPodErrorEvent(ctx context.Context, event *http.PodErrorEvent) error
- func (s *Service) Promote(ctx context.Context, actor Actor, environment, namespace, service string) (PromoteResult, error)
- func (s *Service) ReleaseArtifactID(ctx context.Context, actor Actor, environment, service, artifactID string) (string, error)
- func (s *Service) ReleaseBranch(ctx context.Context, actor Actor, environment, service, branch string) (string, error)
- func (s *Service) Rollback(ctx context.Context, actor Actor, environment, namespace, service string) (RollbackResult, error)
- func (s *Service) Status(ctx context.Context, namespace, service string) (StatusResponse, error)
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
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.
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 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) ([]artifact.Spec, error) }
type DescribeReleaseResponse ¶ added in v0.0.33
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 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 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 NotifyReleaseOptions ¶ added in v0.0.12
type PromoteEvent ¶ added in v0.1.0
type PromoteEvent struct { ArtifactID string `json:"artifactId,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 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) Type() string
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 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) Storage ArtifactReadStorage Policy *policy.Service PublishPromote func(context.Context, PromoteEvent) error PublishRollback func(context.Context, RollbackEvent) error PublishReleaseArtifactID func(context.Context, ReleaseArtifactIDEvent) error PublishReleaseBranch func(context.Context, ReleaseBranchEvent) 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) }
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) 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) 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) NewArtifact ¶ added in v0.7.0
NewArtifact should be triggered when a new artifact is ready
func (*Service) NotifyFluxEvent ¶ added in v0.3.0
func (*Service) NotifyK8SDeployEvent ¶ added in v0.5.0
func (*Service) NotifyK8SPodErrorEvent ¶ added in v0.5.0
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.
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"` }