Help us shape the future of Go! Take the 2026 Go Developer Survey

campaigns

package
v0.0.0-...-c19bbba Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformedOnQueryOrRepository = errors.New("malformed 'on' field; missing either a repository name or a query")
)

Functions

func UserCacheDir

func UserCacheDir() (string, error)

Types

type CampaignSpec

type CampaignSpec struct {
	Name              string                `json:"name,omitempty" yaml:"name"`
	Description       string                `json:"description,omitempty" yaml:"description"`
	On                []OnQueryOrRepository `json:"on,omitempty" yaml:"on"`
	Steps             []Step                `json:"steps,omitempty" yaml:"steps"`
	ImportChangesets  []ImportChangeset     `json:"importChangesets,omitempty" yaml:"importChangesets"`
	ChangesetTemplate *ChangesetTemplate    `json:"changesetTemplate,omitempty" yaml:"changesetTemplate"`
}

func ParseCampaignSpec

func ParseCampaignSpec(data []byte) (*CampaignSpec, error)

func (*CampaignSpec) Validate

func (spec *CampaignSpec) Validate() error

type CampaignSpecID

type CampaignSpecID string

type ChangesetSpec

type ChangesetSpec struct {
	BaseRepository string `json:"baseRepository"`

	*ExternalChangeset
	*CreatedChangeset
}

type ChangesetSpecID

type ChangesetSpecID string

type ChangesetTemplate

type ChangesetTemplate struct {
	Title     string                       `json:"title,omitempty" yaml:"title"`
	Body      string                       `json:"body,omitempty" yaml:"body"`
	Branch    string                       `json:"branch,omitempty" yaml:"branch"`
	Commit    ExpandedGitCommitDescription `json:"commit,omitempty" yaml:"commit"`
	Published bool                         `json:"published" yaml:"published"`
}

type CreatedChangeset

type CreatedChangeset struct {
	BaseRef        string                 `json:"baseRef"`
	BaseRev        string                 `json:"baseRev"`
	HeadRepository string                 `json:"headRepository"`
	HeadRef        string                 `json:"headRef"`
	Title          string                 `json:"title"`
	Body           string                 `json:"body"`
	Commits        []GitCommitDescription `json:"commits"`
	Published      bool                   `json:"published"`
}

type ExecutionCache

type ExecutionCache interface {
	Get(ctx context.Context, key ExecutionCacheKey) (result *ChangesetSpec, err error)
	Set(ctx context.Context, key ExecutionCacheKey, result *ChangesetSpec) error
	Clear(ctx context.Context, key ExecutionCacheKey) error
}

type ExecutionCacheKey

type ExecutionCacheKey struct {
	*Task
}

type ExecutionDiskCache

type ExecutionDiskCache struct {
	Dir string
}

func (ExecutionDiskCache) Clear

func (ExecutionDiskCache) Get

func (ExecutionDiskCache) Set

type ExecutionNoOpCache

type ExecutionNoOpCache struct{}

ExecutionNoOpCache is an implementation of actionExecutionCache that does not store or retrieve cache entries.

func (ExecutionNoOpCache) Clear

func (ExecutionNoOpCache) Get

func (ExecutionNoOpCache) Set

type Executor

type Executor interface {
	AddTask(repo *graphql.Repository, steps []Step, template *ChangesetTemplate) *TaskStatus
	LogFiles() []string
	Start(ctx context.Context)
	Wait() ([]*ChangesetSpec, error)
}

type ExecutorOpts

type ExecutorOpts struct {
	Cache       ExecutionCache
	Parallelism int
	Timeout     time.Duration

	ClearCache    bool
	KeepLogs      bool
	VerboseLogger bool
}

type ExecutorUpdateCallback

type ExecutorUpdateCallback func(*Task, TaskStatus)

type ExpandedGitCommitDescription

type ExpandedGitCommitDescription struct {
	Message string `json:"message,omitempty" yaml:"message"`
}

type ExternalChangeset

type ExternalChangeset struct {
	ExternalID string `json:"externalID"`
}

type GitCommitDescription

type GitCommitDescription struct {
	Message string `json:"message"`
	Diff    string `json:"diff"`
}

type ImportChangeset

