models

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package models contains the models and auto generated models for the app.

Index

Constants

View Source
const (
	SourceUpserted        = "SOURCE_UPSERTED"
	SourceDeleted         = "SOURCE_DELETED"
	WorkspaceUpserted     = "WORKSPACE_UPSERTED"
	ProjectUpserted       = "PROJECT_UPSERTED"
	TaskUpserted          = "TASK_UPSERTED"
	KeyUpserted           = "KEY_UPSERTED"
	KeyDeleted            = "KEY_DELETED"
	JobUpserted           = "JOB_UPSERTED"
	JobMetricsUpdated     = "JOB_METRICS_UPDATED"
	ProcessGroupUpserted  = "PROCESS_GROUP_UPSERTED"
	ProcessUpserted       = "PROCESS_UPSERTED"
	ProcessMetricsUpdated = "PROCESS_METRICS_UPDATED"
	LogEntryAdded         = "LOG_ENTRY_ADDED"
	LogMetricsUpdated     = "LOG_METRICS_UPDATED"
)

Message types.

View Source
const DateFormat = "2006-01-02T15:04:05-0700"

DateFormat is the date format used throughout the app.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrType          = errors.New("wrong type")
	ErrFirstNegative = errors.New("first cannot be negative")
	ErrLastNegative  = errors.New("last cannot be negative")
	ErrNotRunning    = errors.New("project isn't running")
	ErrNotStopped    = errors.New("project isn't stopped")
)

Errors.

Functions

func CreateLineWriter

func CreateLineWriter(
	write func(ownerID, message string, a ...interface{}) string,
	ownerID string,
	a ...interface{},
) io.WriteCloser

CreateLineWriter creates a writer with a line splitter. Remember to call close().

func WithModelContext added in v0.1.5

func WithModelContext(ctx context.Context, mc *ModelContext) context.Context

WithModelContext adds a model context to a Go context.

Types

type DateTime

type DateTime time.Time

DateTime holds a date.

func (DateTime) MarshalGQL

func (d DateTime) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface.

func (*DateTime) UnmarshalGQL

func (d *DateTime) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Marshaler interface.

type DirectorySource added in v0.2.0

type DirectorySource struct {
	// The global ID of the node.
	ID string `json:"id"`
	// The IDs of the workspaces.
	WorkspaceIDs []string `json:"workspaceIds"`
	// Whether currently loading workspaces.
	IsLoading bool `json:"isLoading"`
	// The path to the directory containing the workspaces.
	Directory string `json:"directory"`
}

DirectorySource is a collection of workspaces in a directory.

func (DirectorySource) GetWorkspaceIDs added in v0.2.0

func (n DirectorySource) GetWorkspaceIDs() []string

GetWorkspaceIDs returns the IDs of the workspaces.

func (DirectorySource) IsNode added in v0.2.0

func (DirectorySource) IsNode()

IsNode tells gqlgen that it implements Node.

func (DirectorySource) IsSource added in v0.2.0

func (DirectorySource) IsSource()

IsSource tells gqlgen that it implements Source.

func (DirectorySource) Workspaces added in v0.2.0

