domain

package
v0.0.0-...-a8e4d9d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FreePlanUuid     = "b99a21cc-b108-466e-aa4d-bde10ebbe1f3"
	PlatinumPlanUuid = "f975a385-3625-4883-b353-8f1febeb5b3e"
)
View Source
const (
	EventNone      = "no events"
	EventNoHandler = "no event handler registered"

	EventOperationStarted   = "operations.started"
	EventOperationFailed    = "operations.failed"
	EventOperationSucceeded = "operations.succeeded"
	EventOperationTimedOut  = "operations.timed_out"
	EventOperationScheduled = "operations.scheduled"
)
View Source
const (
	LoggableOK = iota
	LoggableEndOfTransmission
)
View Source
const (
	LoggableWorkspace = "workspace"
	LoggableVerbose   = "verbose"
)
View Source
const (
	LogSubscriptionSubscribe = iota
	LogSubscriptionUnsubscribe
)
View Source
const (
	OperationTypeGitAccessCheck         string = "git.check.access"
	OperationTypeGitEnumerationBranches string = "git.enumeration.branches"
	OperationTypeGitEnumerationCommits  string = "git.enumeration.commits"
	OperationTypeJobScheduled           string = "job.scheduled"
	OperationTypeJobWebhooked           string = "job.webhooked"
	OperationTypeJobRetried             string = "job.retried"
	OperationTypeNotifierInvoke         string = "notifier.invoke"
)
View Source
const (
	ScheduledExecutionDefaultInterval = 24 * time.Hour
	ScheduledExecutionDefaultN        = 20
)
View Source
const ISODateFormat = "2006-01-02 15:04:05 -0700"

Variables

View Source
var (
	FreePlan = &BillingPlan{
		Uuid:                   FreePlanUuid,
		Name:                   "free",
		PrivateCodeAvailable:   true,
		PricePerMonth:          Money{0, USD},
		UsersIncluded:          1,
		ProjectsIncluded:       1,
		PricePerAdditionalUser: Money{0, USD},
		NumberOfConcurrentJobs: 1,
	}
	PlatinumPlan = &BillingPlan{
		Uuid:                   PlatinumPlanUuid,
		Name:                   "Platinum",
		PrivateCodeAvailable:   true,
		PricePerMonth:          Money{12900, USD},
		UsersIncluded:          10,
		ProjectsIncluded:       10,
		PricePerAdditionalUser: Money{1900, USD},
		NumberOfConcurrentJobs: 1,
	}
)
View Source
var (
	CapabilitySignUp         = "signup"
	CapabilityCreate         = "create"
	CapabilityRead           = "read"
	CapabilityUpdate         = "update"
	CapabilityValidate       = "validate"
	CapabilityArchive        = "archive"
	CapabilityReadPrivileged = "readPrivileged"
)
View Source
var (
	EUR = Currency("EUR")
	USD = Currency("USD")
)
View Source
var (
	ErrInvalidCronspecFormat = fmt.Errorf("Invalid Cronspec Format.")
	ErrInvalidTimespecFormat = fmt.Errorf("Invalid Timespec Format.")
	ErrScheduledInThePast    = fmt.Errorf("Scheduled in the past.")
	ErrInvalidTimezoneName   = fmt.Errorf("Invalid timezone name.")
	ErrNoTimeScheduled       = fmt.Errorf("Empty schedule time (Cronspec/Timespec).")
)
View Source
var (
	ScheduleDisabledInternalError = "internal_error"
	ScheduleDisabledJobArchived   = "job_archived"
	ScheduleDisabledRanOnce       = "ran_once"
)
View Source
var (
	ProjectInvitee = newCapabilityList().
					reads("project", "organization", "user")

	ErrTotpTokenNotValid = NewValidationError("totp", "not valid anymore")
)
View Source
var (
	SegmentCold     = "cold"
	SegmentLimbo    = "limbo"
	SegmentReturned = "returned"
	SegmentFailed   = "failed"
	SegmentLoner    = "loner"
	SegmentIdeal    = "ideal"
	UserSegments    = []string{SegmentCold, SegmentLimbo, SegmentReturned, SegmentFailed, SegmentLoner, SegmentIdeal}
)
View Source
var ErrNotASshSecret = errors.New("secret type is not ssh")
View Source
var ErrNotAnEnvironmentSecret = errors.New("secret type is not env")
View Source
var (
	// ErrUnknownOperationCategory indicates that no script can be
	// run for operations of the given type.
	ErrUnknownOperationCategory = errors.New("operation: unknown category")
)
View Source
var (
	GitTriggerChangeTypes = map[string]string{
		"change": "ref-changed",
		"add":    "ref-added",
		"remove": "ref-removed",
	}
)
View Source
var MembershipTypeGuest string = guest
View Source
var MembershipTypeManager string = manager
View Source
var MembershipTypeMember string = member
View Source
var MembershipTypeOwner string = owner
View Source
var (
	ProjectVisitor = &ProjectMember{}
)
View Source
var TaskTypeBuild string = "build"
View Source
var TaskTypeDeployment string = "deployment"
View Source
var TaskTypeScript string = "script"
View Source
var TaskTypeTest string = "test"
View Source
var WorkspaceBaseImageTypeContainer string = container

Functions

func IsNotFound

func IsNotFound(err error) bool

func MembershipTypeHierarchyLevel

func MembershipTypeHierarchyLevel(membershipType string) int

func RandomTotpSecret

func RandomTotpSecret() string

func RegisterBillingEvent

func RegisterBillingEvent(event BillingEventData)

func ValidateOrganization

func ValidateOrganization(u *Organization) error

TODO: Lh/DH Move this to a struct method

func ValidateProject

func ValidateProject(u *Project) error

func ValidateRepository

func ValidateRepository(u *Repository) error

func ValidateTarget

func ValidateTarget(t *Target) error

func ValidateUser

func ValidateUser(u *User) error

Types

type Activity

type Activity struct {
	// Id is a strictly monotonically increasing integer and
	// functions as a sequence number for ordering events.
	Id int `json:"id" db:"id"`

	// Name is used to disambiguate different activities.  Values
	// should follow the form:
	//
	//    ${OBJECT}.${EVENT}
	//
	// Examples:
	//
	//    operation.finished
	//    job.added
	Name string `json:"name" db:"name"`

	// OccurredOn is the time at which the activity has occurred.
	OccurredOn time.Time `json:"occurredOn" db:"occurred_on"`

	// CreatedAt is the time at which the activity has been
	// persisted.
	CreatedAt time.Time `json:"createdAt" db:"created_at"`

	// ContextUserUuid is the uuid of the user who caused the
	// activity.  For activities that are not triggered by a user,
	// this field is nil.
	ContextUserUuid *string `json:"contextUserUuid" db:"context_user_uuid"`

	// Payload is the context dependent data captured about the
	// activity.
	Payload interface{} `json:"payload" db:"payload"`

	// Extra is additional data added to the activity by various
	// processors of an activity.
	Extra map[string]interface{} `json:"extra" db:"extra"`
}

An activity is something that has been done, most of times by a user, sometimes by a program. An activity represents that an action has lead to a result and captures information about the action and the result.

func NewActivity

func NewActivity(id int, name string) *Activity

func (*Activity) Audience

func (self *Activity) Audience() []string

Audience returns a list of user ids that should be notified about this activity.

Usually it refers to all people having access to a project if the activity is emitted from something within a given project.

func (*Activity) JobUuid

func (self *Activity) JobUuid() string

JobUuid returns the uuid of the job this activity is associated with or the empty string if this activity is not associated with any job.

func (*Activity) ProjectUuid

func (self *Activity) ProjectUuid() string

ProjectUuid returns the uuid of the project this activity is associated with or the empty string if this activity is not associated with any project.

func (*Activity) SetAudience

func (self *Activity) SetAudience(audience []string) *Activity

func (*Activity) SetJobUuid

func (self *Activity) SetJobUuid(jobUuid string) *Activity

func (*Activity) SetProjectUuid

func (self *Activity) SetProjectUuid(projectUuid string) *Activity

func (*Activity) SubscriptionKey

func (self *Activity) SubscriptionKey() string

SubscriptionKey returns the key used for matching notification subscriptions against this activity. Usually this is the activity name.

type ActivityActor

type ActivityActor struct {
	Name string `json:"name"`
	Uuid string `json:"uuid"`
}

ActivityOnStream represents an activity as it is displayed on an activity stream.

type ActivityOnStream

type ActivityOnStream struct {
	Id         int            `json:"id"`
	UserUuid   string         `json:"userUuid"`
	Project    *ActivityActor `json:"project"`
	OccurredOn time.Time      `json:"occurredOn"`
	Actor      *ActivityActor `json:"actor"`
	Action     string         `json:"action"`
	Object     string         `json:"object"`
	Subject    *ActivityActor `json:"subject"`
	Unread     bool           `json:"unread"`
	// contains filtered or unexported fields
}

func (*ActivityOnStream) Embed

func (self *ActivityOnStream) Embed(k string, subject Subject)

func (*ActivityOnStream) Embedded

func (self *ActivityOnStream) Embedded() map[string][]Subject

func (*ActivityOnStream) FindUser

func (self *ActivityOnStream) FindUser(users UserStore) (*User, error)
func (self *ActivityOnStream) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*ActivityOnStream) OwnUrl

func (self *ActivityOnStream) OwnUrl(requestBase, requestScheme string) string

type Archiver

type Archiver interface {
	ArchiveByUuid(uuid string) error
}

type BasicRepositoryCredential

type BasicRepositoryCredential struct {
	*RepositoryCredential `json:"-"`
	Username              string `json:"username"`
	Password              string `json:"password"`
}

func AsBasicRepositoryCredential

func AsBasicRepositoryCredential(rc *RepositoryCredential) (*BasicRepositoryCredential, error)

func (*BasicRepositoryCredential) AsRepositoryCredential

func (self *BasicRepositoryCredential) AsRepositoryCredential() (*RepositoryCredential, error)

func (BasicRepositoryCredential) Embed

func (self BasicRepositoryCredential) Embed(k string, subject Subject)

func (BasicRepositoryCredential) Embedded

func (self BasicRepositoryCredential) Embedded() map[string][]Subject

type BillingCreditCardAdded

type BillingCreditCardAdded struct {
	// CreditCard is the credit card that has been added.
	CreditCard *CreditCard

	// UserUuid is the uuid of the user who added the card.
	UserUuid string

	// PaymentProviderName is the name of the payment provider at
	// which the card has been registered.
	PaymentProviderName string
}

func (*BillingCreditCardAdded) BillingEventName

func (self *BillingCreditCardAdded) BillingEventName() string

type BillingEvent

type BillingEvent struct {
	Uuid             string    `json:"uuid" db:"uuid"`
	EventName        string    `json:"eventName" db:"event_name"`
	OrganizationUuid string    `json:"organizationUuid" db:"organization_uuid"`
	OccurredOn       time.Time `json:"occurredOn" db:"occurred_on"`
	Data             BillingEventData
}

func NewBillingEvent

func NewBillingEvent(organizationUuid string, eventData BillingEventData) *BillingEvent

func (*BillingEvent) UnmarshalJSON

func (self *BillingEvent) UnmarshalJSON(data []byte) error

type BillingEventData

type BillingEventData interface {
	BillingEventName() string
}

func NewBillingEventDataByName

func NewBillingEventDataByName(eventName string) BillingEventData

type BillingExtraLimitsGranted

type BillingExtraLimitsGranted struct {
	// Number of addtional projects granted to the organization
	Projects int

	// Number of addtional users granted to the organization
	Users int

	// Uuid of the user granting those limits
	GrantedBy string

	// Reason for granting those limits
	Reason string
}

func (*BillingExtraLimitsGranted) BillingEventName

func (self *BillingExtraLimitsGranted) BillingEventName() string

type BillingHistory

type BillingHistory struct {
	Subscriptions map[string]*BillingPlanSubscription `json:"subscriptions"`

	// OrganizationToPlanUuids maps organization uuids to the plan
	// uuid of the most recent subscription created for that
	// organization.
	OrganizationToPlanUuids map[string]string `json:"organizationToPlanUuids"`

	// OrganizationUuidsToSubscriptions maps organization uuids to
	// the currently active subscription for the organization.
	OrganizationUuidsToSubscriptions map[string]string

	// OrganizationUuidsToCreditCards maps organization uuids to
	// credit cards registered for that organization.
	OrganizationUuidsToCreditCards map[string][]*CreditCard

	// OrganizationUuidsToExtraProjects maps organization uuids to
	// increases in project limits an organization should be
	// granted.
	OrganizationUuidsToExtraProjects map[string]int

	// OrganizationUuidsToExtraProjects maps organization uuids to
	// increases in user limits an organization should be granted.
	OrganizationUuidsToExtraUsers map[string]int

	// OrganizationUuidsToExtras maps organization uuids to a
	// history of discounts that have been applied to an
	// organization.
	OrganizationUuidsToExtras map[string][]*BillingEvent

	// Version is the time of the last event that has been
	// processed by this instance.
	Version time.Time `json:"version"`
}

func NewBillingHistory

func NewBillingHistory() *BillingHistory

func (*BillingHistory) CreditCardsFor

func (self *BillingHistory) CreditCardsFor(organizationUuid string) []*CreditCard

func (*BillingHistory) ExtraProjectsFor

func (self *BillingHistory) ExtraProjectsFor(organizationUuid string) int

func (*BillingHistory) ExtraUsersFor

func (self *BillingHistory) ExtraUsersFor(organizationUuid string) int

func (*BillingHistory) ExtrasGrantedTo

func (self *BillingHistory) ExtrasGrantedTo(organizationUuid string) []*BillingEvent

func (*BillingHistory) HandleEvent

func (self *BillingHistory) HandleEvent(event *BillingEvent)

HandleEvent ...

func (*BillingHistory) PlanUuidFor

func (self *BillingHistory) PlanUuidFor(organizationUuid string) string

func (*BillingHistory) Subscription

func (self *BillingHistory) Subscription(subscriptionId string) *BillingPlanSubscription

Subscription returns the billing plan subscription for the given id or nil if no such subscription exists.