type ImportChangeset struct {
	Repository  string        `json:"repository" yaml:"repository"`
	ExternalIDs []interface{} `json:"externalIDs" yaml:"externalIDs"`
}

type LogManager

type LogManager struct {
	// contains filtered or unexported fields
}

func NewLogManager

func NewLogManager(keepLogs bool) *LogManager

func (*LogManager) AddTask

func (lm *LogManager) AddTask(task *Task) (*TaskLogger, error)

func (*LogManager) Close

func (lm *LogManager) Close() error

func (*LogManager) LogFiles

func (lm *LogManager) LogFiles() []string

type OnQueryOrRepository

type OnQueryOrRepository struct {
	RepositoriesMatchingQuery string `json:"repositoriesMatchingQuery,omitempty" yaml:"repositoriesMatchingQuery"`
	Repository                string `json:"repository,omitempty" yaml:"repository"`
	Branch                    string `json:"branch,omitempty" yaml:"branch"`
}

func (*OnQueryOrRepository) String

func (on *OnQueryOrRepository) String() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(opts *ServiceOpts) *Service

func (*Service) ApplyCampaign

func (svc *Service) ApplyCampaign(ctx context.Context, spec CampaignSpecID) (*graphql.Campaign, error)

func (*Service) CreateCampaignSpec

func (svc *Service) CreateCampaignSpec(ctx context.Context, namespace, spec string, ids []ChangesetSpecID) (CampaignSpecID, string, error)

func (*Service) CreateChangesetSpec

func (svc *Service) CreateChangesetSpec(ctx context.Context, spec *ChangesetSpec) (ChangesetSpecID, error)

func (*Service) ExecuteCampaignSpec

func (svc *Service) ExecuteCampaignSpec(ctx context.Context, x Executor, spec *CampaignSpec, progress func([]*TaskStatus)) ([]*ChangesetSpec, error)

func (*Service) NewExecutionCache

func (svc *Service) NewExecutionCache(dir string) ExecutionCache

func (*Service) NewExecutor

func (svc *Service) NewExecutor(opts ExecutorOpts, update ExecutorUpdateCallback) Executor

func (*Service) ParseCampaignSpec

func (svc *Service) ParseCampaignSpec(in io.Reader) (*CampaignSpec, string, error)

func (*Service) ResolveNamespace

func (svc *Service) ResolveNamespace(ctx context.Context, namespace string) (string, error)

func (*Service) ResolveRepositories

func (svc *Service) ResolveRepositories(ctx context.Context, spec *CampaignSpec) ([]*graphql.Repository, error)

func (*Service) ResolveRepositoriesOn

func (svc *Service) ResolveRepositoriesOn(ctx context.Context, on *OnQueryOrRepository) ([]*graphql.Repository, error)

func (*Service) SetDockerImages

func (svc *Service) SetDockerImages(ctx context.Context, spec *CampaignSpec, progress func(i int)) error

type ServiceOpts

type ServiceOpts struct {
	AllowUnsupported bool
	Client           api.Client
}

type Step

type Step struct {
	Run       string            `json:"run,omitempty" yaml:"run"`
	Container string            `json:"container,omitempty" yaml:"container"`
	Env       map[string]string `json:"env,omitempty" yaml:"env"`
	// contains filtered or unexported fields
}

type Task

type Task struct {
	Repository *graphql.Repository
	Steps      []Step
	Template   *ChangesetTemplate `json:"-"`
}

type TaskLogger

type TaskLogger struct {
	// contains filtered or unexported fields
}

func (*TaskLogger) Close

func (tl *TaskLogger) Close() error

func (*TaskLogger) Log

func (tl *TaskLogger) Log(s string)

func (*TaskLogger) Logf

func (tl *TaskLogger) Logf(format string, a ...interface{})

func (*TaskLogger) MarkErrored

func (tl *TaskLogger) MarkErrored()

func (*TaskLogger) Path

func (tl *TaskLogger) Path() string

func (*TaskLogger) PrefixWriter

func (tl *TaskLogger) PrefixWriter(prefix string) io.Writer

type TaskStatus

type TaskStatus struct {
	Cached bool

	LogFile    string
	EnqueuedAt time.Time
	StartedAt  time.Time
	FinishedAt time.Time

	// Result fields.
	ChangesetSpec *ChangesetSpec
	Err           error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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