notifier

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const StatusID string = "flux-status"

StatusID is a project specific identifier to avoid conflicts in the commit status.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureDevops

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

AzureDevops handles events for AzureDevops repositories.

func NewAzureDevops

func NewAzureDevops(inst string, url string, pat string) (*AzureDevops, error)

NewAzureDevops creates and returns an AzureDevops instance.

func (AzureDevops) Get

func (azdo AzureDevops) Get(commitID string, action string) (*Status, error)

Get returns the status of a given commit id in a AzureDevops repository.

func (AzureDevops) Send

func (azdo AzureDevops) Send(ctx context.Context, e Event) error

Send sets the status for a given commit id in a AzureDevops repository.

func (AzureDevops) String

func (AzureDevops) String() string

String returns the name of the struct.

type Event

type Event struct {
	Type     EventType
	Message  string
	CommitID string
	State    EventState
}

Event wraps information about a specific event occurence.

type EventState

type EventState string

EventState represents the different states an event can be in.

const (
	// EventStateFailed occurs when an action has failed.
	EventStateFailed EventState = "failed"
	// EventStatePending occurs when an event is not yet completed.
	EventStatePending EventState = "pending"
	// EventStateSucceeded occurs when an event has completed successfully.
	EventStateSucceeded EventState = "succeeded"
	// EventStateCanceled occurs when an event has been preemptively canceled.
	EventStateCanceled EventState = "canceled"
)

These constants represents all valid EventState values.

type EventType

type EventType string

EventType represents the different types of actions an event can occur for.

const (
	// EventTypeSync when the remote state has successfully reconciled.
	EventTypeSync EventType = "sync"
	// EventTypeWorkload occurs when all workloads have started.
	EventTypeWorkload EventType = "workload"
)

These constants represents all valid EventType values.

type GitHub added in v0.2.0

type GitHub struct {
	Instance   string
	Owner      string
	Repository string
	Client     *github.Client
}

GitHub handles events for Github repositories.

func NewGitHub added in v0.2.0

func NewGitHub(inst string, url string, token string) (*GitHub, error)

NewGitHub returns a new Github instance.

func (GitHub) Get added in v0.2.0

func (g GitHub) Get(commitID string, action string) (*Status, error)

Get returns the status of a given commit id in a Github repository.

func (GitHub) Send added in v0.2.0

func (g GitHub) Send(ctx context.Context, e Event) error

Send sets the status for a given commit id in a Github repository.

func (GitHub) String added in v0.2.0

func (g GitHub) String() string

String returns the name of the struct.

type Gitlab

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

Gitlab handles events for Gitlab repositories.

func NewGitlab

func NewGitlab(inst string, url string, token string) (*Gitlab, error)

NewGitlab creates and returns a Gitlab instance.

func (Gitlab) Get

func (g Gitlab) Get(commitID string, action string) (*Status, error)

Get returns the status of a given commit id in a Gitlab repository.

func (Gitlab) Send

func (g Gitlab) Send(ctx context.Context, e Event) error

Send sets the status for a given commit id in a Gitlab repository.

func (Gitlab) String

func (g Gitlab) String() string

String returns the name of the struct.

type Mock

type Mock struct {
	Events chan Event
}

Mock implements a dummy notifier that doesn nothing.

func NewMock

func NewMock() *Mock

NewMock creates and returns a Mock instance.

func (*Mock) Get

func (n *Mock) Get(commitID string, action string) (*Status, error)

Get always returns nil.

func (*Mock) Send

func (n *Mock) Send(ctx context.Context, e Event) error

Send adds the event to the Events channel buffer.

func (*Mock) String

func (n *Mock) String() string

String returns the name of the struct.

type Notifier

type Notifier interface {
	Send(context.Context, Event) error
	Get(string, string) (*Status, error)
	String() string
}

Notifier is the interface that wraps the required methods to send events to a git provider.

func GetNotifier

func GetNotifier(inst string, url string, azdoPat string, glToken string, ghToken string) (Notifier, error)

GetNotifier returns the best matching notifier given the configuration data. It works by attempting to create each available notifier one by one, and returns the first one that succeededs.

type Status

type Status struct {
	Name  string     `json:"name"`
	State EventState `json:"state"`
}

Status represents the current status of a commit id.

Jump to

Keyboard shortcuts

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