store

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// FlagOnlyFailedJobs means we only keep failed jobs
	FlagOnlyFailedJobs = "only-failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ProjectIdentifier

type ProjectIdentifier struct {
	VCSType string // Currently supported : "gh" and "bb"
	Org     string
	Project string
}

ProjectIdentifier is a structure to differentiate projects from different VCS

func CreateProjectIdentifierFromSlug

func CreateProjectIdentifierFromSlug(fullSlug string) (*ProjectIdentifier, string)

CreateProjectIdentifierFromSlug creates a struct from a slug in format (gh|bb)/org-name/project-name) Return a string explaining the error is related to incorrect formatting

func (*ProjectIdentifier) ToCircleURL

func (pi *ProjectIdentifier) ToCircleURL() string

ToCircleURL returns the link to CircleCI project page

func (*ProjectIdentifier) ToMarkdown

func (pi *ProjectIdentifier) ToMarkdown() string

ToMarkdown returns a link to the repo formatted in Markdown

func (*ProjectIdentifier) ToSlug

func (pi *ProjectIdentifier) ToSlug() string

ToSlug returns the slug in format "(gh|bb)/org-name/project-name)"

type Store

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

Store is an interface to interact with the KV Store

func NewStore

func NewStore(api plugin.API) (Store, error)

NewStore returns a fresh store

func (*Store) DeleteTokenForUser

func (s *Store) DeleteTokenForUser(userID string) error

DeleteTokenForUser returns an error if the token has not been deleted

func (*Store) GetDefaultProject

func (s *Store) GetDefaultProject(userID string) (*ProjectIdentifier, error)

GetDefaultProject retrieves the saved default project for the user. Returns nil if no default project exists for the user

func (*Store) GetSubscriptions

func (s *Store) GetSubscriptions() (*Subscriptions, error)

GetSubscriptions returns all the subscriptions from the KVStore

func (*Store) GetTokenForUser

func (s *Store) GetTokenForUser(userID, encryptionKey string) (string, error)

GetTokenForUser returns the token or an empty string if no token is stored

func (*Store) StoreDefaultProject

func (s *Store) StoreDefaultProject(userID string, project ProjectIdentifier) error

StoreDefaultProject saves the passed in default project

func (*Store) StoreSubscriptions

func (s *Store) StoreSubscriptions(subs *Subscriptions) error

StoreSubscriptions stores the subscriptions in the KVStore

func (*Store) StoreTokenForUser

func (s *Store) StoreTokenForUser(userID, circleciToken, encryptionKey string) error

StoreTokenForUser returns an error if the token has not been saved

type Subscription

type Subscription struct {
	ChannelID          string            `json:"ChannelID"`
	CreatorID          string            `json:"CreatorID"`
	ProjectInformation ProjectIdentifier `json:"ProjectInformation"`
	Flags              SubscriptionFlags `json:"Flags"`
}

Subscription contains a subscription for a channel and a project

func (*Subscription) ToSlackAttachmentField

func (s *Subscription) ToSlackAttachmentField(username string) *model.SlackAttachmentField

ToSlackAttachmentField transforms the subscription to a well-formatted short Slack attachment field

type SubscriptionFlags

type SubscriptionFlags struct {
	OnlyFailedBuilds bool `json:"OnlyFailedBuilds"`
}

SubscriptionFlags contains the options for subscriptions

func (*SubscriptionFlags) AddFlag

func (s *SubscriptionFlags) AddFlag(flag string) error

AddFlag adds a flag to the struct

func (SubscriptionFlags) String

func (s SubscriptionFlags) String() string

String outputs the flags in a well-formatted string

type Subscriptions

type Subscriptions struct {
	Repositories map[string][]*Subscription
}

Subscriptions stores all the subscriptions Keys of the map are projects slugs, in format "(gh|bb)/org-name/project-name" Values of the map are arrays of subscriptions, with different channels, flags and creator IDs

func (*Subscriptions) AddSubscription

func (s *Subscriptions) AddSubscription(newSub *Subscription) bool

AddSubscription adds a new subscription in the struct Returns true if the subscription was already existing and has been updated

func (*Subscriptions) GetFilteredChannelsForJob

func (s *Subscriptions) GetFilteredChannelsForJob(conf *ProjectIdentifier, isFailed bool) []string

GetFilteredChannelsForJob retrieves all the channels specified by a job for a project, filtered with subscription flags

func (*Subscriptions) GetSubscribedChannelsForProject

func (s *Subscriptions) GetSubscribedChannelsForProject(conf *ProjectIdentifier) []string

GetSubscribedChannelsForProject retrieves a list of subscribed channel IDs for a project

func (*Subscriptions) GetSubscriptionsByChannel

func (s *Subscriptions) GetSubscriptionsByChannel(channelID string) []*Subscription

GetSubscriptionsByChannel retrieves the subscriptions for a given channel

func (*Subscriptions) GetSubscriptionsForProject

func (s *Subscriptions) GetSubscriptionsForProject(conf *ProjectIdentifier) []*Subscription

GetSubscriptionsForProject retrieves all the subscriptions for a given project

func (*Subscriptions) RemoveSubscription

func (s *Subscriptions) RemoveSubscription(channelID string, conf *ProjectIdentifier) bool

RemoveSubscription removes a subscription from the struct Returns true if the subscription has been found and removed

Jump to

Keyboard shortcuts

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