providers

package
v0.0.0-...-ba29e81 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StepPipeline = iota
	StepStage
	StepJob
	StepTask
)
View Source
const (
	ColumnRef tui.ColumnID = iota
	ColumnPipeline
	ColumnType
	ColumnState
	ColumnCreated
	ColumnStarted
	ColumnFinished
	ColumnDuration
	ColumnName
	ColumnWebURL
	ColumnAllowedFailure
)

Variables

View Source
var CircleCIURL = url.URL{
	Scheme:  "https",
	Host:    "circleci.com",
	Path:    "api/v1.1",
	RawPath: "api/v1.1",
}
View Source
var ErrNoLogHere = errors.New("no log is associated to this row")
View Source
var ErrNoProvider = errors.New("list of providers must not be empty")
View Source
var ErrObsoleteBuild = errors.New("build to save is older than current build in cache")
View Source
var ErrUnknownGitReference = errors.New("unknown git reference")
View Source
var ErrUnknownPipelineURL = errors.New("unknown pipeline url")
View Source
var ErrUnknownRepositoryURL = errors.New("unknown repository url")
View Source
var TravisComURL = url.URL{Scheme: "https", Host: "api.travis-ci.com"}
View Source
var TravisOrgURL = url.URL{Scheme: "https", Host: "api.travis-ci.org"}

Functions

func References

func References(path string, conf GitStyle) (tui.Suggestions, error)

func Remotes

func Remotes(path string) (map[string][]string, error)

Types

type AppVeyorClient

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

func NewAppVeyorClient

func NewAppVeyorClient(id string, name string, token string, requestsPerSecond float64) AppVeyorClient

func (AppVeyorClient) BuildFromURL

func (c AppVeyorClient) BuildFromURL(ctx context.Context, u string) (Pipeline, error)

func (AppVeyorClient) Host

func (c AppVeyorClient) Host() string

func (AppVeyorClient) ID

func (c AppVeyorClient) ID() string

func (AppVeyorClient) Log

func (c AppVeyorClient) Log(ctx context.Context, step Step) (string, error)

func (AppVeyorClient) Name

func (c AppVeyorClient) Name() string

type AzurePipelinesClient

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

func NewAzurePipelinesClient

func NewAzurePipelinesClient(id string, name string, token string, requestsPerSecond float64) AzurePipelinesClient

func (AzurePipelinesClient) BuildFromURL

func (c AzurePipelinesClient) BuildFromURL(ctx context.Context, u string) (Pipeline, error)

func (AzurePipelinesClient) Host

func (c AzurePipelinesClient) Host() string

func (AzurePipelinesClient) ID

func (AzurePipelinesClient) Log

func (c AzurePipelinesClient) Log(ctx context.Context, step Step) (string, error)

func (AzurePipelinesClient) Name

func (c AzurePipelinesClient) Name() string

type CIProvider

type CIProvider interface {
	// Unique identifier of the Provider instance among all other instances
	ID() string
	// Host part of the url of the Provider
	Host() string
	// Display name of the Provider
	Name() string
	// FIXME Replace stepID by stepIDs
	Log(ctx context.Context, step Step) (string, error)
	BuildFromURL(ctx context.Context, u string) (Pipeline, error)
}

type Cache

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

func NewCache

func NewCache(CIProviders []CIProvider, sourceProviders []SourceProvider, strategy utils.PollingStrategy) Cache

func (Cache) Commit

func (c Cache) Commit(ref string) (Commit, bool)

func (*Cache) Log

func (c *Cache) Log(ctx context.Context, key PipelineKey, stepIDs []string) (string, error)

func (*Cache) MonitorPipelines

func (c *Cache) MonitorPipelines(ctx context.Context, repositoryURLs map[string][]string, ref Ref, updates chan<- PipelineChanges) error

Monitor CI pipelines associated to the git reference 'ref'. Every time the cache is updated with new data, a message is sent on the 'updates' channel. This function may return ErrUnknownRepositoryURL if none of the source providers is able to handle 'repositoryURL'.

func (*Cache) Pipeline

func (c *Cache) Pipeline(key PipelineKey) (Pipeline, bool)

func (Cache) Pipelines

func (c Cache) Pipelines(ref string) []Pipeline

func (*Cache) SaveCommit

func (c *Cache) SaveCommit(ref string, commit Commit)

Store commit in If a commit with the same SHA exists, merge both commits.

func (*Cache) SavePipeline

func (c *Cache) SavePipeline(sha string, p Pipeline) (PipelineChanges, error)

