policy

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotParsable indicates that a policies file could not be parsed against
	// the specification.
	ErrNotParsable = errors.New("policies not parsable")
	// ErrUnknownFields indicates that a policies file contains an unknown field.
	ErrUnknownFields = errors.New("policies contains unknown fields")
	// ErrNotFound indicates that policies are not found for a service.
	ErrNotFound = errors.New("not found")
	// ErrConflict indicates that polices are not compatible
	ErrConflict = errors.New("conflict")
)

Functions

This section is empty.

Types

type Actor added in v0.0.15

type Actor struct {
	Name  string
	Email string
}

type AutoReleasePolicy

type AutoReleasePolicy struct {
	ID          string `json:"id,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Environment string `json:"environment,omitempty"`
}

type BranchRestriction added in v0.4.0

type BranchRestriction struct {
	ID          string `json:"id,omitempty"`
	BranchRegex string `json:"branchRegex,omitempty"`
	Environment string `json:"environment,omitempty"`
}

type GitService added in v0.5.0

type GitService interface {
	MasterPath() string
	Clone(context.Context, string) (*git.Repository, error)
	Commit(ctx context.Context, rootPath, changesPath, msg string) error
}

type MockGitService added in v0.5.0

type MockGitService struct {
	mock.Mock
}

MockGitService is an autogenerated mock type for the GitService type

func (*MockGitService) Clone added in v0.5.0

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.5.0

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) MasterPath added in v0.5.0

func (_m *MockGitService) MasterPath() string

MasterPath provides a mock function with given fields:

type Policies

type Policies struct {
	Service            string              `json:"service,omitempty"`
	AutoReleases       []AutoReleasePolicy `json:"autoReleases,omitempty"`
	BranchRestrictions []BranchRestriction `json:"branchRestrictions,omitempty"`
}

func (*Policies) Delete

func (p *Policies) Delete(ids ...string) int

Delete deletes any policies with a matching id.

func (*Policies) HasPolicies

func (p *Policies) HasPolicies() bool

HasPolicies returns whether any policies are applied.

func (*Policies) SetAutoRelease

func (p *Policies) SetAutoRelease(branch, env string) string

SetAutoRelease sets an auto-release policy for specified branch and environment.

If an auto-release policy exists for the same environment it is overwritten.

func (*Policies) SetBranchRestriction added in v0.4.0

func (p *Policies) SetBranchRestriction(branchRegex string, env string) string

SetBranchRestriction sets a branch-restriction policy for specified environment and branch regex.

If a policy exists for the same environment it is overwritten.

type Service added in v0.0.15

type Service struct {
	Tracer tracing.Tracer
	Git    GitService

	MaxRetries                      int
	GlobalBranchRestrictionPolicies []BranchRestriction
}

func (*Service) ApplyAutoRelease added in v0.0.15

func (s *Service) ApplyAutoRelease(ctx context.Context, actor Actor, svc, branch, env string) (string, error)

ApplyAutoRelease applies an auto-release policy for service svc from branch to environment env.

func (*Service) ApplyBranchRestriction added in v0.4.0

func (s *Service) ApplyBranchRestriction(ctx context.Context, actor Actor, svc, branchRegex, env string) (string, error)

ApplyBranchRestriction applies a branch-restriction policy for service svc to environment env with regular expression branchRegex.

func (*Service) CanRelease added in v0.4.0

func (s *Service) CanRelease(ctx context.Context, svc, branch, env string) (bool, error)

CanRelease returns whether service svc's branch can be released to env.

func (*Service) Delete added in v0.0.15

func (s *Service) Delete(ctx context.Context, actor Actor, svc string, ids []string) (int, error)

Delete deletes policies by ID for service svc.

func (*Service) Get added in v0.0.15

func (s *Service) Get(ctx context.Context, svc string) (Policies, error)

Get gets stored policies for service svc. If no policies are stored ErrNotFound is returned. This method also returns globally configured policies along with the service specific ones.

func (*Service) GetAutoReleases added in v0.0.15

func (s *Service) GetAutoReleases(ctx context.Context, svc, branch string) ([]AutoReleasePolicy, error)

GetAutoReleases gets stored auto-release policies for service svc. If no policies are found a nil slice is returned.

Jump to

Keyboard shortcuts

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