func (*BillingHistory) SubscriptionFor

func (self *BillingHistory) SubscriptionFor(organizationUuid string) *BillingPlanSubscription

type BillingPlan

type BillingPlan struct {
	Uuid                   string `json:"uuid" db:"uuid"`
	Name                   string `json:"name" db:"name"`
	ProviderName           string `json:"providerName" db:"provider_name"`
	ProviderPlanId         string `json:"providerPlanId" db:"provider_plan_id"`
	PrivateCodeAvailable   bool   `json:"privateCodeAvailable" db:"private_code_available"`
	PricePerMonth          Money  `json:"pricePerMonth" db:"price_per_month"`
	UsersIncluded          int    `json:"usersIncluded" db:"users_included"`
	ProjectsIncluded       int    `json:"projectsIncluded" db:"projects_included"`
	PricePerAdditionalUser Money  `json:"pricePerAdditionalUser" db:"price_per_additional_user"`
	NumberOfConcurrentJobs int    `json:"numberOfConcurrentJobs" db:"number_of_concurrent_jobs"`
	// contains filtered or unexported fields
}

func NewBillingPlan

func NewBillingPlan(uuid string) *BillingPlan

func (*BillingPlan) Embed

func (self *BillingPlan) Embed(k string, subject Subject)

func (*BillingPlan) Embedded

func (self *BillingPlan) Embedded() map[string][]Subject

func (*BillingPlan) EnsureDefaultPrice

func (self *BillingPlan) EnsureDefaultPrice()
func (self *BillingPlan) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*BillingPlan) OwnUrl

func (self *BillingPlan) OwnUrl(requestScheme, requestBase string) string

func (*BillingPlan) ProjectsExceedingLimit

func (self *BillingPlan) ProjectsExceedingLimit(projects int) int

ProjectsExceedingLimit returns the number of projects by which projects exceeds the limits imposed by this plan.

func (*BillingPlan) UsersExceedingLimit

func (self *BillingPlan) UsersExceedingLimit(members int) int

UsersExceedingLimit returns the number of users by which members exceeds the limits imposed by this plan.

type BillingPlanSelected

type BillingPlanSelected struct {
	UserUuid               string
	PlanUuid               string
	PlanName               string
	SubscriptionId         string
	PrivateCodeAvailable   bool
	PricePerMonth          Money
	UsersIncluded          int
	ProjectsIncluded       int
	PricePerAdditionalUser Money
	NumberOfConcurrentJobs int
}

func (*BillingPlanSelected) BillingEventName

func (self *BillingPlanSelected) BillingEventName() string

func (*BillingPlanSelected) FillFromPlan

func (self *BillingPlanSelected) FillFromPlan(plan *BillingPlan)

type BillingPlanSubscription

type BillingPlanSubscription struct {
	Id               string `json:"id"`
	PlanUuid         string `json:"planUuid"`
	OrganizationUuid string `json:"organizationUuid"`
	UserUuid         string `json:"userUuid"`
	Status           string `json:"status"`
}

func NewBillingPlanSubscription

func NewBillingPlanSubscription() *BillingPlanSubscription

func (*BillingPlanSubscription) IsCancellable

func (self *BillingPlanSubscription) IsCancellable() bool

type BillingPlanSubscriptionChanged

type BillingPlanSubscriptionChanged struct {
	UserUuid       string
	SubscriptionId string
	PlanId         string
	Status         string
}

func (*BillingPlanSubscriptionChanged) BillingEventName

func (self *BillingPlanSubscriptionChanged) BillingEventName() string

type ChangedRepositoryRef

type ChangedRepositoryRef struct {
	RepositoryUuid string `json:"repositoryUuid"`
	Symbolic       string `json:"symbolic"`
	OldHash        string `json:"oldHash"`
	NewHash        string `json:"newHash"`
}

func (*ChangedRepositoryRef) FindProject

func (self *ChangedRepositoryRef) FindProject(projects ProjectStore) (*Project, error)

type CreditCard

type CreditCard struct {
	// IsDefault is set to true if the payment provider reports this
	// credit card as the default mode of payment.
	IsDefault bool `json:"isDefault"`

	CardholderName string `json:"cardholderName"`

	// SafeCardNumber is a truncated version of the credit card
	// number, safe for display purposes.
	SafeCardNumber string `json:"safeCardNumber"`

	// CardId identifies this card at the payment provider
	CardId string `json:"cardId"`

	// Token is a provider specific identifier for using this
	// credit card in transactions.
	Token string `json:"token"`
}

*

*
*  CAUTION!
*
*  This type is used withing billing events as well; only make
*  backwards compatible hchanges with regards to serialization:
*
*  - if you rename a field, keep the old name in the "json" tag
*  - do not remove fields, only add new fields
*
*

func NewCreditCard

func NewCreditCard(cardId string) *CreditCard

type Currency

type Currency string

func (Currency) String

func (self Currency) String() string

type DeliveredRequest

type DeliveredRequest struct {
	*http.Request
}

func (DeliveredRequest) MarshalJSON

func (self DeliveredRequest) MarshalJSON() ([]byte, error)

func (*DeliveredRequest) Scan

func (self *DeliveredRequest) Scan(value interface{}) error

func (DeliveredRequest) Value

func (self DeliveredRequest) Value() (driver.Value, error)

type Delivery

type Delivery struct {
	Uuid        string     `json:"uuid" db:"uuid"`
	WebhookUuid string     `json:"webhookUuid" db:"webhook_uuid"`
	DeliveredAt time.Time  `json:"deliveredAt" db:"delivered_at"`
	ArchivedAt  *time.Time `json:"archivedAt" db:"archived_at"`
	// The Schedule this Delivery triggered, optional
	ScheduleUuid *string          `json:"scheduleUuid" db:"schedule_uuid"`
	Request      DeliveredRequest `json:"request" db:"request"`
	// contains filtered or unexported fields
}

func (*Delivery) AuthorizationName

func (self *Delivery) AuthorizationName() string

func (*Delivery) Embed

func (self *Delivery) Embed(k string, subject Subject)

func (*Delivery) Embedded

func (self *Delivery) Embedded() map[string][]Subject

func (*Delivery) FindProject

func (self *Delivery) FindProject(projects ProjectStore) (*Project, error)

func (*Delivery) GitRef

func (self *Delivery) GitRef() string
func (self *Delivery) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*Delivery) OperationParameters

func (self *Delivery) OperationParameters(projectUuid string, repositories RepositoriesByName) *OperationParameters

func (*Delivery) OwnUrl

func (self *Delivery) OwnUrl(requestScheme, requestBase string) string

func (*Delivery) RepositoryName

func (self *Delivery) RepositoryName() string

type DeliveryStore

type DeliveryStore interface {
	FindByUuid(uuid string) (*Delivery, error)
}

type Dictionary

type Dictionary map[string]interface{}

Dictionary is a generic mapping for seamlessly storing JSON objects in the database.

func NewDictionary

func NewDictionary() Dictionary

func (Dictionary) Get

func (dictionary Dictionary) Get(key string) interface{}

Get returns the value associated with key in the dictionary or nil if no such value exists.

func (Dictionary) MarshalJSON

func (dictionary Dictionary) MarshalJSON() ([]byte, error)

func (*Dictionary) Scan

func (dictionary *Dictionary) Scan(data interface{}) error

func (Dictionary) Set

func (dictionary Dictionary) Set(key string, value interface{}) Dictionary

Set associates key with value in the dictionary.

func (*Dictionary) UnmarshalJSON

func (dictionary *Dictionary) UnmarshalJSON(data []byte) error

func (Dictionary) Value

func (dictionary Dictionary) Value() (driver.Value, error)

type EmailNotifier

type EmailNotifier struct {
	Uuid        string  `json:"uuid" db:"uuid"`
	Recipient   string  `json:"recipient" db:"recipient"`
	ProjectUuid *string `json:"projectUuid" db:"project_uuid"`
	UrlHost     string  `json:"urlHost" db:"url_host"`

	ArchivedAt *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func (*EmailNotifier) AuthorizationName

func (self *EmailNotifier) AuthorizationName() string

func (*EmailNotifier) Embed

func (self *EmailNotifier) Embed(k string, subject Subject)

func (*EmailNotifier) Embedded

func (self *EmailNotifier) Embedded() map[string][]Subject

func (*EmailNotifier) FindProject

func (self *EmailNotifier) FindProject(projects ProjectStore) (*Project, error)
func (self *EmailNotifier) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*EmailNotifier) OwnUrl

func (self *EmailNotifier) OwnUrl(requestScheme, requestBase string) string

func (*EmailNotifier) Validate

func (self *EmailNotifier) Validate() error

type Environment

type Environment struct {
	Uuid        string               `json:"uuid"`
	Name        string               `json:"name"`
	ProjectUuid string               `json:"projectUuid" db:"project_uuid"`
	IsDefault   bool                 `json:"-"  db:"is_default"`
	Variables   EnvironmentVariables `json:"variables"`
	ArchivedAt  *time.Time           `json:"archivedAt"  db:"archived_at"`
	CreatedAt   time.Time            `json:"-"`
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment(uuid string) *Environment

func (*Environment) AuthorizationName

func (self *Environment) AuthorizationName() string

func (*Environment) CreationDate

func (self *Environment) CreationDate() time.Time

func (*Environment) Embed

func (self *Environment) Embed(k string, subject Subject)

func (*Environment) Embedded

func (self *Environment) Embedded() map[string][]Subject

func (*Environment) Equal

func (self *Environment) Equal(b *Environment) bool

func (*Environment) FindProject

func (self *Environment) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Environment) Get

func (self *Environment) Get(variable string) string

func (*Environment) Id

func (self *Environment) Id() string
func (self *Environment) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Environment) NewSecret

func (self *Environment) NewSecret(name string, kind SecretType) *Secret

NewSecret returns a new secret associated with this environment

func (*Environment) OwnUrl

func (self *Environment) OwnUrl(requestScheme, requestBaseUri string) string

func (*Environment) PruneVariables

func (self *Environment) PruneVariables()

func (*Environment) Set

func (self *Environment) Set(variable, value string) *Environment

type EnvironmentSecret

type EnvironmentSecret struct {
	*Secret `json:"-"`
	Value   string
}

func AsEnvironmentSecret

func AsEnvironmentSecret(s *Secret) (*EnvironmentSecret, error)

func (*EnvironmentSecret) AsPrivileged

func (self *EnvironmentSecret) AsPrivileged() (*PrivilegedEnvironmentSecret, error)

func (*EnvironmentSecret) AsSecret

func (self *EnvironmentSecret) AsSecret() (*Secret, error)

func (*EnvironmentSecret) AsUnprivileged

func (self *EnvironmentSecret) AsUnprivileged() (*UnprivilegedEnvironmentSecret, error)

func (EnvironmentSecret) Embed

func (self EnvironmentSecret) Embed(k string, subject Subject)

func (EnvironmentSecret) Embedded

func (self EnvironmentSecret) Embedded() map[string][]Subject

type EnvironmentStore

type EnvironmentStore interface {
	FindByJobUuid(uuid string) (*Environment, error)
}

EnvironmentStore defines all the operations that are necessary for domain objects to fetch associated environment objects.

type EnvironmentVariable

type EnvironmentVariable struct {
	Name     string  `json:"name"`
	Value    string  `json:"value"`
	OldValue *string `json:"oldValue,omitempty"`
}

type EnvironmentVariableChanges

type EnvironmentVariableChanges struct {
	Added   []*EnvironmentVariable `json:"added"`
	Removed []*EnvironmentVariable `json:"removed"`
	Changed []*EnvironmentVariable `json:"changed"`
}

func NewEnvironmentVariableChanges

func NewEnvironmentVariableChanges() *EnvironmentVariableChanges

type EnvironmentVariables

type EnvironmentVariables struct {
	M map[string]string
}

func (EnvironmentVariables) Diff

func (*EnvironmentVariables) MarshalJSON

func (self *EnvironmentVariables) MarshalJSON() ([]byte, error)

func (*EnvironmentVariables) Scan

func (self *EnvironmentVariables) Scan(value interface{}) error

func (*EnvironmentVariables) UnmarshalJSON

func (self *EnvironmentVariables) UnmarshalJSON(data []byte) error

func (EnvironmentVariables) Value

func (self EnvironmentVariables) Value() (driver.Value, error)

type EventPayload

type EventPayload interface {
	Get(key string) string
}

type ExecutionsByTime

type ExecutionsByTime []*ScheduledExecution

sort.Interface

func (ExecutionsByTime) Len

func (a ExecutionsByTime) Len() int

func (ExecutionsByTime) Less

func (a ExecutionsByTime) Less(i, j int) bool

func (ExecutionsByTime) Swap

func (a ExecutionsByTime) Swap(i, j int)

type Feature