Store build in If a build from the same Provider and with the same ID is already stored in cache, it will be overwritten if the build to save is more recent than the build in If the build to save is older than the build in cache, SavePipeline will return ErrObsoleteBuild.

func (*Cache) Step

func (c *Cache) Step(key PipelineKey, stepIDs []string) (Step, bool)

type CircleCIClient

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

func NewCircleCIClient

func NewCircleCIClient(id string, name string, token string, requestsPerSecond float64) CircleCIClient

func (CircleCIClient) BuildFromURL

func (c CircleCIClient) BuildFromURL(ctx context.Context, u string) (Pipeline, error)

func (CircleCIClient) Host

func (c CircleCIClient) Host() string

func (CircleCIClient) ID

func (c CircleCIClient) ID() string

func (CircleCIClient) Log

func (c CircleCIClient) Log(ctx context.Context, step Step) (string, error)

func (CircleCIClient) Name

func (c CircleCIClient) Name() string

type Commit

type Commit struct {
	Sha      string
	Author   string
	Date     time.Time
	Message  string
	Branches []string
	Tags     []string
	Head     string
	Statuses []string
}

func ResolveCommit

func ResolveCommit(path string, ref string) (Commit, error)

func (Commit) StyledStrings

func (c Commit) StyledStrings(conf GitStyle) []tui.StyledString

type Configuration

type Configuration struct {
	Polling struct {
		InitialInterval int  `toml:"initial-interval"`
		MaxInterval     int  `toml:"max-interval"`
		Forever         bool `toml:"forever"`
	}
	GitLab []struct {
		Name              string   `toml:"name" default:"gitlab"`
		URL               string   `toml:"url"`
		SSHHost           string   `toml:"ssh-host"`
		Token             string   `toml:"token"`
		TokenFromProcess  []string `toml:"token-from-process"`
		RequestsPerSecond float64  `toml:"max-requests-per-second"`
	}
	GitHub []struct {
		Token            string   `toml:"token"`
		TokenFromProcess []string `toml:"token-from-process"`
	}
	CircleCI []struct {
		Name              string   `toml:"name" default:"circleci"`
		Token             string   `toml:"token"`
		TokenFromProcess  []string `toml:"token-from-process"`
		RequestsPerSecond float64  `toml:"max-requests-per-second"`
	}
	Travis []struct {
		Name              string   `toml:"name" default:"travis"`
		URL               string   `toml:"url"`
		Token             string   `toml:"token"`
		TokenFromProcess  []string `toml:"token-from-process"`
		RequestsPerSecond float64  `toml:"max-requests-per-second"`
	}
	AppVeyor []struct {
		Name              string   `toml:"name" default:"appveyor"`
		Token             string   `toml:"token"`
		TokenFromProcess  []string `toml:"token-from-process"`
		RequestsPerSecond float64  `toml:"max-requests-per-second"`
	}
	Azure []struct {
		Name              string   `toml:"name" default:"azure"`
		Token             string   `toml:"token"`
		TokenFromProcess  []string `toml:"token-from-process"`
		RequestsPerSecond float64  `toml:"max-requests-per-second"`
	}
}

func (Configuration) ToCache

func (c Configuration) ToCache(ctx context.Context) (Cache, error)

type GitHubClient

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

func NewGitHubClient

func NewGitHubClient(ctx context.Context, id string, token *string) GitHubClient

func (GitHubClient) Commit

func (c GitHubClient) Commit(ctx context.Context, repo string, ref string) (Commit, error)

func (GitHubClient) ID

func (c GitHubClient) ID() string

func (GitHubClient) RefStatuses

func (c GitHubClient) RefStatuses(ctx context.Context, u string, ref string, sha string) ([]string, error)

type GitLabClient

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

func NewGitLabClient

func NewGitLabClient(id string, name string, baseURL string, token string, requestsPerSecond float64, SSHHostname string) (GitLabClient, error)

func (GitLabClient) BuildFromURL

func (c GitLabClient) BuildFromURL(ctx context.Context, u string) (Pipeline, error)

func (GitLabClient) Commit

func (c GitLabClient) Commit(ctx context.Context, repo string, ref string) (Commit, error)

func (GitLabClient) Host

func (c GitLabClient) Host() string

func (GitLabClient) ID

func (c GitLabClient) ID() string

func (GitLabClient) Log

func (c GitLabClient) Log(ctx context.Context, step Step) (string, error)

func (GitLabClient) Name

func (c GitLabClient) Name() string

func (GitLabClient) RefStatuses

func (c GitLabClient) RefStatuses(ctx context.Context, url string, ref string, sha string) ([]string, error)

type GitStyle