func (n DirectorySource) Workspaces(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (WorkspaceConnection, error)

Workspaces are the workspaces using Relay pagination.

type DirectorySourceConfig added in v0.2.0

type DirectorySourceConfig struct {
	Directory string `json:"directory"`
	ID        string `json:"-" yaml:"-"`
}

DirectorySourceConfig contains all the data in a YAML directory source config file.

type GitSource added in v0.2.0

type GitSource struct {
	// The global ID of the node.
	ID string `json:"id"`
	// The IDs of the workspaces.
	WorkspaceIDs []string `json:"workspaceIds"`
	// Whether currently loading workspaces.
	IsLoading bool `json:"isLoading"`
	// The Git repository.
	Repository string `json:"repository"`
	// The Git branch.
	Branch string `json:"branch"`
}

GitSource is a collection of workspaces in a Git repository.

func (GitSource) GetWorkspaceIDs added in v0.2.0

func (n GitSource) GetWorkspaceIDs() []string

GetWorkspaceIDs returns the IDs of the workspaces.

func (GitSource) IsCloned added in v0.2.0

func (n GitSource) IsCloned(ctx context.Context) bool

IsCloned checks if the project is cloned.

func (GitSource) IsNode added in v0.2.0

func (GitSource) IsNode()

IsNode tells gqlgen that it implements Node.

func (GitSource) IsSource added in v0.2.0

func (GitSource) IsSource()

IsSource tells gqlgen that it implements Source.

func (GitSource) Workspaces added in v0.2.0

func (n GitSource) Workspaces(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (WorkspaceConnection, error)

Workspaces are the workspaces using Relay pagination.

type GitSourceConfig added in v0.2.0

type GitSourceConfig struct {
	Repository string `json:"repository"`
	Branch     string `json:"branch"`
	ID         string `json:"-" yaml:"-"`
}

GitSourceConfig contains all the data in a YAML Git source config file.

type Hash

type Hash string

Hash holds a Git hash. TODO: change to bytes.

func (Hash) MarshalGQL

func (h Hash) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface.

func (*Hash) UnmarshalGQL

func (h *Hash) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Marshaler interface.

type Job

type Job struct {
	ID        string      `json:"id"`
	Name      string      `json:"name"`
	CreatedAt DateTime    `json:"createdAt"`
	UpdatedAt DateTime    `json:"updatedAt"`
	Status    JobStatus   `json:"status"`
	Priority  JobPriority `json:"priority"`
	OwnerID   string      `json:"ownerId"`
}

Job represents a job in the app.

func (Job) IsNode

func (Job) IsNode()

IsNode tells gqlgen that it implements Node.

func (Job) Owner

func (j Job) Owner(ctx context.Context) Node

Owner returns the node associated with the job.

type JobManager

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

JobManager manages creating and running jobs.

func NewJobManager

func NewJobManager(concurrency int) *JobManager

NewJobManager creates a JobManager with given concurrency.

func (*JobManager) Add

func (j *JobManager) Add(
	modelCtx *ModelContext,
	name string,
	ownerID string,
	priority JobPriority,
	fn func(ctx context.Context) error,
) string

Add adds a job to the queue and returns the job's ID.

func (*JobManager) Stop

func (j *JobManager) Stop(modelCtx *ModelContext, id string) error

Stop cancels a running job.

func (*JobManager) Work

func (j *JobManager) Work(ctx context.Context) error

Work starts running jobs and blocks until the context is done.

type KeysConfig added in v0.3.0

type KeysConfig struct {
	Filename string            `json:"-" yaml:"-"`
	Keys     map[string]string `json:"keys" yaml:"keys"`
}

KeysConfig contains all the data in a YAML keys config file.

func LoadKeysConfigYAML added in v0.3.0

func LoadKeysConfigYAML(filename string) (*KeysConfig, error)

LoadKeysConfigYAML loads a key config from a YAML file. It will create a file if it doesn't exist.

func (*KeysConfig) DeleteKey added in v0.3.0

func (c *KeysConfig) DeleteKey(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
	id string,
) error

DeleteKey deletes a key.

func (KeysConfig) Save added in v0.3.0

func (c KeysConfig) Save() error

Save saves the config to disk, overwriting the file if it exists.

func (*KeysConfig) UpsertKey added in v0.3.0

func (c *KeysConfig) UpsertKey(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
	input KeyInput,
) string

UpsertKey upserts a key. It returns the ID of the key.

func (*KeysConfig) UpsertNodes added in v0.3.0

func (c *KeysConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
) error

UpsertNodes upserts nodes for the content of the keys config. The user node must already exists.

type LogEntry

type LogEntry struct {
	ID        string   `json:"id"`
	Level     LogLevel `json:"level"`
	CreatedAt DateTime `json:"createdAt"`
	Message   string   `json:"message"`
	OwnerID   string   `json:"ownerId"`
}

LogEntry represents a log entry in the app.

func (LogEntry) IsNode

func (LogEntry) IsNode()

IsNode tells gqlgen that it implements Node.

func (LogEntry) Owner

func (l LogEntry) Owner(ctx context.Context) Node

Owner returns the node associated with the LogEntry.

type Logger

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

Logger logs messages.

func NewLogger

func NewLogger(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	cap int,
	level LogLevel,
	systemID string,
) *Logger

NewLogger creates a Logger with given capacity and level.

func (*Logger) Add

func (l *Logger) Add(
	level LogLevel,
	ownerID string,
	message string,
) (string, error)

Add adds a log entry.

func (*Logger) Debug

func (l *Logger) Debug(message string, a ...interface{}) string

Debug adds a debug entry.

func (*Logger) DebugWithOwner

func (l *Logger) DebugWithOwner(ownerID string, message string, a ...interface{}) string

DebugWithOwner adds a debug entry with an owner.

func (*Logger) Error

func (l *Logger) Error(message string, a ...interface{}) string

Error adds an error entry.

func (*Logger) ErrorWithOwner

func (l *Logger) ErrorWithOwner(ownerID string, message string, a ...interface{}) string

ErrorWithOwner adds an error entry with an owner.

func (*Logger) Info

func (l *Logger) Info(message string, a ...interface{}) string

Info adds an info entry.

func (*Logger) InfoWithOwner

func (l *Logger) InfoWithOwner(ownerID string, message string, a ...interface{}) string

InfoWithOwner adds an info entry with an owner.

func (*Logger) Warning

func (l *Logger) Warning(message string, a ...interface{}) string

Warning adds a warning entry.

func (*Logger) WarningWithOwner

func (l *Logger) WarningWithOwner(ownerID string, message string, a ...interface{}) string

WarningWithOwner adds a warning entry with an owner.

type ModelContext added in v0.1.5

type ModelContext struct {
	Nodes               *NodeManager
	Log                 *Logger
	Jobs                *JobManager
	PM                  *ProcessManager
	Subs                *pubsub.PubSub
	Sources             *SourcesConfig
	Keys                *KeysConfig
	GetGitSourcePath    ProjectGitSourcePathGetter
	GetProjectPath      ProjectPathGetter
	GetProjectCachePath ProjectCachePathGetter
	ViewerID            string
	SystemID            string
}

ModelContext contains variables that are passed to model functions.

func GetModelContext added in v0.1.5

func GetModelContext(ctx context.Context) *ModelContext

GetModelContext retrieves the model context from a Go context.

type Node added in v0.2.0

type Node interface {
	IsNode()
	GetID() string
}

Node represents a Relay node.

type NodeManager

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

NodeManager helps manage nodes with global IDs.

func (*NodeManager) Load

func (n *NodeManager) Load(id string) (Node, bool)

Load loads a node.

func (*NodeManager) Lock

func (n *NodeManager) Lock(ids ...string)

Lock locks the given IDs.

func (*NodeManager) MustLoad

func (n *NodeManager) MustLoad(id string) Node

MustLoad loads a node or panics if it doesn't exist.

func (*NodeManager) MustLoadSource added in v0.2.0

func (n *NodeManager) MustLoadSource(id string) Source

MustLoadSource loads a Source or panics on failure.

func (*NodeManager) Unlock

func (n *NodeManager) Unlock(ids ...string)

Unlock unlocks the given IDs.

type Process

type Process struct {
	ID      string `json:"id"`
	Command string `json:"command"`
	// Env is the environment of the process.
	// Each entry is of the form "key=value".
	Env            []string      `json:"env"`
	ProcessGroupID string        `json:"processGroupId"`
	ProjectID      string        `json:"projectId"`
	Status         ProcessStatus `json:"status"`
}

Process represents a process in the app.

func (Process) IsNode

func (Process) IsNode()

IsNode tells gqlgen that it implements Node.

func (Process) ProcessGroup

func (p Process) ProcessGroup(ctx context.Context) ProcessGroup

ProcessGroup returns the ProcessGroup associated with the Process.

func (Process) Project

func (p Process) Project(ctx context.Context) Project

Project returns the Project associated with the Process.

type ProcessGroup

type ProcessGroup struct {
	ID         string   `json:"id"`
	CreatedAt  DateTime `json:"createdAt"`
	TaskID     string   `json:"taskId"`
	ProcessIDs []string `json:"processIds"`
}

ProcessGroup represents a ProcessGroup in the app.

func (ProcessGroup) IsNode

func (ProcessGroup) IsNode()

IsNode tells gqlgen that it implements Node.

func (ProcessGroup) Processes

func (p ProcessGroup) Processes(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (ProcessConnection, error)

Processes returns the ProcessGroup's processes.

func (ProcessGroup) Status

func (p ProcessGroup) Status(ctx context.Context) ProcessStatus

Status returns the status of the ProcessGroup.

func (ProcessGroup) Task

func (p ProcessGroup) Task(ctx context.Context) Task

Task returns the Task associated with the ProcessGroup.

type ProcessManager

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

ProcessManager manages creating and running jobs.

func NewProcessManager

func NewProcessManager() *ProcessManager

NewProcessManager creates a ProcessManager.

func (*ProcessManager) Clean

func (p *ProcessManager) Clean(ctx context.Context)

Clean terminates all running processes.

func (*ProcessManager) CreateGroup

func (p *ProcessManager) CreateGroup(ctx context.Context, taskID string) string

CreateGroup creates a new ProcessGroup and returns its ID.

func (*ProcessManager) Run

func (p *ProcessManager) Run(
	ctx context.Context,
	command string,
	env []string,
	processGroupID string,
	projectID string,
) string

Run launches a new Process and adds it to a ProcessGroup.

func (*ProcessManager) Start

func (p *ProcessManager) Start(ctx context.Context, processID string) error

Start starts a process that was stopped.

func (*ProcessManager) Stop

func (p *ProcessManager) Stop(ctx context.Context, processID string) error

Stop stops a running process.

type Project

type Project struct {
	ID               string   `json:"id"`
	Slug             string   `json:"slug"`
	Repository       string   `json:"repository"`
	Branch           string   `json:"branch"`
	Description      *string  `json:"description"`
	WorkspaceID      string   `json:"workspaceId"`
	CommitIDs        []string `json:"commitIds"`
	Tasks            []Task   `json:"projects"`
	IsLoadingCommits bool     `json:"isLoadingCommits"`
	IsCloning        bool     `json:"isCloning"`
	IsPulling        bool     `json:"isPulling"`
	IsBehind         bool     `json:"isBehind"`
	IsAhead          bool     `json:"isAhead"`
}

Project represents a project in the app.

func (Project) Commits

func (p Project) Commits(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (CommitConnection, error)

Commits returns paginated commits.

func (Project) IsCloned

func (p Project) IsCloned(ctx context.Context) bool

IsCloned checks if the project is cloned.

func (Project) IsNode

func (Project) IsNode()

IsNode tells gqlgen that it implements Node.

func (Project) Workspace

func (p Project) Workspace(ctx context.Context) Workspace

Workspace returns the workspace associated with the project.

type ProjectCachePathGetter added in v0.1.5

type ProjectCachePathGetter func(workspaceSlug, repo, branch string) string

ProjectCachePathGetter is a function that returns the path to a project's cache.

type ProjectConfig added in v0.2.0

type ProjectConfig struct {
	Slug        string  `json:"slug"`
	Repository  string  `json:"repository"`
	Branch      string  `json:"branch"`
	Description *string `json:"description"`
}

ProjectConfig contains all the data in a YAML project config file.

func (ProjectConfig) UpsertNodes added in v0.2.0

func (c ProjectConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	workspaceID string,
	workspaceSlug string,
) string

UpsertNodes upserts nodes for the content of the config. It returns the ID of the project upserted.

type ProjectGitSourcePathGetter added in v0.2.0

type ProjectGitSourcePathGetter func(repo, branch string) string

ProjectGitSourcePathGetter is a function that returns the path to a Git source.

type ProjectPathGetter

type ProjectPathGetter func(workspaceSlug, repo, branch string) string

ProjectPathGetter is a function that returns the path to a project.

type Source added in v0.2.0

type Source interface {
	Node
	IsSource()

	// GetWorkspaceIDs returns the IDs of the workspaces.
	GetWorkspaceIDs() []string

	// Workspaces are the workspaces using Relay pagination.
	Workspaces(
		ctx context.Context,
		after *string,
		before *string,
		first *int,
		last *int,
	) (WorkspaceConnection, error)
}

Source is a collection of workspaces.

type SourcesConfig added in v0.2.0

type SourcesConfig struct {
	Filename         string                  `json:"-" yaml:"-"`
	DirectorySources []DirectorySourceConfig `json:"directorySources" yaml:"directory-sources"`
	GitSources       []GitSourceConfig       `json:"gitSources" yaml:"git-sources"`
}

SourcesConfig contains all the data in a YAML sources config file.

func LoadSourcesConfigYAML added in v0.2.0

func LoadSourcesConfigYAML(filename string) (*SourcesConfig, error)

LoadSourcesConfigYAML loads a source config from a YAML file. It will create a file if it doesn't exist.

func (*SourcesConfig) DeleteSource added in v0.2.0

func (c *SourcesConfig) DeleteSource(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
	id string,
) error

DeleteSource deletes a source.

func (SourcesConfig) Save added in v0.2.0

func (c SourcesConfig) Save() error

Save saves the config to disk, overwriting the file if it exists.

func (*SourcesConfig) UpsertDirectorySource added in v0.2.0

func (c *SourcesConfig) UpsertDirectorySource(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
	input DirectorySourceInput,
) string

UpsertDirectorySource upserts a directory source. It returns the ID of the source.

func (*SourcesConfig) UpsertGitSource added in v0.2.0

func (c *SourcesConfig) UpsertGitSource(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
	input GitSourceInput,
) string

UpsertGitSource upserts a repository source. It returns the ID of the source.

func (*SourcesConfig) UpsertNodes added in v0.2.0

func (c *SourcesConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	userID string,
) error

UpsertNodes upserts nodes for the content of the sources config. The user node must already exists.

type Step

type Step struct {
	ID         string   `json:"id"`
	ProjectIDs []string `json:"projectIds"`
	CommandIDs []string `json:"commandIds"`
	TaskID     string   `json:"taskId"`
}

Step represents a task step in the app.

func (Step) Commands

func (s Step) Commands(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (CommandConnection, error)

Commands returns the step's commands.

func (Step) IsNode

func (Step) IsNode()

IsNode tells gqlgen that it implements Node.

func (Step) Projects

func (s Step) Projects(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (ProjectConnection, error)

Projects returns the step's projects.

func (Step) Task

func (s Step) Task(ctx context.Context) Task

Task returns the step's taks.

type StepConfig added in v0.2.0

type StepConfig struct {
	Projects []string `json:"projects"`
	Commands []string `json:"commands"`
}

StepConfig contains all the data in a YAML step config file.

func (StepConfig) UpsertNodes added in v0.2.0

func (c StepConfig) UpsertNodes(
	nodes *NodeManager,
	workspaceSlug string,
	taskID string,
	taskName string,
	stepIndex int,
	projectSlugToID map[string]string,
) (string, error)

UpsertNodes upserts nodes for the content of the config. It returns the ID of the step upserted.

type System

type System struct {
	ID               string   `json:"id"`
	JobIDs           []string `json:"jobsIds"`
	JobMetricsID     string   `json:"jobMetricsId"`
	ProcessGroupIDs  []string `json:"processGroupIds"`
	ProcessMetricsID string   `json:"processMetricsId"`
	LogEntryIDs      []string `json:"logEntryIds"`
	LogMetricsID     string   `json:"logMetricsId"`
}

System contains information about the running app.

func (System) IsNode

func (System) IsNode()

IsNode tells gqlgen that it implements Node.

func (System) JobMetrics

func (s System) JobMetrics(ctx context.Context) JobMetrics

JobMetrics returns the JobMetrics node.

func (System) Jobs

func (s System) Jobs(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
	status []JobStatus,
) (JobConnection, error)

Jobs returns paginated jobs.

func (System) LastMessageID added in v0.2.2

func (s System) LastMessageID(ctx context.Context) string

LastMessageID is the ID of the last message which can be used for subscriptions.

func (System) LogEntries

func (s System) LogEntries(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
	level []LogLevel,
	ownerID *string,
) (LogEntryConnection, error)

LogEntries returns paginated log entries.

func (System) LogMetrics

func (s System) LogMetrics(ctx context.Context) LogMetrics

LogMetrics returns the LogMetrics node.

func (System) ProcessGroups

func (s System) ProcessGroups(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
	status []ProcessStatus,
) (ProcessGroupConnection, error)

ProcessGroups returns paginated process groups.

func (System) ProcessMetrics

func (s System) ProcessMetrics(ctx context.Context) ProcessMetrics

ProcessMetrics returns the ProcessMetrics node.

type Task

type Task struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	VariableIDs []string `json:"variableIds"`
	StepIDs     []string `json:"stepIds"`
	WorkspaceID string   `json:"workspace"`
	IsRunning   bool     `json:"isRunning"`
}

Task represents a workspace task in the app.

func (Task) IsNode

func (Task) IsNode()

IsNode tells gqlgen that it implements Node.

func (Task) Steps

func (t Task) Steps(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (StepConnection, error)

Steps returns the task's steps.

func (Task) Variables added in v0.3.0

func (t Task) Variables(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (VariableConnection, error)

Variables returns the task's variables.

func (Task) Workspace

func (t Task) Workspace(ctx context.Context) Workspace

Workspace returns the task's workspace.

type TaskConfig added in v0.2.0

type TaskConfig struct {
	Name      string           `json:"name"`
	Variables []VariableConfig `json:"variables"`
	Steps     []StepConfig     `json:"tasks"`
}

TaskConfig contains all the data in a YAML task config file.

func (TaskConfig) UpsertNodes added in v0.2.0

func (c TaskConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
	workspaceID string,
	workspaceSlug string,
	projectSlugToID map[string]string,
) (string, error)

UpsertNodes upserts nodes for the content of the config. It returns the ID of the task upserted.

type User

type User struct {
	ID        string   `json:"id"`
	SourceIDs []string `json:"sourceIds"`
	KeyIDs    []string `json:"keyIds"`
}

User contains all the data of the person using the app.

func (User) IsNode

func (User) IsNode()

IsNode tells gqlgen that it implements Node.

func (User) Keys added in v0.3.0

func (u User) Keys(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (KeyConnection, error)

Keys returns the user's keys.

func (User) Projects

func (u User) Projects(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (ProjectConnection, error)

Projects returns the user's projects.

func (User) Sources added in v0.2.0

func (u User) Sources(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (SourceConnection, error)

Sources returns the user's sources.

func (User) Workspace

func (u User) Workspace(ctx context.Context, slug string) *Workspace

Workspace finds a workspace.

func (User) WorkspaceIDs

func (u User) WorkspaceIDs(ctx context.Context) []string

WorkspaceIDs returns the user's workspace IDs.

func (User) Workspaces

func (u User) Workspaces(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (WorkspaceConnection, error)

Workspaces returns the user's workspaces.

type VariableConfig added in v0.3.0

type VariableConfig struct {
	Name    string  `json:"name"`
	Default *string `json:"default"`
}

VariableConfig contains all the data in a YAML variable config file.

func (VariableConfig) UpsertNodes added in v0.3.0

func (c VariableConfig) UpsertNodes(
	nodes *NodeManager,
	workspaceSlug string,
	taskID string,
	taskName string,
	stepIndex int,
) string

UpsertNodes upserts nodes for the content of the config. It returns the ID of the variable upserted.

type Workspace

type Workspace struct {
	ID          string   `json:"id"`
	Slug        string   `json:"slug"`
	Name        string   `json:"name"`
	ProjectIDs  []string `json:"projectIds"`
	TaskIDs     []string `json:"taskIds"`
	Description string   `json:"description"`
	Notes       *string  `json:"notes"`
}

Workspace represents a workspace in the app.

func (Workspace) IsAhead

func (w Workspace) IsAhead(ctx context.Context) bool

IsAhead returns true if any of the projects is ahead origin.

func (Workspace) IsBehind

func (w Workspace) IsBehind(ctx context.Context) bool

IsBehind returns true if any of the projects is behind origin.

func (Workspace) IsCloned

func (w Workspace) IsCloned(ctx context.Context) bool

IsCloned returns true if all the projects are cloned.

func (Workspace) IsCloning

func (w Workspace) IsCloning(ctx context.Context) bool

IsCloning returns true if any of the projects is cloning.

func (Workspace) IsNode

func (Workspace) IsNode()

IsNode tells gqlgen that it implements Node.

func (Workspace) IsPulling

func (w Workspace) IsPulling(ctx context.Context) bool

IsPulling returns true if any of the projects is pulling.

func (Workspace) Projects

func (w Workspace) Projects(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (ProjectConnection, error)

Projects returns the workspace's projects.

func (Workspace) Tasks

func (w Workspace) Tasks(
	ctx context.Context,
	after *string,
	before *string,
	first *int,
	last *int,
) (TaskConnection, error)

Tasks returns the workspace's tasks.

type WorkspaceConfig added in v0.2.0

type WorkspaceConfig struct {
	Slug        string          `json:"slug"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Notes       *string         `json:"notes"`
	Projects    []ProjectConfig `json:"projects" yaml:",flow"`
	Tasks       []TaskConfig    `json:"tasks"`
}

WorkspaceConfig contains all the data in a YAML workspace config file.

func (WorkspaceConfig) UpsertNodes added in v0.2.0

func (c WorkspaceConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
) (string, error)

UpsertNodes upserts nodes for the content of the config. It returns the ID of the workspace upserted.

type WorkspacesConfig added in v0.2.0

type WorkspacesConfig struct {
	Filename   string            `json:"-" yaml:"-"`
	Workspaces []WorkspaceConfig `json:"workspaces"`
}

WorkspacesConfig contains all the data in a YAML workspaces config file.

func LoadWorkspacesConfigYAML added in v0.2.0

func LoadWorkspacesConfigYAML(filename string) (WorkspacesConfig, error)

LoadWorkspacesConfigYAML loads a config from a YAML file.

func (WorkspacesConfig) UpsertNodes added in v0.2.0

func (c WorkspacesConfig) UpsertNodes(
	nodes *NodeManager,
	subs *pubsub.PubSub,
) ([]string, error)

UpsertNodes upserts nodes for the content of the config. It returns the IDs of the workspaces upserted.

Jump to

Keyboard shortcuts

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