type Feature struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`
	// contains filtered or unexported fields
}

func NewFeaturesFromConfig

func NewFeaturesFromConfig(features config.Features) []*Feature

func (*Feature) Embed

func (self *Feature) Embed(k string, subject Subject)

func (*Feature) Embedded

func (self *Feature) Embedded() map[string][]Subject
func (self *Feature) Links(response map[string]map[string]string, requestScheme string, requestBaseUri string) map[string]map[string]string

func (*Feature) OwnUrl

func (self *Feature) OwnUrl(requestScheme string, requestBaseUri string) string

type GitLogEntry

type GitLogEntry struct {
	Commit      string   `json:"commit"`
	Author      string   `json:"author"`
	AuthorEmail string   `json:"authorEmail"`
	AuthorDate  ISODate  `json:"authorDate"`
	Parents     []string `json:"parents"`
	Subject     string   `json:"subject"`
	Body        string   `json:"body"`
}

type GitLogs

type GitLogs struct {
	Repositories map[string][]*GitLogEntry `json:"repositories"`
}

func NewGitLogs

func NewGitLogs() *GitLogs

func (*GitLogs) HandleEvent

func (self *GitLogs) HandleEvent(payload EventPayload)

func (*GitLogs) Scan

func (self *GitLogs) Scan(data interface{}) error

func (*GitLogs) Trim

func (self *GitLogs) Trim(maxLength int) *GitLogs

func (*GitLogs) Value

func (self *GitLogs) Value() (driver.Value, error)

type GitTrigger

type GitTrigger struct {
	Uuid string `json:"uuid" db:"uuid"`
	Name string `json:"name" db:"name"`

	ProjectUuid    string  `json:"projectUuid" db:"project_uuid"`
	JobUuid        string  `json:"jobUuid" db:"job_uuid"`
	RepositoryUuid *string `json:"repositoryUuid" db:"repository_uuid"`
	ChangeType     string  `json:"changeType" db:"change_type"`
	MatchRef       string  `json:"matchRef" db:"match_ref"`

	CreatorUuid string `json:"creatorUuid" db:"creator_uuid"`

	ArchivedAt *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func NewGitTrigger

func NewGitTrigger(name, creatorUuid string) *GitTrigger

func (*GitTrigger) AuthorizationName

func (self *GitTrigger) AuthorizationName() string

func (*GitTrigger) Embed

func (self *GitTrigger) Embed(k string, subject Subject)

func (*GitTrigger) Embedded

func (self *GitTrigger) Embedded() map[string][]Subject

func (*GitTrigger) FindProject

func (self *GitTrigger) FindProject(store ProjectStore) (*Project, error)

func (*GitTrigger) ForChangeType

func (self *GitTrigger) ForChangeType(changeType string) *GitTrigger

func (*GitTrigger) ForJob

func (self *GitTrigger) ForJob(jobUuid string) *GitTrigger

func (*GitTrigger) InProject

func (self *GitTrigger) InProject(projectUuid string) *GitTrigger

func (*GitTrigger) InRepository

func (self *GitTrigger) InRepository(repositoryUuid string) *GitTrigger
func (self *GitTrigger) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*GitTrigger) Match

func (self *GitTrigger) Match(activity *Activity) bool

Match returns true if this trigger should fire for the given activity.

func (*GitTrigger) MatchingRef

func (self *GitTrigger) MatchingRef(refspec string) *GitTrigger

func (*GitTrigger) OwnUrl

func (self *GitTrigger) OwnUrl(requestScheme, requestBase string) string

func (*GitTrigger) Validate

func (self *GitTrigger) Validate() error

type ISODate

type ISODate time.Time

func (ISODate) MarshalJSON

func (self ISODate) MarshalJSON() ([]byte, error)

func (*ISODate) UnmarshalJSON

func (self *ISODate) UnmarshalJSON(data []byte) error

type Invitation

type Invitation struct {
	Uuid             string     `json:"uuid" db:"uuid"`
	RecipientName    string     `json:"recipientName" db:"recipient_name"`
	Email            string     `json:"email" db:"email"`
	OrganizationUuid string     `json:"organizationUuid" db:"organization_uuid"`
	ProjectUuid      string     `json:"projectUuid" db:"project_uuid"`
	MembershipType   string     `json:"membershipType" db:"membership_type"`
	CreatorUuid      string     `json:"creatorUuid" db:"creator_uuid"`
	CreatedAt        time.Time  `json:"createdAt" db:"created_at"`
	SentAt           *time.Time `json:"sentAt" db:"sent_at"`
	AcceptedAt       *time.Time `json:"acceptedAt" db:"accepted_at"`
	RefusedAt        *time.Time `json:"refusedAt" db:"refused_at"`
	InviteeUuid      string     `json:"inviteeUuid" db:"invitee_uuid"`
	Message          string     `json:"message" db:"message"`
	ArchivedAt       *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func (*Invitation) Accept

func (self *Invitation) Accept(invitee *User)

Accept marks the invitation as accepted. The current time is used for recording the time of accepting the invitation.

func (*Invitation) AuthorizationName

func (self *Invitation) AuthorizationName() string

func (*Invitation) CallToActionPath

func (self *Invitation) CallToActionPath(users UserStore) string

CallToActionPath returns the URL path for the page on which the invitee can react to this invitation.

func (*Invitation) Embed

func (self *Invitation) Embed(k string, subject Subject)

func (*Invitation) Embedded

func (self *Invitation) Embedded() map[string][]Subject

func (*Invitation) FindOrganization

func (self *Invitation) FindOrganization(store OrganizationStore) (*Organization, error)

FindOrganization satisfies authz.BelongsToOrganization

func (*Invitation) FindProject

func (self *Invitation) FindProject(store ProjectStore) (*Project, error)

FindProject satifies authz.BelongsToProject to determine access to project level invitations.

func (*Invitation) FindUser

func (self *Invitation) FindUser(store UserStore) (*User, error)

FindUser satisfies authz.BelongsToUser by looking for the invitation's recipient (who might not exist yet).

func (*Invitation) IsAccepted

func (self *Invitation) IsAccepted() bool

IsAccepted returns true if the invitation has been marked as accepted.

func (*Invitation) IsOpen

func (self *Invitation) IsOpen() bool

IsOpen returns true if the invitation can still be responded to, i.e. whether it can still be accepted or refused.

func (*Invitation) IsRefused

func (self *Invitation) IsRefused() bool

IsRefused returns true if the invitation has been marked as refused.

func (self *Invitation) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Invitation) NewProjectMembership

func (self *Invitation) NewProjectMembership() *ProjectMembership

NewProjectMembership returns the new project membership that should be created when accepting this invitation.

func (*Invitation) OwnUrl

func (self *Invitation) OwnUrl(requestScheme, requestBaseUri string) string

func (*Invitation) OwnedBy

func (self *Invitation) OwnedBy(user *User) bool

OwnedBy satisfies authz.Ownable by looking at the creator of the invitation.

func (*Invitation) Refuse

func (self *Invitation) Refuse()

Refuse marks the invitation as refused. The current time is usd for recording the time of refusing the invitation.

func (*Invitation) Validate

func (self *Invitation) Validate() error

type InvitationStore

type InvitationStore interface {
	FindByUserAndProjectUuid(userId, projectId string) (*Invitation, error)
}

type Job

type Job struct {
	Uuid            string     `json:"uuid"`
	CreatedAt       time.Time  `json:"createdAt"       db:"created_at"`
	Name            string     `json:"name"`
	Description     *string    `json:"description"     db:"description"`
	TaskUuid        string     `json:"taskUuid"        db:"task_uuid"`
	EnvironmentUuid string     `json:"environmentUuid" db:"environment_uuid"`
	ArchivedAt      *time.Time `json:"archivedAt"      db:"archived_at"`

	// makes the job widget much easier to implement
	ProjectUuid      string     `json:"projectUuid" db:"project_uuid"`
	ProjectName      string     `json:"projectName" db:"project_name"`
	LastRunStartedAt *time.Time `json:"lastRunStartedAt"`
	LastRunCreatedAt *time.Time `json:"lastRunCreatedAt"`
	Runs             []string   `json:"runs"`
	// contains filtered or unexported fields
}

func (*Job) AuthorizationName

func (self *Job) AuthorizationName() string

func (*Job) CreationDate

func (self *Job) CreationDate() time.Time

func (*Job) Embed

func (self *Job) Embed(k string, subject Subject)

func (*Job) Embedded

func (self *Job) Embedded() map[string][]Subject

func (*Job) FindProject

func (self *Job) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Job) FindRecentOperations

func (self *Job) FindRecentOperations(operations RecentOperations) error

func (*Job) Id

func (self *Job) Id() string
func (self *Job) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Job) NewJobNotifier

func (self *Job) NewJobNotifier() *JobNotifier

NewJobNotifier returns a new job notifier which triggers this job.

func (*Job) NewOperation

func (self *Job) NewOperation(wsbiUuid string) *Operation

NewOperation constructs a new operation for running this job.

func (*Job) NewRecurringSchedule

func (self *Job) NewRecurringSchedule(initiatorUuid string, cronexpr string) *Schedule

NewRecurringSchedule returns a recurring schedule for this job, using the given cronexpr for scheduling runs of this job.

func (*Job) OwnUrl

func (self *Job) OwnUrl(requestScheme, requestBaseUri string) string

func (*Job) WatchableEvents

func (self *Job) WatchableEvents() []string

func (*Job) WatchableType

func (self *Job) WatchableType() string

type JobNotifier

type JobNotifier struct {
	Uuid       string `json:"uuid" db:"uuid"`
	WebhookURL string `json:"webhookURL" db:"webhook_url"`

	ArchivedAt *time.Time `json:"archivedAt" db:"archived_at"`

	ProjectUuid string `json:"projectUuid" db:"project_uuid"`
	JobUuid     string `json:"jobUuid" db:"job_uuid"`
	JobName     string `json:"jobName" db:"job_name"`
	// contains filtered or unexported fields
}

func (*JobNotifier) AuthorizationName

func (self *JobNotifier) AuthorizationName() string

func (*JobNotifier) Embed

func (self *JobNotifier) Embed(k string, subject Subject)

func (*JobNotifier) Embedded

func (self *JobNotifier) Embedded() map[string][]Subject

func (*JobNotifier) FindProject

func (self *JobNotifier) FindProject(projects ProjectStore) (*Project, error)
func (self *JobNotifier) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*JobNotifier) OwnUrl

func (self *JobNotifier) OwnUrl(requestScheme, requestBase string) string

func (*JobNotifier) Validate

func (self *JobNotifier) Validate() error

func (*JobNotifier) WebhookSlug

func (self *JobNotifier) WebhookSlug() string

type JobOperationVars

type JobOperationVars struct {
	// Body contains the body of the script to execute.  It is
	// expected to be directly executable using `exec`.
	Body string
}

JobOperationVars holds the necessary information for the template producing the shell script to run a job operation.

type JobStore

type JobStore interface {
	FindByUuid(uuid string) (*Job, error)
}

type Limits

type Limits struct {
	OrganizationUuid    string                `json:"organizationUuid"`
	Projects            int                   `json:"projects"`
	Members             int                   `json:"members"`
	PublicRepositories  int                   `json:"publicRepositories"`
	PrivateRepositories int                   `json:"privateRepositories"`
	TrialDaysLeft       int                   `json:"trialDaysLeft"`
	TrialEnabled        bool                  `json:"trialEnabled"`
	Version             time.Time             `json:"version"`
	Plan                *LimitsComparedToPlan `json:"plan"`
	// contains filtered or unexported fields
}

func (*Limits) AuthorizationName

func (self *Limits) AuthorizationName() string

func (*Limits) Embed

func (self *Limits) Embed(k string, subject Subject)

func (*Limits) Embedded

func (self *Limits) Embedded() map[string][]Subject

func (*Limits) Exceeded

func (self *Limits) Exceeded() bool

func (*Limits) FindOrganization

func (self *Limits) FindOrganization(organizations OrganizationStore) (*Organization, error)

func (*Limits) FindProject

func (self *Limits) FindProject(store ProjectStore) (*Project, error)
func (self *Limits) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Limits) MarshalJSON

func (self *Limits) MarshalJSON() ([]byte, error)

func (*Limits) OwnUrl

func (self *Limits) OwnUrl(requestScheme, requestBaseUri string) string

type LimitsComparedToPlan

type LimitsComparedToPlan struct {
	UsersExceedingLimit           int  `json:"usersExceedingLimit"`
	ProjectsExceedingLimit        int  `json:"projectsExceedingLimit"`
	RequiresUpgradeForPrivateCode bool `json:"requiresUpgradeForPrivateCode"`
	UsersIncluded                 int  `json:"usersIncluded"`
	ProjectsIncluded              int  `json:"projectsIncluded"`
}

type LogLine

type LogLine struct {
	Seq int    `json:"seq"` // the line number
	Msg string `json:"msg"` // the line, without trailing \n
}

func LogLinesFromFile

func LogLinesFromFile(file *os.File) []*LogLine

func LogLinesFromSlice

func LogLinesFromSlice(slice []string, offset int) []*LogLine

func MustUnmarshalLogLine

func MustUnmarshalLogLine(j []byte) *LogLine

func NewLogLine

func NewLogLine(seq int, msg string) *LogLine

func (*LogLine) IsInternal

func (self *LogLine) IsInternal() bool

func (*LogLine) MustMarshal

func (self *LogLine) MustMarshal() []byte

type LogSubscription

type LogSubscription struct {
	Command       int
	OperationUuid string
	LineSeq       int
}

type Loggable

type Loggable struct {
	Uuid     string     `json:"uuid"` // Actually, this is the operation's uuid
	LogLines []*LogLine `json:"logLines"`
	Status   int        `json:"status"`
	// contains filtered or unexported fields
}

func MustUnmarshalLoggable

func MustUnmarshalLoggable(j []byte) *Loggable

func NewLoggable

func NewLoggable(uuid string, logLines []*LogLine, status int) *Loggable

func (*Loggable) AuthorizationName

func (self *Loggable) AuthorizationName() string

func (*Loggable) Embed

func (self *Loggable) Embed(k string, subject Subject)

func (*Loggable) Embedded

func (self *Loggable) Embedded() map[string][]Subject
func (self *Loggable) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Loggable) MustMarshal

func (self *Loggable) MustMarshal() []byte

func (*Loggable) OwnUrl

func (self *Loggable) OwnUrl(requestScheme, requestBaseUri string) string

func (*Loggable) Wrap

func (self *Loggable) Wrap() *LoggableWrapper

type LoggableWrapper

type LoggableWrapper struct {
	Subject Loggable                     `json:"subject"`
	Links   map[string]map[string]string `json:"_links"`
}

resembles a HAL type

type MapPayload

type MapPayload map[string]string

func (MapPayload) Get

func (self MapPayload) Get(key string) string

type Money

type Money struct {
	Amount   int
	Currency Currency
}

func (Money) Cents

func (self Money) Cents() int

func (Money) Equal

func (self Money) Equal(other *Money) bool

func (Money) MarshalJSON

func (self Money) MarshalJSON() ([]byte, error)

func (*Money) Scan

func (self *Money) Scan(src interface{}) error

func (Money) String

func (self Money) String() string

func (*Money) UnmarshalJSON

func (self *Money) UnmarshalJSON(src []byte) error

func (Money) Value

func (self Money) Value() interface{}

func (Money) Whole

func (self Money) Whole() int

type NotFoundError

type NotFoundError struct{}

func (NotFoundError) Error

func (nfe NotFoundError) Error() string

type NotificationRule

type NotificationRule struct {
	Uuid          string     `json:"uuid" db:"uuid"`
	ProjectUuid   string     `json:"projectUuid" db:"project_uuid"`
	NotifierUuid  string     `json:"notifierUuid" db:"notifier_uuid"`
	NotifierType  string     `json:"notifierType" db:"notifier_type"`
	MatchActivity string     `json:"matchActivity" db:"match_activity"`
	CreatorUuid   string     `json:"creatorUuid" db:"creator_uuid"`
	JobUuid       *string    `json:"jobUuid" db:"job_uuid"`
	ArchivedAt    *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func (*NotificationRule) AppliesToJob

func (self *NotificationRule) AppliesToJob(jobUuid string) bool

func (*NotificationRule) AuthorizationName

func (self *NotificationRule) AuthorizationName() string

func (*NotificationRule) Embed

func (self *NotificationRule) Embed(k string, subject Subject)

func (*NotificationRule) Embedded

func (self *NotificationRule) Embedded() map[string][]Subject

func (*NotificationRule) FindProject

func (self *NotificationRule) FindProject(projects ProjectStore) (*Project, error)
func (self *NotificationRule) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*NotificationRule) Matches

func (self *NotificationRule) Matches(activity *Activity) bool

func (*NotificationRule) OwnUrl

func (self *NotificationRule) OwnUrl(requestScheme, requestBase string) string

func (*NotificationRule) Validate

func (self *NotificationRule) Validate() error

type OAuthToken

type OAuthToken struct {
	Uuid        string     `json:"uuid"`
	UserUuid    string     `json:"userUuid"    db:"user_uuid"`
	Provider    string     `json:"provider"`
	Scope       string     `json:"scope"       db:"scopes"`
	AccessToken string     `json:"accessToken" db:"access_token"`
	TokenType   string     `json:"tokenType"   db:"token_type"`
	CreatedAt   *time.Time `json:"createdAt"   db:"created_at"`
	// contains filtered or unexported fields
}

func (*OAuthToken) AuthorizationName

func (self *OAuthToken) AuthorizationName() string

func (*OAuthToken) Embed

func (self *OAuthToken) Embed(k string, subject Subject)

func (*OAuthToken) Embedded

func (self *OAuthToken) Embedded() map[string][]Subject
func (self *OAuthToken) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*OAuthToken) OwnUrl

func (self *OAuthToken) OwnUrl(requestScheme, requestBaseUri string) string

func (*OAuthToken) OwnedBy

func (self *OAuthToken) OwnedBy(user *User) bool

OwnedBy satisfies authz.Ownable by identifying the user for which this OAuth token is valid.

type Operation

type Operation struct {
	Uuid                   string     `json:"uuid"`
	Type                   string     `json:"type"`
	RepositoryUuid         *string    `json:"repositoryUuid"         db:"repository_uuid"`
	JobUuid                *string    `json:"jobUuid"                db:"job_uuid"`
	NotifierUuid           *string    `json:"notifierUuid"           db:"notifier_uuid"`
	NotifierType           *string    `json:"notifierType"           db:"notifier_type"`
	WorkspaceBaseImageUuid string     `json:"workspaceBaseImageUuid" db:"workspace_base_image_uuid"`
	TimeLimit              int        `json:"timeLimitSecs"          db:"time_limit"`
	VisibleTo              string     `json:"-"                      db:"visible_to"`
	ExitStatus             int        `json:"exitStatus"             db:"exit_status"`
	CreatedAt              *time.Time `json:"createdAt"              db:"created_at"`
	StartedAt              *time.Time `json:"startedAt"              db:"started_at"`
	FinishedAt             *time.Time `json:"finishedAt"             db:"finished_at"`
	ArchivedAt             *time.Time `json:"archivedAt"             db:"archived_at"`
	FailedAt               *time.Time `json:"failedAt"               db:"failed_at"`
	TimedOutAt             *time.Time `json:"timedOutAt"             db:"timed_out_at"`
	CanceledAt             *time.Time `json:"canceledAt"             db:"canceled_at"`
	FatalError             *string    `json:"fatalError"             db:"fatal_error"`

	Parameters *OperationParameters `json:"parameters" db:"parameters"`

	RepositoryCheckouts *RepositoryCheckouts `json:"repositoryCheckouts" db:"repository_refs"`

	GitLogs *GitLogs `json:"gitLogs" db:"git_logs"`

	StatusLogs *StatusLogs `json:"statusLogs" db:"status_logs"`

	LogEvents []*logevent.Message `json:"logEvents" db:"-"`
	// contains filtered or unexported fields
}

NOTE(dh): This should probably be split into separate types (JobOperation, RepositoryOperation, ...) once a new operation type is added. Distinguishing operations by the value of their `Type` field seems to work for now, because there are only two cases.

func (*Operation) AddLogEvent

func (self *Operation) AddLogEvent(e *logevent.Message)

func (*Operation) AuthorizationName

func (self *Operation) AuthorizationName() string

func (*Operation) Category

func (self *Operation) Category() string

Category returns the broader category an operation belongs into based on its type. For example, the category of OperationTypeGit* operations is "repository". If the type cannot be mapped to a category, "unknown" is returned.

func (*Operation) Embed

func (self *Operation) Embed(k string, subject Subject)

func (*Operation) Embedded

func (self *Operation) Embedded() map[string][]Subject

func (*Operation) Environment

func (self *Operation) Environment(store EnvironmentStore) (*Environment, error)

Environment returns the environment in which the operation runs. If the operation is not associated with an environment (such as a Git repository access check), nil is returned. Any errors returned are from store.

func (*Operation) FindJob

func (self *Operation) FindJob(store JobStore) (*Job, error)

func (*Operation) FindProject

func (self *Operation) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Operation) FindWorkspaceBaseImage

func (self *Operation) FindWorkspaceBaseImage(store WorkspaceBaseImageStore) (*WorkspaceBaseImage, error)

FindWorkspaceBaseImage returns the workspace base image that should be used for running this operation.

func (*Operation) HandleEvent

func (self *Operation) HandleEvent(payload EventPayload)

func (*Operation) IsGitAccessCheck

func (self *Operation) IsGitAccessCheck() bool

func (*Operation) IsGitMetadataCollect

func (self *Operation) IsGitMetadataCollect() bool

func (*Operation) IsReady

func (self *Operation) IsReady(repos RepositoryStore, credentials RepositoryCredentialStore, envs EnvironmentStore, secrets SecretStore) (bool, error)

func (*Operation) IsUserJob

func (self *Operation) IsUserJob() bool
func (self *Operation) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Operation) NewScriptVars

func (self *Operation) NewScriptVars(tasks TaskStore, repositories RepositoryStore) (interface{}, error)

func (*Operation) NewSetupScriptCtxt

func (self *Operation) NewSetupScriptCtxt(wsbi *WorkspaceBaseImage, project *Project) (*OperationSetupScriptCtxt, error)

NewSetupScriptCtxt returns the setup script context necessary for running this operation.

func (*Operation) OwnUrl

func (self *Operation) OwnUrl(requestScheme, requestBaseUri string) string

func (*Operation) Repositories

func (self *Operation) Repositories(store RepositoryStore) ([]*Repository, error)

Repositories returns the list of repositories that will be used when running this operation. If the operation doesn't require any repositories to exist (such as a repository access check operation), then an empty slice of repositories and no error is returned. Otherwise any error returned originates from store.

func (*Operation) Secrets

func (self *Operation) Secrets(es EnvironmentStore, ss SecretStore) ([]*Secret, error)

Secrets returns the secrets that are associated to this Operation.

func (*Operation) ShieldsIoStatusColorAndParams

func (self *Operation) ShieldsIoStatusColorAndParams() (string, string)

func (*Operation) Status

func (self *Operation) Status() string

func (*Operation) Successful

func (self *Operation) Successful() bool

func (*Operation) Task

func (self *Operation) Task(store TaskStore) (*Task, error)

Task returns the task which is used for running this operation.

If the operation is not associated with a task, nil is returned. Any errors returned are from store.

func (*Operation) UuidBigInt

func (self *Operation) UuidBigInt() big.Int

type OperationParameters

type OperationParameters struct {
	// Checkout is a map of repository uuids to git references
	// that should be checked out before running an operation.
	Checkout map[string]string `json:"checkout"`

	// Reason is the reason for why this operation was triggered.
	Reason OperationTriggerReason `json:"reason"`

	// Username is the name of the user who triggered the
	// operation.
	Username string `json:"username,omitempty"`
	// UserUuid is the uuid of the user who triggered the
	// operation.
	UserUuid string `json:"userUuid,omitempty"`

	// ScheduleDescription is the description of the schedule which triggered
	// this operation.
	ScheduleDescription string `json:"scheduleDescription,omitempty"`

	// ScheduleUuid is the uuid of the schedule that triggered the
	// operation.
	ScheduleUuid string `json:"scheduleUuid,omitempty"`

	// TriggeredByDelivery is the uuid of the delivery that
	// triggered this operation.
	TriggeredByDelivery string `json:"triggeredByDelivery"`

	// TriggeredByGitTrigger is the uuid of the Git trigger that
	// triggered this operation.
	TriggeredByGitTrigger string `json:"triggeredByGitTrigger"`

	// GitTriggerName is the name of the Git trigger that
	// triggered this operation.
	GitTriggerName string `json:"gitTriggerName"`

	// TriggeredByNotificationRule is the uuid of the notification
	// rule that triggered this operation.
	TriggeredByNotificationRule string `json:"triggeredByNotificationRule"`

	// TriggeredByActivityId is the id of the activity that
	// triggered this operation.
	TriggeredByActivityId int `json:"triggeredByActivityId"`

	// Environment specifies a new environment that should be used
	// instead of the one specified by the job.
	Environment *Environment `json:"environment"`

	// Task specifies a new task that should be used instead of
	// the one specified by the job.
	Task *Task `json:"task"`

	// Secrets specifies new secrets that should be used instead
	// of the ones specified by the environment.
	Secrets []*OperationSecret `json:"secrets"`
}

func NewOperationParameters

func NewOperationParameters() *OperationParameters

func (*OperationParameters) AddSecret

func (self *OperationParameters) AddSecret(name, value string) *OperationParameters

func (*OperationParameters) Init

func (*OperationParameters) Scan

func (self *OperationParameters) Scan(from interface{}) error

func (*OperationParameters) Value

func (self *OperationParameters) Value() (driver.Value, error)

type OperationSecret

type OperationSecret struct {
	Name     string  `json:"name"`
	Value    string  `json:"value"`
	OldValue *string `json:"oldValue,omitempty"`
}

type OperationSetupScriptCtxt

type OperationSetupScriptCtxt struct {
	// Operation is the operation for which this script runs
	Operation *Operation

	// Keys is a list of SSH key pairs that need to be present in the
	// workspace for cloning any repositories before running an operation.
	Keys []*keyPair

	// Repositories is the list of repositories that are related to this
	// operation.
	Repositories []*Repository
	SshConfigs   []*sshConfig

	// Parameters are operation-specific parameters that change
	// the state in which an operation runs.
	Parameters *OperationParameters

	// PreviousOperation is the last completed operation that ran
	// before this operation.  This can be nil if there is no such
	// operation.
	PreviousOperation *Operation

	// WebhookBody is the body of the request that triggered this
	// operation via a webhook.  If this operation has not been
	// triggered through a webhook, WebhookBody is nil.
	WebhookBody []byte

	// If the related repositories should be cloned.  If false, only the
	// deploy keys will be written.
	ShouldCloneRepos bool

	// Environment is the environment in which the operation runs.  This
	// value is used to define and export any necessary environment
	// variables before running the operation's user script.
	Environment *Environment

	// Secrets holds the EnvironmentSecrets for this job. They are being
	// exported as environment variables as well.
	Secrets []*EnvironmentSecret

	// WsbiName is the name of the docker workspace base image.
	// Operations are run in a docker container using this image.
	WsbiName string

	// WsbiRepository is the url of the git repository from where
	// the workspace base image can be obtained with "git clone".
	WsbiRepository string

	// WsbiPath is the path to change to within the repository for
	// workspace base images before invoking "make" to build the image.
	WsbiPath string
}

func (*OperationSetupScriptCtxt) AddKey

func (vars *OperationSetupScriptCtxt) AddKey(belongsTo, name, private, public string) *OperationSetupScriptCtxt

func (*OperationSetupScriptCtxt) AddSshConfig

func (vars *OperationSetupScriptCtxt) AddSshConfig(repository *Repository, repostioryCredential *RepositoryCredential) *OperationSetupScriptCtxt

func (*OperationSetupScriptCtxt) LoadPreviousOperation

func (self *OperationSetupScriptCtxt) LoadPreviousOperation(operations OperationStore) error

func (*OperationSetupScriptCtxt) LoadWebhookBody

func (self *OperationSetupScriptCtxt) LoadWebhookBody(deliveries DeliveryStore) error

type OperationStore

type OperationStore interface {
	MarkExitStatus(operationUuid string, exitStatus int) error
	FindPreviousOperation(currentOperationUuid string) (*Operation, error)
}

type OperationTriggerReason

type OperationTriggerReason string
const (
	OperationTriggeredByWebhook          OperationTriggerReason = "webhook"
	OperationTriggeredBySchedule         OperationTriggerReason = "schedule"
	OperationTriggeredByUser             OperationTriggerReason = "user"
	OperationTriggeredByGitTrigger       OperationTriggerReason = "git-trigger"
	OperationTriggeredByNotificationRule OperationTriggerReason = "notification-rule"
)

func (OperationTriggerReason) String

func (self OperationTriggerReason) String() string

type Organization

type Organization struct {
	Uuid        string     `json:"uuid"`
	Name        string     `json:"name"`
	GithubLogin string     `json:"githubLogin"  db:"github_login"`
	Public      bool       `json:"public"`
	CreatedAt   time.Time  `json:"createdAt"    db:"created_at"`
	ArchivedAt  *time.Time `json:"archivedAt"   db:"archived_at"`
	// contains filtered or unexported fields
}

func (*Organization) AuthorizationName

func (self *Organization) AuthorizationName() string

func (*Organization) CreationDate

func (self *Organization) CreationDate() time.Time

CreationDate returns the date on which this organization was created.

func (*Organization) DeletionDate

func (self *Organization) DeletionDate() time.Time

func (*Organization) Embed

func (self *Organization) Embed(k string, subject Subject)

func (*Organization) Embedded

func (self *Organization) Embedded() map[string][]Subject

func (*Organization) FindOrganization

func (self *Organization) FindOrganization(store OrganizationStore) (*Organization, error)

func (*Organization) FindProject

func (self *Organization) FindProject(store ProjectStore) (*Project, error)

func (*Organization) Id

func (self *Organization) Id() string
func (self *Organization) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Organization) NewBillingEvent

func (self *Organization) NewBillingEvent(data BillingEventData) *BillingEvent

func (*Organization) OwnUrl

func (self *Organization) OwnUrl(requestScheme, requestBaseUri string) string

type OrganizationMember

type OrganizationMember struct {
	*User
	MembershipType   string `json:"type" db:"membership_type"`
	OrganizationUuid string `json:"organizationUuid" db:"organization_uuid"`
	// contains filtered or unexported fields
}

OrganizationMember augments the data from user with information about a user's membership with a given organization.

func NewOrganizationMember

func NewOrganizationMember(user *User, membership *OrganizationMembership) *OrganizationMember

func (*OrganizationMember) AuthorizationName

func (self *OrganizationMember) AuthorizationName() string

func (*OrganizationMember) Capabilities

func (self *OrganizationMember) Capabilities() []string

func (*OrganizationMember) Embed

func (self *OrganizationMember) Embed(k string, subject Subject)

func (*OrganizationMember) Embedded

func (self *OrganizationMember) Embedded() map[string][]Subject

func (*OrganizationMember) FindOrganization

func (self *OrganizationMember) FindOrganization(organizations OrganizationStore) (*Organization, error)

FindOrganization satisfies authz.BelongsToOrganization by finding the organizing this member belongs to.

func (*OrganizationMember) FindUser

func (self *OrganizationMember) FindUser(users UserStore) (*User, error)
func (self *OrganizationMember) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*OrganizationMember) OwnUrl

func (self *OrganizationMember) OwnUrl(requestScheme, requestBase string) string

func (*OrganizationMember) OwnedBy

func (self *OrganizationMember) OwnedBy(user *User) bool

type OrganizationMembership

type OrganizationMembership struct {
	OrganizationUuid string    `json:"organizationUuid" db:"organization_uuid"`
	UserUuid         string    `json:"userUuid"         db:"user_uuid"`
	Type             string    `json:"type"`
	CreatedAt        time.Time `json:"createdAt"        db:"created_at"`
	// contains filtered or unexported fields
}

func (*OrganizationMembership) AuthorizationName

func (self *OrganizationMembership) AuthorizationName() string

func (*OrganizationMembership) Embed

func (self *OrganizationMembership) Embed(k string, subject Subject)

func (*OrganizationMembership) Embedded

func (self *OrganizationMembership) Embedded() map[string][]Subject

func (*OrganizationMembership) FindOrganization

func (self *OrganizationMembership) FindOrganization(organizations OrganizationStore) (*Organization, error)

func (*OrganizationMembership) FindUser

func (self *OrganizationMembership) FindUser(users UserStore) (*User, error)
func (self *OrganizationMembership) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*OrganizationMembership) OwnUrl

func (self *OrganizationMembership) OwnUrl(requestScheme, requestBaseUri string) string

func (*OrganizationMembership) OwnedBy

func (self *OrganizationMembership) OwnedBy(user *User) bool

type OrganizationStore

type OrganizationStore interface {
	FindByUuid(uuid string) (*Organization, error)
	FindByProjectUuid(uuid string) (*Organization, error)
}

OrganizationStore defines all the operations that are necessary for the domain to fetch associated organization objects.

type Person

type Person struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type PrivilegedEnvironmentSecret

type PrivilegedEnvironmentSecret struct {
	*UnprivilegedEnvironmentSecret
	Value string `json:"value"`
}

PrivilegedEnvironmentSecret is meant for transport to privileged clients (i.e. project owners), and contains the Value

func (PrivilegedEnvironmentSecret) Embed

func (self PrivilegedEnvironmentSecret) Embed(k string, subject Subject)

func (PrivilegedEnvironmentSecret) Embedded

func (self PrivilegedEnvironmentSecret) Embedded() map[string][]Subject

type PrivilegedSshSecret

type PrivilegedSshSecret struct {
	*UnprivilegedSshSecret
	PrivateKey string `json:"privateKey"`
}

PrivilegedSshSecret is meant for transport to privileged clients (i.e. project owners), and decodes both public and private keys

func (PrivilegedSshSecret) Embed

func (self PrivilegedSshSecret) Embed(k string, subject Subject)

func (PrivilegedSshSecret) Embedded

func (self PrivilegedSshSecret) Embedded() map[string][]Subject

type Project

type Project struct {
	Uuid             string     `json:"uuid"`
	OrganizationUuid string     `json:"organizationUuid" db:"organization_uuid"`
	Name             string     `json:"name"`
	Public           bool       `json:"public"`
	CreatedAt        time.Time  `json:"createdAt"        db:"created_at"`
	ArchivedAt       *time.Time `json:"archivedAt"       db:"archived_at"`
	// contains filtered or unexported fields
}

func (*Project) AuthorizationName

func (self *Project) AuthorizationName() string

func (*Project) CreationDate

func (self *Project) CreationDate() time.Time

func (*Project) DeletionDate

func (self *Project) DeletionDate() time.Time

func (*Project) Embed

func (self *Project) Embed(k string, subject Subject)

func (*Project) Embedded

func (self *Project) Embedded() map[string][]Subject

func (*Project) FindOrganization

func (self *Project) FindOrganization(store OrganizationStore) (*Organization, error)

FindOrganization satisfies authz.BelongsToOrganization in order to determine authorization.

func (*Project) FindProject

func (self *Project) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Project) Id

func (self *Project) Id() string
func (self *Project) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Project) NewDefaultEnvironment

func (self *Project) NewDefaultEnvironment() *Environment

func (*Project) NewEmailNotifier

func (self *Project) NewEmailNotifier(recipient, urlHost string) *EmailNotifier

NewEmailNotifier returns a new email notifier for the given recipient address and url host in this project.

func (*Project) NewEnvironment

func (self *Project) NewEnvironment(name string) *Environment

NewEnvironment constructs a new environment object for this project.

func (*Project) NewGitTrigger

func (self *Project) NewGitTrigger(name, creatorUuid, jobUuid string) *GitTrigger

NewGitTrigger returns a new git trigger in this project which fires on changes to master.

func (*Project) NewInvitationToHarrow

func (self *Project) NewInvitationToHarrow(name, email, message string, membership string) *Invitation

NewInvitationToHarrow returns an invitation object suitable for inviting someone to join Harrow and become part of this project. See NewInvitationForUser for the meaning of the membership parameter.

func (*Project) NewInvitationToUser

func (self *Project) NewInvitationToUser(message string, membership string, recipient *User) *Invitation

NewInvitationForUser returns an invitation object suitable for inviting the given Harrow user to the given project. Membership indicates the desired project membership level, i.e. whether the invited user should be considered a "guest" or "member", etc of the project, should she accept. Valid values for membership are defined by the various MembershipType* constants.

func (*Project) NewJob

func (self *Project) NewJob(name, taskUuid, environmentUuid string) *Job

NewJob constructs a new job for the given task and environment in this project.

func (*Project) NewMembership

func (self *Project) NewMembership(member *User, membershipType string) *ProjectMembership

NewMembership constructs a new project membership for this project and the given user.

func (*Project) NewNotificationRule

func (self *Project) NewNotificationRule(notifierType, notifierUuid, jobUuid, matchActivities string) *NotificationRule

NewNotificationRule ...

func (*Project) NewRepository

func (self *Project) NewRepository(name, url string) *Repository

NewRepository constructs a new repository for this project.

func (*Project) NewTask

func (self *Project) NewTask(name, body string) *Task

NewTask constructs a new task object for this project.

func (*Project) OwnUrl

func (self *Project) OwnUrl(requestScheme, requestBaseUri string) string

type ProjectCard

type ProjectCard struct {
	LastActivitySeenAt time.Time

	ProjectUuid    string     `json:"projectUuid" db:"project_uuid"`
	ProjectName    string     `json:"projectName" db:"project_name"`
	LastTaskUuid   string     `json:"lastTaskUuid" db:"last_task_uuid"`
	LastTaskName   string     `json:"lastTaskName" db:"last_task_name"`
	LastTaskRunAt  *time.Time `json:"lastTaskRunAt" db:"last_task_run_at"`
	LastTaskStatus string     `json:"lastTaskStatus" db:"last_task_status"`
	// contains filtered or unexported fields
}

func NewProjectCard

func NewProjectCard(project *Project, environment *Environment, task *Task, mostRecentOperation *Operation) *ProjectCard

func (*ProjectCard) AuthorizationName

func (self *ProjectCard) AuthorizationName() string

func (*ProjectCard) Embed

func (self *ProjectCard) Embed(k string, subject Subject)

func (*ProjectCard) Embedded

func (self *ProjectCard) Embedded() map[string][]Subject

func (*ProjectCard) FindOrganization

func (self *ProjectCard) FindOrganization(organizations OrganizationStore) (*Organization, error)

func (*ProjectCard) FindProject

func (self *ProjectCard) FindProject(projects ProjectStore) (*Project, error)
func (self *ProjectCard) Links(response map[string]map[string]string, requestScheme string, requestBase string) map[string]map[string]string

func (*ProjectCard) OwnUrl

func (self *ProjectCard) OwnUrl(requestScheme, requestBase string) string

type ProjectMember

type ProjectMember struct {
	*User
	CreatedAt      time.Time `json:"createdAt" db:"-"`
	MembershipType string    `json:"type" db:"membership_type"`
	MembershipUuid *string   `json:"membershipUuid" db:"membership_uuid"`
	ProjectUuid    string    `json:"projectUuid" db:"project_uuid"`
	// contains filtered or unexported fields
}

ProjectMember augments User with project specific data.

func NewProjectMember

func NewProjectMember(user *User, project *Project, projectMembership *ProjectMembership, organizationMembership *OrganizationMembership) *ProjectMember

func (*ProjectMember) AddMember

func (self *ProjectMember) AddMember(userUuid string, membershipType string, projectMemberships ProjectMembershipCreator) (string, error)

func (*ProjectMember) AuthorizationName

func (self *ProjectMember) AuthorizationName() string

func (*ProjectMember) Capabilities

func (self *ProjectMember) Capabilities() []string

Capabilities satisfies authz.Role by returning a list of all capabilities the member has in its project.

func (*ProjectMember) Embed

func (self *ProjectMember) Embed(k string, subject Subject)

func (*ProjectMember) Embedded

func (self *ProjectMember) Embedded() map[string][]Subject

func (*ProjectMember) FindProject

func (self *ProjectMember) FindProject(projects ProjectStore) (*Project, error)

func (*ProjectMember) FindUser

func (self *ProjectMember) FindUser(users UserStore) (*User, error)
func (self *ProjectMember) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*ProjectMember) OwnUrl

func (self *ProjectMember) OwnUrl(requestScheme, requestBaseUri string) string

func (*ProjectMember) OwnedBy

func (self *ProjectMember) OwnedBy(user *User) bool

func (*ProjectMember) Promote

func (self *ProjectMember) Promote(other *ProjectMember) error

func (*ProjectMember) Remove

func (self *ProjectMember) Remove(other *ProjectMember, projectMemberships Archiver) error

func (*ProjectMember) ToMembership

func (self *ProjectMember) ToMembership() *ProjectMembership

type ProjectMembership

type ProjectMembership struct {
	Uuid           string     `json:"uuid" db:"uuid"`
	ProjectUuid    string     `json:"projectUuid" db:"project_uuid"`
	UserUuid       string     `json:"userUuid" db:"user_uuid"`
	MembershipType string     `json:"membershipType" db:"membership_type"`
	CreatedAt      time.Time  `json:"createdAt" db:"created_at"`
	ArchivedAt     *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func (*ProjectMembership) AuthorizationName

func (self *ProjectMembership) AuthorizationName() string

func (*ProjectMembership) Embed

func (self *ProjectMembership) Embed(k string, subject Subject)

func (*ProjectMembership) Embedded

func (self *ProjectMembership) Embedded() map[string][]Subject

func (*ProjectMembership) FindProject

func (self *ProjectMembership) FindProject(project ProjectStore) (*Project, error)

func (*ProjectMembership) FindUser

func (self *ProjectMembership) FindUser(users UserStore) (*User, error)
func (self *ProjectMembership) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*ProjectMembership) OwnUrl

func (self *ProjectMembership) OwnUrl(requestScheme, requestUri string) string

func (*ProjectMembership) OwnedBy

func (self *ProjectMembership) OwnedBy(user *User) bool

type ProjectMembershipCreator

type ProjectMembershipCreator interface {
	Create(membership *ProjectMembership) (string, error)
}

type ProjectStore

type ProjectStore interface {
	FindByUuid(uuid string) (*Project, error)
	FindByMemberUuid(uuid string) (*Project, error)
	FindByOrganizationUuid(uuid string) (*Project, error)
	FindByNotifierUuid(uuid, notifierType string) (*Project, error)
	FindByJobUuid(uuid string) (*Project, error)
	FindByTaskUuid(uuid string) (*Project, error)
	FindByRepositoryUuid(uuid string) (*Project, error)
	FindByEnvironmentUuid(uuid string) (*Project, error)
	FindByWebhookUuid(uuid string) (*Project, error)
	FindByNotificationRule(notifierType string, notifierUuid string) (*Project, error)
}

ProjectStore defines all operations that are necessary for the domain objects to work properly.

type RecentOperations

type RecentOperations interface {
	FindRecentByJobUuid(n int, jobUuid string) ([]*Operation, error)
}

type RepositoriesByName

type RepositoriesByName interface {
	FindAllByProjectUuidAndRepositoryName(projectUuid, name string) ([]*Repository, error)
}

type Repository

type Repository struct {
	Uuid           string     `json:"uuid"`
	Url            string     `json:"url"`
	Name           string     `json:"name"`
	Accessible     bool       `json:"accessible"`
	VisibleTo      string     `json:"-"              db:"visible_to"`
	ProjectUuid    string     `json:"projectUuid"    db:"project_uuid"`
	GithubImported bool       `json:"githubImported" db:"github_imported"`
	GithubLogin    string     `json:"githubLogin"    db:"github_login"`
	GithubRepo     string     `json:"githubRepo"     db:"github_repo"`
	CreatedAt      time.Time  `json:"createdAt"      db:"created_at"`
	ArchivedAt     *time.Time `json:"archivedAt"     db:"archived_at"`

	MetadataUpdatedAt *time.Time          `json:"metadataUpdatedAt" db:"metadata_updated_at"`
	Metadata          *RepositoryMetaData `json:"metadata" db:"metadata"`

	ConnectedSuccessfully *bool `json:"connectedSuccessfully,omitempty" db:"connected_successfully"`
	// contains filtered or unexported fields
}

func (*Repository) AuthorizationName

func (self *Repository) AuthorizationName() string

func (*Repository) CloneURL

func (self *Repository) CloneURL() string

CloneURL returns the URL to use for cloning the repository. This url can include sensitive informaiton (usernames, passwords).

func (*Repository) ClonedGit

func (self *Repository) ClonedGit(OS git.System, credentials RepositoryCredentialStore) (*git.ClonedRepository, error)

func (*Repository) Embed

func (self *Repository) Embed(k string, subject Subject)

func (*Repository) Embedded

func (self *Repository) Embedded() map[string][]Subject

func (*Repository) FindProject

func (self *Repository) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Repository) Git

func (self *Repository) Git() (*git.Repository, error)
func (self *Repository) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Repository) NewMetadataUpdateOperation

func (self *Repository) NewMetadataUpdateOperation() *Operation

NewMetadataUpdateOperation returns an operation for updating this repository's metadata.

func (*Repository) OwnUrl

func (self *Repository) OwnUrl(requestScheme, requestBaseUri string) string

func (*Repository) PublicURL

func (self *Repository) PublicURL() string

PublicURL returns the URL used for cloning this repository with all sensitive information removed.

func (*Repository) SetCredential

func (self *Repository) SetCredential(credential *RepositoryCredential) *Repository

type RepositoryCheckout

type RepositoryCheckout struct {
	Ref  string
	Hash string
}

type RepositoryCheckouts

type RepositoryCheckouts struct {
	Refs map[string][]*RepositoryCheckout `json:"refs"`
}

func NewRepositoryCheckouts

func NewRepositoryCheckouts() *RepositoryCheckouts

func (*RepositoryCheckouts) HandleEvent

func (self *RepositoryCheckouts) HandleEvent(payload EventPayload)

func (*RepositoryCheckouts) Hash

func (self *RepositoryCheckouts) Hash(repositoryUuid string) string

func (*RepositoryCheckouts) Ref

func (self *RepositoryCheckouts) Ref(repositoryUuid string) string

func (*RepositoryCheckouts) Scan

func (self *RepositoryCheckouts) Scan(data interface{}) error

func (*RepositoryCheckouts) Value

func (self *RepositoryCheckouts) Value() (driver.Value, error)

type RepositoryCredential

type RepositoryCredential struct {
	Uuid           string                     `json:"uuid"`
	Name           string                     `json:"name"`
	RepositoryUuid string                     `json:"repositoryUuid" db:"repository_uuid"`
	Type           RepositoryCredentialType   `json:"type"`
	Status         RepositoryCredentialStatus `json:"status"`
	ArchivedAt     *time.Time                 `json:"archivedAt"     db:"archived_at"`
	SecretBytes    []byte                     `json:"-"              db:"-"`
	Key            []byte                     `json:"-"               db:"key"`
	PublicKey      string                     `json:"publicKey,omitempty"`
	// contains filtered or unexported fields
}

func (*RepositoryCredential) AuthorizationName

func (self *RepositoryCredential) AuthorizationName() string

authz.Subject

func (*RepositoryCredential) Embed

func (self *RepositoryCredential) Embed(k string, subject Subject)

func (*RepositoryCredential) Embedded

func (self *RepositoryCredential) Embedded() map[string][]Subject

func (*RepositoryCredential) FindProject

func (self *RepositoryCredential) FindProject(store ProjectStore) (*Project, error)

authz.BelongsToProject

func (*RepositoryCredential) IsBasic

func (self *RepositoryCredential) IsBasic() bool

func (*RepositoryCredential) IsPending

func (self *RepositoryCredential) IsPending() bool

func (*RepositoryCredential) IsSsh

func (self *RepositoryCredential) IsSsh() bool
func (self *RepositoryCredential) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

domain.Subject

func (*RepositoryCredential) OwnUrl

func (self *RepositoryCredential) OwnUrl(requestScheme, requestBaseUri string) string

domain.Subject

type RepositoryCredentialStatus

type RepositoryCredentialStatus string
var (
	RepositoryCredentialPending RepositoryCredentialStatus = "pending"
	RepositoryCredentialPresent RepositoryCredentialStatus = "present"
)

func (*RepositoryCredentialStatus) Scan

func (self *RepositoryCredentialStatus) Scan(value interface{}) error

driver.Scanner

func (RepositoryCredentialStatus) Value

func (self RepositoryCredentialStatus) Value() (driver.Value, error)

driver.Valuer

type RepositoryCredentialStore

type RepositoryCredentialStore interface {
	FindByRepositoryUuid(repositoryUuid string) (*RepositoryCredential, error)
	FindByRepositoryUuidAndType(repositoryUuid string, credentialType RepositoryCredentialType) (*RepositoryCredential, error)
}

RepositoryCredentialStore defines all the operations that are necessary for domain objects to fetch associated repository credential objects.

type RepositoryCredentialType

type RepositoryCredentialType string
var (
	RepositoryCredentialSsh   RepositoryCredentialType = "ssh"
	RepositoryCredentialBasic RepositoryCredentialType = "basic"
)

func (*RepositoryCredentialType) Scan

func (self *RepositoryCredentialType) Scan(value interface{}) error

driver.Scanner

func (RepositoryCredentialType) Value

func (self RepositoryCredentialType) Value() (driver.Value, error)

driver.Valuer

type RepositoryCredentialTypeError

type RepositoryCredentialTypeError struct {
	ExpectedType RepositoryCredentialType `json:"expectedType"`
	ActualType   RepositoryCredentialType `json:"actualType"`
}

func NewRepositoryCredentialTypeError

func NewRepositoryCredentialTypeError(actual, expected RepositoryCredentialType) *RepositoryCredentialTypeError

func (*RepositoryCredentialTypeError) Error

func (self *RepositoryCredentialTypeError) Error() string

type RepositoryMetaData

type RepositoryMetaData struct {
	Contributors map[string]*Person `json:"contributors"`
	Refs         map[string]string  `json:"refs"`
}

func NewRepositoryMetaData

func NewRepositoryMetaData() *RepositoryMetaData

func (*RepositoryMetaData) Changes

Changes returns the changes between this repository metadata and the new version provided as an argument.

func (*RepositoryMetaData) IsEmpty

func (self *RepositoryMetaData) IsEmpty() bool

IsEmpty returns true if there are no refs contained in this instance.

func (*RepositoryMetaData) Scan

func (self *RepositoryMetaData) Scan(value interface{}) error

func (*RepositoryMetaData) Value

func (self *RepositoryMetaData) Value() (driver.Value, error)

func (*RepositoryMetaData) WithRef

func (self *RepositoryMetaData) WithRef(symbolic, hash string) *RepositoryMetaData

WithRef adds a symbolic ref pointing to a given hash to this metadata object.

type RepositoryMetaDataChanges

type RepositoryMetaDataChanges struct {
	AddedRefs   []*RepositoryRef `json:"addedRefs"`
	RemovedRefs []*RepositoryRef `json:"removedRefs"`

	ChangedRefs []*ChangedRepositoryRef `json:"changedRefs"`
}

func NewRepositoryMetaDataChanges

func NewRepositoryMetaDataChanges() *RepositoryMetaDataChanges

func (*RepositoryMetaDataChanges) Add

Add marks ref as a ref that has been introduced with this set of changes.

func (*RepositoryMetaDataChanges) Added

func (self *RepositoryMetaDataChanges) Added() []*RepositoryRef

Added returns the list of refs that have been added with this change. It never returns nil.

func (*RepositoryMetaDataChanges) Change

func (self *RepositoryMetaDataChanges) Change(symbolic, oldHash, newHash string) *RepositoryMetaDataChanges

Change marks that ref's old hash has been changed to new with this set of changes.

func (*RepositoryMetaDataChanges) Changed

Changed returns the list of refs that are pointing to a different hash with this set of changes. It never returns nil.

func (*RepositoryMetaDataChanges) Remove

Remove marks ref as a ref that has been removed with this set of changes. The ref's hash points to the last known hash.

func (*RepositoryMetaDataChanges) Removed

func (self *RepositoryMetaDataChanges) Removed() []*RepositoryRef

Removed returns the list of refs that have been removed with this change. It never returns nil.

type RepositoryOperationVars

type RepositoryOperationVars struct {
	// Url is the URL pointing to the repository to which this
	// operation applies.
	Url string
}

RepositoryOperationVars hold the necessary information for the template production the shell script to run a repository operation.

type RepositoryRef

type RepositoryRef struct {
	RepositoryUuid string `json:"repositoryUuid"`
	Symbolic       string `json:"symbolic"`
	Hash           string `json:"hash"`
}

func NewRepositoryRef

func NewRepositoryRef(symbolic, hash string) *RepositoryRef

func (*RepositoryRef) FindProject

func (self *RepositoryRef) FindProject(projects ProjectStore) (*Project, error)

type RepositoryStore

type RepositoryStore interface {
	FindByUuid(repositoryUuid string) (*Repository, error)
	FindAllByJobUuid(jobUuid string) ([]*Repository, error)
	MarkAsAccessible(repositoryUuid string, accessible bool) error
}

RepositoryStore defines all the operations that are necessary for domain objects to fetch associated repository objects.

type Schedulable

type Schedulable interface {
	// NextOperation determines the next time an operation should
	// run.  If now is non nil, the value it points to is used
	// instead of time.Now().  A zero time return value means, that no
	// next operation is scheduled.  An error is returned when
	// invalid scheduling information is used for determining the
	// time of the next operation.
	//
	// The time returned is in the timezone specified by this
	// Schedulable.
	NextOperation(now *time.Time) (time.Time, error)

	// Validate tests whether the schedule is in valid state.  If it
	// isn't, it returns an error of type (*ValidationError).
	// Validate may modify the internal state of the schedule to
	// pool, make it valid (if possible).
	Validate() error

	// Id returns the UUID of the schedule.  This information is
	// required for managing the pool of live schedules.
	Id() string

	// JobId returns the UUID of the job to execute by this
	// Schedulable.
	JobId() string

	// IsRecurring is used by the Scheduler (and possibly others)
	// to determine whether to add this to the watch pool
	// or schedule it for immediate execution
	IsRecurring() bool

	// IsDisabled returns true or false based on the presense of a non
	// empty string in Disabled
	IsDisabled() bool

	OperationParameters() *OperationParameters

	// We echo the interface of domain.Subject in order to
	// be able to render Schedulables to the API as JSON
	// Url returns the URL referencing the subject itself
	OwnUrl(requestScheme, requestBaseUri string) string
	// Links fills in the _links object in the HAL response
	Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string
}

func NewSchedulable

func NewSchedulable(s *Schedule) (Schedulable, error)

TODO: This actually changes s via setupOneTime, but the name does not give that fact away. This method should probably be defined on a non-pointer, make a copy of s, or RunOnceAt should be a method so we don't need setupOneTime.

type Schedule

type Schedule struct {
	Uuid         string    `json:"uuid"`
	UserUuid     string    `json:"userUuid"            db:"user_uuid"`
	JobUuid      string    `json:"jobUuid"             db:"job_uuid"`
	Cronspec     *string   `json:"cronspec"`
	Description  string    `json:"description"`
	CreatedAt    time.Time `json:"createdAt"           db:"created_at"`
	Timespec     *string   `json:"timespec,omitempty"`
	TimezoneName string    `json:"location"            db:"location"`

	Parameters *OperationParameters `json:"parameters" db:"parameters"`

	NextExecutions []*ScheduledExecution `json:"nextExecutions,omitempty", db:"-"`

	ArchivedAt *time.Time `json:"archivedAt" db:"archived_at"`

	// Disabled is an enum describing the reason this Schedule is disabled
	// If it is nil, the Schedule is enabled.
	Disabled *string `json:"disabled" db:"disabled"`
	// DisabledBecause describes the error in case of ScheduleDisabledInternalError
	DisabledBecause *string `json:"-" db:"disabled_because"`

	// RunOnceAt contains the result of parsing a timespec by at(1).
	// It is necessary to cache this value in the database, because
	// evaluating a timespec by at(1) can depend on the current time.
	// Repeatedly evaluating 'now + 2 minutes' for example yields a
	// different time everytime it is evaluated.
	RunOnceAt *time.Time `json:"runOnceAt,omitempty"   db:"run_once_at"`
	// contains filtered or unexported fields
}

func (*Schedule) AuthorizationName

func (self *Schedule) AuthorizationName() string

func (*Schedule) Embed

func (self *Schedule) Embed(k string, subject Subject)

func (*Schedule) Embedded

func (self *Schedule) Embedded() map[string][]Subject

func (*Schedule) FindProject

func (self *Schedule) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Schedule) FindUser

func (self *Schedule) FindUser(store UserStore) (*User, error)

FindUser satisies authz.BelongsToUser in order to determine authorization.

func (self *Schedule) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Schedule) OperationParameters

func (self *Schedule) OperationParameters() *OperationParameters

func (*Schedule) OwnUrl

func (self *Schedule) OwnUrl(requestScheme, requestBaseUri string) string

func (*Schedule) OwnedBy

func (self *Schedule) OwnedBy(user *User) bool

func (*Schedule) Validate

func (self *Schedule) Validate() error

TODO: this potentially mutates self, see above

type ScheduledExecution

type ScheduledExecution struct {
	Time        time.Time `json:"time"`
	JobUuid     string    `json:"jobUuid"`
	Spec        string    `json:"spec"`
	Description string    `json:"description"`
	// contains filtered or unexported fields
}

func ExecutionsBetween

func ExecutionsBetween(from, to time.Time, n int, schedules []*Schedule) ([]*ScheduledExecution, error)

func NewScheduledExecution

func NewScheduledExecution(time time.Time, jobUuid, spec, description string) *ScheduledExecution

func (*ScheduledExecution) AuthorizationName

func (self *ScheduledExecution) AuthorizationName() string

func (*ScheduledExecution) Embed

func (self *ScheduledExecution) Embed(k string, subject Subject)

func (*ScheduledExecution) Embedded

func (self *ScheduledExecution) Embedded() map[string][]Subject
func (self *ScheduledExecution) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*ScheduledExecution) OwnUrl

func (self *ScheduledExecution) OwnUrl(requestScheme, requestBaseUri string) string

type ScriptCard

type ScriptCard struct {
	ProjectUuid                            string              `json:"projectUuid" db:"project_uuid"`
	ScriptUuid                             string              `json:"scriptUuid" db:"script_uuid"`
	ScriptName                             string              `json:"scriptName" db:"script_name"`
	LastOperation                          *Operation          `json:"lastOperation" db:"last_operation"`
	EnabledEnvironments                    []*Environment      `json:"enabledEnvironments"`
	RecentOperationStatusByEnvironmentUuid map[string][]string `json:"recentOperationStatusByEnvironmentUuid"`
	// contains filtered or unexported fields
}

func (*ScriptCard) AuthorizationName

func (self *ScriptCard) AuthorizationName() string

func (*ScriptCard) Embed

func (self *ScriptCard) Embed(k string, subject Subject)

func (*ScriptCard) Embedded

func (self *ScriptCard) Embedded() map[string][]Subject

func (*ScriptCard) FindProject

func (self *ScriptCard) FindProject(projects ProjectStore) (*Project, error)
func (self *ScriptCard) Links(response map[string]map[string]string, requestScheme string, requestBaseUri string) map[string]map[string]string

func (*ScriptCard) OwnUrl

func (self *ScriptCard) OwnUrl(requestScheme string, requestBaseUri string) string

type Secret

type Secret struct {
	Uuid            string       `json:"uuid"`
	Name            string       `json:"name"`
	EnvironmentUuid string       `json:"environmentUuid" db:"environment_uuid"`
	Type            SecretType   `json:"type"`
	Status          SecretStatus `json:"status"`
	ArchivedAt      *time.Time   `json:"archivedAt"      db:"archived_at"`
	Key             []byte       `json:"-"               db:"key"`
	SecretBytes     []byte       `json:"-"               db:"-"`
	// contains filtered or unexported fields
}

func (*Secret) AuthorizationName

func (self *Secret) AuthorizationName() string

authz.Subject

func (*Secret) Embed

func (self *Secret) Embed(k string, subject Subject)

func (*Secret) Embedded

func (self *Secret) Embedded() map[string][]Subject

func (*Secret) FindProject

func (self *Secret) FindProject(store ProjectStore) (*Project, error)

authz.BelongsToProject

func (*Secret) IsEnv

func (self *Secret) IsEnv() bool

func (*Secret) IsEnvOverride

func (self *Secret) IsEnvOverride() bool

func (*Secret) IsPending

func (self *Secret) IsPending() bool

func (*Secret) IsSsh

func (self *Secret) IsSsh() bool
func (self *Secret) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

domain.Subject

func (*Secret) OwnUrl

func (self *Secret) OwnUrl(requestScheme, requestBaseUri string) string

domain.Subject

type SecretStatus

type SecretStatus string
var (
	SecretPending SecretStatus = "pending"
	SecretPresent SecretStatus = "present"
)

func (*SecretStatus) Scan

func (self *SecretStatus) Scan(value interface{}) error

driver.Scanner

func (SecretStatus) Value

func (self SecretStatus) Value() (driver.Value, error)

driver.Valuer

type SecretStore

type SecretStore interface {
	FindAllByEnvironmentUuid(environmentUuid string) ([]*Secret, error)
}

SecretStore defines all the operations that are necessary for domain objects to fetch associated secret objects

type SecretType

type SecretType string
var (
	SecretEnv         SecretType = "env"
	SecretEnvOverride SecretType = "env-override"
	SecretSsh         SecretType = "ssh"
)

func (*SecretType) Scan

func (self *SecretType) Scan(value interface{}) error

driver.Scanner

func (SecretType) Value

func (self SecretType) Value() (driver.Value, error)

driver.Valuer

type Session

type Session struct {
	Uuid          string     `json:"uuid"`
	UserUuid      string     `json:"userUuid"      db:"user_uuid"`
	EndedAt       time.Time  `json:"-"             db:"ended_at"`
	LoadedAt      time.Time  `json:"loadedAt"      db:"loaded_at"`
	ExpiresAt     time.Time  `json:"expiresAt"     db:"expires_at"`
	CreatedAt     time.Time  `json:"createdAt"     db:"created_at"`
	ValidatedAt   time.Time  `json:"validatedAt"   db:"validated_at"`
	LoggedOutAt   *time.Time `json:"loggedOutAt"   db:"logged_out_at"`
	InvalidatedAt *time.Time `json:"invalidatedAt" db:"invalidated_at"`
	Valid         bool       `json:"valid"         db:"-"`
	UserAgent     string     `json:"userAgent"     db:"user_agent"`
	ClientAddress string     `json:"clientAddress" db:"client_address"`
	// contains filtered or unexported fields
}

func (*Session) AuthorizationName

func (self *Session) AuthorizationName() string

func (*Session) Embed

func (self *Session) Embed(k string, subject Subject)

func (*Session) Embedded

func (self *Session) Embedded() map[string][]Subject

func (*Session) FindUser

func (self *Session) FindUser(store UserStore) (*User, error)

func (*Session) IsExpired

func (s *Session) IsExpired() bool

func (*Session) IsInvalidated

func (s *Session) IsInvalidated() bool
func (self *Session) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Session) LogOut

func (s *Session) LogOut()

func (*Session) OwnUrl

func (self *Session) OwnUrl(requestScheme, requestBaseUri string) string

func (*Session) OwnedBy

func (self *Session) OwnedBy(user *User) bool

func (*Session) Validate

func (s *Session) Validate() error

type Set

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

func NewSet

func NewSet() *Set

func (*Set) Add

func (self *Set) Add(item string) *Set

Add adds item to the set

func (*Set) Includes

func (self *Set) Includes(item string) bool

Includes returns true if item is contained in this set.

func (*Set) Intersect

func (self *Set) Intersect(other *Set) *Set

Intersect returns a new set containing the items that are part of this set and the other set.

func (*Set) Size

func (self *Set) Size() int

Size returns the number of items in the set

type SlackNotifier

type SlackNotifier struct {
	Uuid        string `json:"uuid" db:"uuid"`
	Name        string `json:"name" db:"name"`
	WebhookURL  string `json:"webhookURL" db:"webhook_url"`
	UrlHost     string `json:"urlHost" db:"url_host"`
	ProjectUuid string `json:"projectUuid" db:"project_uuid"`

	ArchivedAt *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func (*SlackNotifier) AuthorizationName

func (self *SlackNotifier) AuthorizationName() string

func (*SlackNotifier) Embed

func (self *SlackNotifier) Embed(k string, subject Subject)

func (*SlackNotifier) Embedded

func (self *SlackNotifier) Embedded() map[string][]Subject

func (*SlackNotifier) FindProject

func (self *SlackNotifier) FindProject(projects ProjectStore) (*Project, error)
func (self *SlackNotifier) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*SlackNotifier) OwnUrl

func (self *SlackNotifier) OwnUrl(requestScheme, requestBase string) string

func (*SlackNotifier) Validate

func (self *SlackNotifier) Validate() error

type SshRepositoryCredential

type SshRepositoryCredential struct {
	*RepositoryCredential `json:"-"`
	PrivateKey, PublicKey string
}

func AsSshRepositoryCredential

func AsSshRepositoryCredential(rc *RepositoryCredential) (*SshRepositoryCredential, error)

func (*SshRepositoryCredential) AsRepositoryCredential

func (self *SshRepositoryCredential) AsRepositoryCredential() (*RepositoryCredential, error)

func (SshRepositoryCredential) Embed

func (self SshRepositoryCredential) Embed(k string, subject Subject)

func (SshRepositoryCredential) Embedded

func (self SshRepositoryCredential) Embedded() map[string][]Subject

type SshSecret

type SshSecret struct {
	*Secret               `json:"-"`
	PrivateKey, PublicKey string
}

func AsSshSecret

func AsSshSecret(s *Secret) (*SshSecret, error)

func (*SshSecret) AsPrivileged

func (self *SshSecret) AsPrivileged() (*PrivilegedSshSecret, error)

func (*SshSecret) AsSecret

func (self *SshSecret) AsSecret() (*Secret, error)

func (*SshSecret) AsUnprivileged

func (self *SshSecret) AsUnprivileged() (*UnprivilegedSshSecret, error)

func (SshSecret) Embed

func (self SshSecret) Embed(k string, subject Subject)

func (SshSecret) Embedded

func (self SshSecret) Embedded() map[string][]Subject

type StatusLogEntry

type StatusLogEntry struct {
	OccurredOn time.Time `json:"occurredOn"`
	Type       string    `json:"type"`
	Subject    string    `json:"subject"`
	Body       string    `json:"body"`
}

func NewStatusLogEntry

func NewStatusLogEntry(entryType string) *StatusLogEntry

NewStatusLogEntry returns a new empty status log entry of the given type.

type StatusLogs

type StatusLogs struct {
	Entries []*StatusLogEntry `json:"entries"`
}

func NewStatusLogs

func NewStatusLogs() *StatusLogs

NewStatusLogs returns an empty list of status logs.

func (*StatusLogs) HandleEvent

func (self *StatusLogs) HandleEvent(payload EventPayload)

HandleEvent adds new entries to the logs

func (*StatusLogs) Len

func (self *StatusLogs) Len() int

func (*StatusLogs) Less

func (self *StatusLogs) Less(i, j int) bool

Less compares status log entries by occurrence date, ascending.

func (*StatusLogs) Log

func (self *StatusLogs) Log(entry *StatusLogEntry) *StatusLogs

Log adds entry to the end of this log and sorts entries by ocurrence date.

func (*StatusLogs) Newest

func (self *StatusLogs) Newest() *StatusLogEntry

Newest returns the newest entry in this log going by the entries' occurrence date.

func (*StatusLogs) Scan

func (self *StatusLogs) Scan(data interface{}) error

Scan deserializes value as a JSON array.

func (*StatusLogs) Swap

func (self *StatusLogs) Swap(i, j int)

func (*StatusLogs) Value

func (self *StatusLogs) Value() (driver.Value, error)

Value serializes this log as a JSON array.

type Stencil

type Stencil struct {
	Id             string `json:"id"`
	ProjectUuid    string `json:"projectUuid,omitempty"`
	UserUuid       string `json:"userUuid,omitempty"`
	NotifyViaEmail string `json:"notifyViaEmail,omitempty"`
	UrlHost        string `json:"urlHost,omitempty"`
	// contains filtered or unexported fields
}

func (*Stencil) AuthorizationName

func (self *Stencil) AuthorizationName() string

func (*Stencil) Embed

func (self *Stencil) Embed(k string, subject Subject)

func (*Stencil) Embedded

func (self *Stencil) Embedded() map[string][]Subject

func (*Stencil) FindProject

func (self *Stencil) FindProject(projects ProjectStore) (*Project, error)
func (self *Stencil) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*Stencil) OwnUrl

func (self *Stencil) OwnUrl(requestScheme, requestBase string) string

func (*Stencil) Validate

func (self *Stencil) Validate() error

type Subject

type Subject interface {
	// Url returns the URL referencing the subject itself
	OwnUrl(requestScheme, requestBaseUri string) string
	// Links fills in the _links object in the HAL response
	Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string
	// Embedded is used for embedding relations
	Embedded() map[string][]Subject
}

Subject defines the methods necessary for creating a JSON-HAL compliant response object.

type Subscription

type Subscription struct {
	Uuid          string     `json:"uuid" db:"uuid"`
	UserUuid      string     `json:"userUuid" db:"user_uuid"`
	WatchableUuid string     `json:"watchableUuid" db:"watchable_uuid"`
	WatchableType string     `json:"watchableType" db:"watchable_type"`
	EventName     string     `json:"eventName" db:"event_name"`
	ArchivedAt    *time.Time `json:"archivedAt" db:"archived_at"`
	CreatedAt     *time.Time `json:"createdAt" db:"created_at"`
}

func NewSubscription

func NewSubscription(watchable Watchable, event, userUuid string) *Subscription

func (*Subscription) AuthorizationName

func (self *Subscription) AuthorizationName() string

func (*Subscription) FindUser

func (self *Subscription) FindUser(users UserStore) (*User, error)

func (*Subscription) OwnedBy

func (self *Subscription) OwnedBy(user *User) bool

type SubscriptionStore

type SubscriptionStore interface {
	Create(subscription *Subscription) (string, error)
	Find(watchableId, event, userUuid string) (*Subscription, error)
	FindEventsForUser(watchableId, userUuid string) ([]string, error)
	Delete(subscriptionUuid string) error
}

type Subscriptions

type Subscriptions struct {
	WatcherUuid   string          `json:"watcherUuid"`
	WatchableUuid string          `json:"watchableUuid"`
	WatchableType string          `json:"watchableType"`
	Subscribed    map[string]bool `json:"subscribed"`
	// contains filtered or unexported fields
}

Subscriptions is aggregates all event subscriptions of a single user on a given watchable.

func (*Subscriptions) AuthorizationName

func (self *Subscriptions) AuthorizationName() string

func (*Subscriptions) Embed

func (self *Subscriptions) Embed(k string, subject Subject)

func (*Subscriptions) Embedded

func (self *Subscriptions) Embedded() map[string][]Subject

func (*Subscriptions) FindUser

func (self *Subscriptions) FindUser(users UserStore) (*User, error)
func (self *Subscriptions) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*Subscriptions) OwnUrl

func (self *Subscriptions) OwnUrl(requestScheme, requestBase string) string

func (*Subscriptions) OwnedBy

func (self *Subscriptions) OwnedBy(user *User) bool

type Target

type Target struct {
	Uuid            string     `json:"uuid"`
	CreatedAt       time.Time  `json:"createdAt" db:"created_at"`
	ArchivedAt      *time.Time `json:"archivedAt" db:"archived_at"`
	AccessibeSince  *time.Time `json:"accessibeSince" db:"accessibe_since"`
	EnvironmentUuid string     `json:"EnvironmentUuid" db:"environment_uuid"`
	Identifier      string     `json:"identifier"`
	ProjectUuid     string     `json:"projectUuid" db:"project_uuid"`
	Secret          string     `json:"secret"`
	Type            string     `json:"type"`
	Url             string     `json:"url"`
	// contains filtered or unexported fields
}

func (*Target) AuthorizationName

func (self *Target) AuthorizationName() string

func (*Target) Embed

func (self *Target) Embed(k string, subject Subject)

func (*Target) Embedded

func (self *Target) Embedded() map[string][]Subject

func (*Target) FindProject

func (self *Target) FindProject(projects ProjectStore) (*Project, error)
func (self *Target) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Target) OwnUrl

func (self *Target) OwnUrl(requestScheme, requestBaseUri string) string

type Task

type Task struct {
	Uuid        string     `json:"uuid"`
	Body        string     `json:"body"`
	CreatedAt   time.Time  `json:"createdAt"   db:"created_at"`
	Name        string     `json:"name"`
	ProjectUuid string     `json:"projectUuid" db:"project_uuid"`
	Type        string     `json:"type"`
	ArchivedAt  *time.Time `json:"archivedAt"  db:"archived_at"`
	// contains filtered or unexported fields
}

func (*Task) AuthorizationName

func (self *Task) AuthorizationName() string

func (*Task) CreationDate

func (self *Task) CreationDate() time.Time

func (*Task) Embed

func (self *Task) Embed(k string, subject Subject)

func (*Task) Embedded

func (self *Task) Embedded() map[string][]Subject

func (*Task) FindProject

func (self *Task) FindProject(store ProjectStore) (*Project, error)

FindProject satisfies authz.BelongsToProject in order to determine authorization.

func (*Task) Id

func (self *Task) Id() string
func (self *Task) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*Task) NewJob

func (self *Task) NewJob(environment *Environment) *Job

NewJob constructs a new job for this task in the given environment

func (*Task) OwnUrl

func (self *Task) OwnUrl(requestScheme, requestBaseUri string) string

type TaskStore

type TaskStore interface {
	FindByJobUuid(jobUuid string) (*Task, error)
}

TaskStore defines all the operations that are necessary for domain objects to fetch associated task objects.

type TotpToken

type TotpToken interface {
	FromNow(period int64) int32
	Now() int32
}

TotpToken defines the methods necessary for verifying time-based one-time password tokens.

type TotpTokenWithClock

type TotpTokenWithClock struct {
	*gototp.TOTP
}

TotpTokenWithClock implements a TotpToken which does not depend on the time package but uses the domain clock instead.

func NewTotpTokenWithClock

func NewTotpTokenWithClock(secretB32 string) (*TotpTokenWithClock, error)

func (*TotpTokenWithClock) FromNow

func (totp *TotpTokenWithClock) FromNow(periods int64) int32

type UnprivilegedEnvironmentSecret

type UnprivilegedEnvironmentSecret struct {
	*Secret
}

UnprivilegedEnvironmentSecret is meant for transport to unprivileged clients (i.e. project members), and doesn't containt the Value

func (UnprivilegedEnvironmentSecret) Embed

func (self UnprivilegedEnvironmentSecret) Embed(k string, subject Subject)

func (UnprivilegedEnvironmentSecret) Embedded

func (self UnprivilegedEnvironmentSecret) Embedded() map[string][]Subject

type UnprivilegedSshSecret

type UnprivilegedSshSecret struct {
	*Secret
	PublicKey string `json:"publicKey"`
}

UnprivilegedSshSecret is meant for transport to unprivileged clients (i.e. project members), and only decodes the public key

func (UnprivilegedSshSecret) Embed

func (self UnprivilegedSshSecret) Embed(k string, subject Subject)

func (UnprivilegedSshSecret) Embedded

func (self UnprivilegedSshSecret) Embedded() map[string][]Subject

type User

type User struct {
	Uuid string `json:"uuid"`

	Email      string  `json:"email"`
	GhUsername *string `json:"ghUsername" db:"gh_username"`
	Name       string  `json:"name"`
	Password   string  `json:"password,omitempty"`
	Token      string  `json:"-" db:"token"`
	// If true, the user has no password. They can change user details without
	// providing a password (Name, Email) and cannot log in with username+password
	// This is true for example for users created as result of a OAuth login in
	WithoutPassword bool       `json:"withoutPassword"              db:"without_password"`
	CreatedAt       time.Time  `json:"createdAt"                    db:"created_at"`
	TotpSecret      string     `json:"-"                            db:"totp_secret"`
	TotpEnabledAt   *time.Time `json:"totpEnabledAt"                db:"totp_enabled_at"`
	PasswordHash    string     `json:"-"                            db:"password_hash"`
	// TODO(paul): unused, remove?
	PasswordResetToken string `json:"passwordResetToken,omitempty" db:"password_reset_token"`
	UrlHost            string `json:"urlHost"                      db:"url_host"`

	SignupParameters Dictionary `json:"signupParameters"  db:"signup_parameters"`
	// contains filtered or unexported fields
}

User is a basic type representing users in the system, the JSON marshalling of this type is intentionally disabled for private and public members as they should never be marshalled directly, everything should go through presentation.User marshaller.

func NewUser

func NewUser(name, email, password string) *User

func (*User) AuthorizationName

func (self *User) AuthorizationName() string

func (*User) Capabilities

func (self *User) Capabilities() []string

func (*User) CurrentTotpToken

func (self *User) CurrentTotpToken() int32

func (*User) DisableTotp

func (self *User) DisableTotp(token int32) error

func (*User) Embed

func (self *User) Embed(k string, subject Subject)

func (*User) Embedded

func (self *User) Embedded() map[string][]Subject

func (*User) EnableTotp

func (self *User) EnableTotp(token int32) error

func (*User) FindProject

func (self *User) FindProject(store ProjectStore) (*Project, error)

func (*User) FindUser

func (self *User) FindUser(store UserStore) (*User, error)

func (*User) GenerateTotpSecret

func (self *User) GenerateTotpSecret()

func (*User) HMAC

func (self *User) HMAC(key []byte) []byte

func (*User) InvitedTo

func (self *User) InvitedTo(project *Project, invitations InvitationStore) (bool, error)

func (*User) IsSubscribedTo

func (self *User) IsSubscribedTo(watchable Watchable, event string, subscriptions SubscriptionStore) (bool, error)

func (*User) IsValidTotpToken

func (self *User) IsValidTotpToken(token int32) bool
func (self *User) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

func (*User) NewBlock

func (self *User) NewBlock(reason string) (*UserBlock, error)

func (*User) NewSession

func (self *User) NewSession(userAgent, clientAddress string) *Session

func (*User) OwnUrl

func (self *User) OwnUrl(requestScheme, requestBaseUri string) string

func (*User) OwnedBy

func (self *User) OwnedBy(user *User) bool

func (*User) Scrub

func (self *User) Scrub() *User

func (*User) SubscribeTo

func (self *User) SubscribeTo(watchable Watchable, event string, subscriptions SubscriptionStore) error

func (*User) SubscriptionsFor

func (self *User) SubscriptionsFor(watchable Watchable, allSubscriptions SubscriptionStore) (*Subscriptions, error)

func (*User) TotpEnabled

func (self *User) TotpEnabled() bool

func (*User) UnsubscribeFrom

func (self *User) UnsubscribeFrom(watchable Watchable, event string, subscriptions SubscriptionStore) error

func (*User) Unwatch

func (self *User) Unwatch(watchable Watchable, subscriptions SubscriptionStore) error

func (*User) Watch

func (self *User) Watch(watchable Watchable, subscriptions SubscriptionStore) error

type UserBlock

type UserBlock struct {
	Uuid      string     `json:"uuid" db:"uuid"`
	UserUuid  string     `json:"userUuid" db:"user_uuid"`
	Reason    string     `json:"reason" db:"reason"`
	ValidFrom *time.Time `json:"validFrom" db:"valid_from"`
	ValidTo   *time.Time `json:"validTo" db:"valid_to"`
	// contains filtered or unexported fields
}

func (*UserBlock) BlockForever

func (self *UserBlock) BlockForever(now time.Time)

func (*UserBlock) Embed

func (self *UserBlock) Embed(k string, subject Subject)

func (*UserBlock) Embedded

func (self *UserBlock) Embedded() map[string][]Subject
func (self *UserBlock) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*UserBlock) OwnUrl

func (self *UserBlock) OwnUrl(requestScheme, requestBase string) string

type UserHistory

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

func NewUserHistory

func NewUserHistory(userUuid string, today time.Time) *UserHistory

func (*UserHistory) HandleActivity

func (self *UserHistory) HandleActivity(activity *Activity) error

HandleActivity updates the history for this user.

func (*UserHistory) IsActive

func (self *UserHistory) IsActive() bool

IsActive returns whether this user has been reported as active today already.

func (*UserHistory) PreviousSegment

func (self *UserHistory) PreviousSegment() string

PreviousSegment returns the segment the user was in previously, according to segment-entered and segment-left activities. If no such activities exist for a user, SegmentLimbo is returned.

func (*UserHistory) Segment

func (self *UserHistory) Segment() string

Segment returns the KPI segment the user is in. See the various Segment variables for which user falls into which segment.

func (*UserHistory) VerificationEmailsRequestedToday

func (self *UserHistory) VerificationEmailsRequestedToday() int

VerificationEmailsRequestedToday returns the number verification emails that have been requested for this user today.

type UserStore

type UserStore interface {
	FindByUuid(uuid string) (*User, error)
	FindAllSubscribers(watchableId, event string) ([]*User, error)
}

UserStore defines all the operations that are necessary for the domain to fetch associated user objects.

type ValidationError

type ValidationError struct {
	Errors    map[string][]string `json:"errors"`
	Originals map[string]error    `json:"-"`
}

func EmptyValidationError

func EmptyValidationError() *ValidationError

func NewValidationError

func NewValidationError(key, value string) *ValidationError

func (*ValidationError) Add

func (ve *ValidationError) Add(key, err string) *ValidationError

func (*ValidationError) Error

func (ve *ValidationError) Error() string

func (*ValidationError) Get

func (ve *ValidationError) Get(key string) string

func (*ValidationError) ToError

func (ve *ValidationError) ToError() error

type Watchable

type Watchable interface {
	Id() string
	WatchableType() string
	WatchableEvents() []string
}

type Webhook

type Webhook struct {
	Uuid        string     `json:"uuid" db:"uuid"`
	ProjectUuid string     `json:"projectUuid" db:"project_uuid"`
	CreatorUuid string     `json:"creatorUuid" db:"creator_uuid"`
	JobUuid     string     `json:"jobUuid" db:"job_uuid"`
	Name        string     `json:"name" db:"name"`
	Slug        string     `json:"slug" db:"slug"`
	CreatedAt   time.Time  `json:"createdAt" db:"created_at"`
	ArchivedAt  *time.Time `json:"archivedAt" db:"archived_at"`
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(projectUuid, creatorUuid, jobUuid, name string) *Webhook

func (*Webhook) AuthorizationName

func (self *Webhook) AuthorizationName() string

func (*Webhook) Embed

func (self *Webhook) Embed(k string, subject Subject)

func (*Webhook) Embedded

func (self *Webhook) Embedded() map[string][]Subject

func (*Webhook) FindProject

func (self *Webhook) FindProject(projects ProjectStore) (*Project, error)

func (*Webhook) GenerateSlug

func (self *Webhook) GenerateSlug()

func (*Webhook) IsInternal

func (self *Webhook) IsInternal() bool

IsInternal returns true if the webhook has been created internally by Harrow (e.g. for supporting job notifiers).

func (self *Webhook) Links(response map[string]map[string]string, requestScheme, requestBase string) map[string]map[string]string

func (*Webhook) NewDelivery

func (self *Webhook) NewDelivery(req *http.Request) *Delivery

func (*Webhook) OwnUrl

func (self *Webhook) OwnUrl(requestScheme, requestBase string) string

func (*Webhook) Validate

func (self *Webhook) Validate() error

type WorkspaceBaseImage

type WorkspaceBaseImage struct {
	Uuid       string    `json:"uuid" db:"uuid"`
	Name       string    `json:"name" db:"name"`
	Type       string    `json:"type" db:"type"`
	Path       string    `json:"path" db:"path"`
	Ref        string    `json:"ref" db:"ref"`
	Repository string    `json:"repository" db:"repository"`
	CreatedAt  time.Time `json:"createdAt" db:"created_at"`
	// contains filtered or unexported fields
}

func (*WorkspaceBaseImage) AuthorizationName

func (self *WorkspaceBaseImage) AuthorizationName() string

func (*WorkspaceBaseImage) Embed

func (self *WorkspaceBaseImage) Embed(k string, subject Subject)

func (*WorkspaceBaseImage) Embedded

func (self *WorkspaceBaseImage) Embedded() map[string][]Subject
func (self *WorkspaceBaseImage) Links(response map[string]map[string]string, requestScheme, requestBaseUri string) map[string]map[string]string

type WorkspaceBaseImageStore

type WorkspaceBaseImageStore interface {
	FindByUuid(uuid string) (*WorkspaceBaseImage, error)
}

WorkspaceBaseImageStore defines all the operations that are necessary for domain objects to fetch associated workspace base images.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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