type GitStyle struct {
	Location *time.Location
	SHA      tui.StyleTransform
	Head     tui.StyleTransform
	Branch   tui.StyleTransform
	Tag      tui.StyleTransform
}

type HTTPError

type HTTPError struct {
	Method  string
	URL     string
	Status  int
	Message string
}

func (HTTPError) Error

func (err HTTPError) Error() string

type Log

type Log struct {
	Key     string
	Content utils.NullString
}

type Pipeline

type Pipeline struct {
	Number string

	ProviderHost string
	ProviderName string
	Ref          string
	IsTag        bool
	Step
	// contains filtered or unexported fields
}

func (Pipeline) Compare

func (p Pipeline) Compare(other tui.TableNode, id tui.ColumnID, i interface{}) int

func (Pipeline) Diff

func (p Pipeline) Diff(other Pipeline) string

func (Pipeline) InheritedValues

func (p Pipeline) InheritedValues() []tui.ColumnID

func (Pipeline) Key

func (p Pipeline) Key() PipelineKey

func (Pipeline) NodeID

func (p Pipeline) NodeID() interface{}

func (Pipeline) StatusDiff

func (p Pipeline) StatusDiff(before Pipeline) PipelineChanges

func (Pipeline) Values

func (p Pipeline) Values(v interface{}) map[tui.ColumnID]tui.StyledString

type PipelineChanges

type PipelineChanges struct {
	Valid bool
	PipelineKey
	Changes map[StepType]*StepStatusChanges
}

type PipelineKey

type PipelineKey struct {
	ProviderHost string
	ID           string
}

type Pipelines

type Pipelines []Pipeline

func (Pipelines) Diff

func (ps Pipelines) Diff(others Pipelines) string

type Provider

type Provider struct {
	ID   string
	Name string
}

type Ref

type Ref struct {
	Name string
	Commit
}

type SourceProvider

type SourceProvider interface {
	// Unique identifier of the Provider instance among all other instances
	ID() string
	RefStatuses(ctx context.Context, url string, ref string, sha string) ([]string, error)
	Commit(ctx context.Context, repo string, sha string) (Commit, error)
}

type State

type State string
const (
	Unknown  State = ""
	Pending  State = "pending"
	Running  State = "running"
	Passed   State = "passed"
	Failed   State = "failed"
	Canceled State = "canceled"
	Manual   State = "manual"
	Skipped  State = "skipped"
)

func (State) IsActive

func (s State) IsActive() bool

type Step

type Step struct {
	ID           string
	Name         string
	Type         StepType
	State        State
	AllowFailure bool
	CreatedAt    utils.NullTime
	StartedAt    utils.NullTime
	FinishedAt   utils.NullTime
	UpdatedAt    utils.NullTime
	Duration     utils.NullDuration
	WebURL       utils.NullString
	Log          Log
	Children     []Step
}

func Aggregate

func Aggregate(steps []Step) Step

func (Step) Compare

func (s Step) Compare(t tui.TableNode, id tui.ColumnID, i interface{}) int

func (Step) Diff

func (s Step) Diff(other Step) string

func (Step) InheritedValues

func (s Step) InheritedValues() []tui.ColumnID

func (Step) Map

func (s Step) Map(f func(Step) Step) Step

func (Step) NodeChildren

func (s Step) NodeChildren() []tui.TableNode

func (Step) NodeID

func (s Step) NodeID() interface{}

func (Step) Values

func (s Step) Values(v interface{}) map[tui.ColumnID]tui.StyledString

type StepStatusChanges

type StepStatusChanges struct {
	Started [][]string
	Passed  [][]string
	Failed  [][]string
}

type StepStyle

type StepStyle struct {
	GitStyle
	Provider tui.StyleTransform
	Status   struct {
		Failed   tui.StyleTransform
		Canceled tui.StyleTransform
		Passed   tui.StyleTransform
		Running  tui.StyleTransform
		Pending  tui.StyleTransform
		Skipped  tui.StyleTransform
		Manual   tui.StyleTransform
	}
}

type StepType

type StepType int

type TravisClient

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

func NewTravisClient

func NewTravisClient(id string, name string, token string, URL string, requestsPerSecond float64) (TravisClient, error)

func (TravisClient) BuildFromURL

func (c TravisClient) BuildFromURL(ctx context.Context, u string) (Pipeline, error)

func (TravisClient) Host

func (c TravisClient) Host() string

func (TravisClient) ID

func (c TravisClient) ID() string

func (TravisClient) Log

func (c TravisClient) Log(ctx context.Context, step Step) (string, error)

func (TravisClient) Name

func (c TravisClient) Name() string

Jump to

Keyboard shortcuts

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