djinn

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WebhookEvents = []string{
	"build.submitted",
	"build.tagged",
	"invite.sent",
	"invite.accepted",
	"invite.rejected",
	"namespaces",
	"cron",
	"images",
	"objects",
	"variables",
	"ssh_keys",
}

Functions

This section is empty.

Types

type Build

type Build struct {
	ID           int64         `json:"id"`
	UserID       int64         `json:"user_id"`
	NamespaceID  NullInt64     `json:"namespace_id"`
	Number       int64         `json:"number"`
	Manifest     string        `json:"manifest"`
	Status       Status        `json:"status"`
	Output       NullString    `json:"output"`
	Tags         []string      `json:"tags"`
	CreatedAt    Time          `json:"created_at"`
	StartedAt    NullTime      `json:"started_at"`
	FinishedAt   NullTime      `json:"finished_at"`
	URL          URL           `json:"url"`
	ObjectsURL   URL           `json:"objects_url"`
	VariablesURL URL           `json:"variables_url"`
	JobsURL      URL           `json:"jobs_url"`
	ArtifactsURL URL           `json:"artifacts_url"`
	TagsURL      URL           `json:"tags_url"`
	User         *User         `json:"user"`
	Trigger      *BuildTrigger `json:"trigger"`
	Namespace    *Namespace    `json:"namespace"`
}

func GetBuild

func GetBuild(cli *Client, owner string, number int64) (*Build, error)

func SubmitBuild

func SubmitBuild(cli *Client, p BuildParams) (*Build, error)

func (*Build) Get

func (b *Build) Get(cli *Client) error

func (*Build) Kill

func (b *Build) Kill(cli *Client) error

func (*Build) Tag

func (b *Build) Tag(cli *Client, tags ...string) ([]*BuildTag, error)

type BuildParams

type BuildParams struct {
	Manifest Manifest `json:"manifest"`
	Comment  string   `json:"comment"`
	Tags     []string `json:"tags"`
}

type BuildTag

type BuildTag struct {
	ID        int64  `json:"id"`
	UserID    int64  `json:"user_id"`
	BuildID   int64  `json:"build_id"`
	Name      string `json:"name"`
	CreatedAt Time   `json:"created_at"`
	URL       URL    `json:"url"`
}

func (*BuildTag) Delete

func (t *BuildTag) Delete(cli *Client) error

type BuildTrigger

type BuildTrigger struct {
	Type    string            `json:"type"`
	Comment string            `json:"comment"`
	Data    map[string]string `json:"data"`
}

type Client

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

func NewClient

func NewClient(tok, endpoint string) (*Client, error)

func NewClientWithLogger

func NewClientWithLogger(tok, endpoint string, log Logger) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(url string) (*http.Response, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(url, accept string) (*http.Response, error)

func (*Client) Patch

func (c *Client) Patch(url, contentType string, body io.Reader) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(url, contentType string, body io.Reader) (*http.Response, error)

func (*Client) String

func (c *Client) String() string

String returns the string representation of the client, this will look something like &djinn.Client{endpoint: endpoint, tok: tok}. This would typically be used during logging.

type Cron

type Cron struct {
	ID          int64     `json:"id"`
	AuthorID    int64     `json:"author_id"`
	UserID      int64     `json:"user_id"`
	NamespaceID NullInt64 `json:"namespace_id"`
	Name        string    `json:"name"`
	Schedule    Schedule  `json:"schedule"`
	Manifest    Manifest  `json:"manifest"`
	NextRun     Time      `json:"next_run"`
	CreatedAt   Time      `json:"created_at"`
	URL         URL       `json:"url"`
}

func CreateCron

func CreateCron(cli *Client, p CronParams) (*Cron, error)

func (*Cron) Delete

func (c *Cron) Delete(cli *Client) error

func (*Cron) Get

func (c *Cron) Get(cli *Client) error

func (*Cron) Update

func (c *Cron) Update(cli *Client, p CronParams) error

type CronParams

type CronParams struct {
	Name     string   `json:"name"`
	Schedule Schedule `json:"schedule"`
	Manifest Manifest `json:"manifest"`
}

type Driver

type Driver uint8
const (
	DriverSSH    Driver = iota // ssh
	DriverQEMU                 // qemu
	DriverDocker               // docker
)

func (*Driver) MarshalJSON

func (d *Driver) MarshalJSON() ([]byte, error)

func (Driver) String

func (i Driver) String() string

func (*Driver) UnmarshalJSON

func (d *Driver) UnmarshalJSON(p []byte) error

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(p []byte) error

type Error

type Error struct {
	StatusCode int
	Message    string
	Params     map[string][]string
}

func (*Error) Error

func (e *Error) Error() string

type Image

type Image struct {
	ID          int64          `json:"id"`
	AuthorID    int64          `json:"author_id"`
	UserID      int64          `json:"user_id"`
	NamespaceID NullInt64      `json:"namespace_id"`
	Driver      Driver         `json:"driver"`
	Name        string         `json:"name"`
	CreatedAt   Time           `json:"created_at"`
	URL         URL            `json:"url"`
	Download    *ImageDownload `json:"download"`
}

func CreateImage

func CreateImage(cli *Client, p ImageParams) (*Image, error)

func GetImage

func GetImage(cli *Client, id int64) (*Image, error)

func (*Image) Data

func (i *Image) Data(cli *Client) (io.ReadCloser, error)

func (*Image) Delete

func (i *Image) Delete(cli *Client) error

func (*Image) Get

func (i *Image) Get(cli *Client) error

type ImageDownload

type ImageDownload struct {
	Source     URL        `json:"source"`
	Error      NullString `json:"error"`
	CreatedAt  Time       `json:"created_at"`
	StartedAt  NullTime   `json:"started_at"`
	FinishedAt NullTime   `json:"finished_at"`
}

type ImageParams

type ImageParams struct {
	Namespace   string    `json:"namespace"`
	Image       io.Reader `json:"-"`
	Name        string    `json:"name"`
	DownloadURL string    `json:"download_url"`
}

type Invite

type Invite struct {
	ID          int64      `json:"id"`
	NamespaceID int64      `json:"namespace_id"`
	InviteeID   int64      `json:"invitee_id"`
	InviterID   int64      `json:"inviter_id"`
	URL         URL        `json:"url"`
	Invitee     *User      `json:"invitee"`
	Inviter     *User      `json:"inviter"`
	Namespace   *Namespace `json:"namespace"`
}

func (*Invite) Accept

func (i *Invite) Accept(cli *Client) error

func (*Invite) Reject

func (i *Invite) Reject(cli *Client) error

type Key

type Key struct {
	ID          int64     `json:"id"`
	AuthorID    int64     `json:"author_id"`
	UserID      int64     `json:"user_id"`
	NamespaceID NullInt64 `json:"namespace_id"`
	Name        string    `json:"name"`
	Config      string    `json:"config"`
	CreatedAt   Time      `json:"created_at"`
	UpdatedAt   Time      `json:"updated_at"`
	URL         URL       `json:"url"`
}

func CreateKey

func CreateKey(cli *Client, p KeyParams) (*Key, error)

func GetKey

func GetKey(cli *Client, id int64) (*Key, error)

func (*Key) Delete

func (k *Key) Delete(cli *Client) error

func (*Key) Get

func (k *Key) Get(cli *Client) error

func (*Key) Update

func (k *Key) Update(cli *Client, p KeyParams) error

type KeyParams

type KeyParams struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
	Key       string `json:"key"`
	Config    string `json:"config"`
}

type Logger

type Logger interface {
	Log(args ...interface{})
}

type Manifest

type Manifest struct {
	Namespace     string
	Driver        map[string]string
	Env           []string
	Objects       ManifestPassthrough
	Sources       []ManifestSource
	Stages        []string
	AllowFailures []string `yaml:"allow_failures"`
	Jobs          []ManifestJob
}

func (Manifest) MarshalJSON

func (m Manifest) MarshalJSON() ([]byte, error)

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(p []byte) error

type ManifestJob

type ManifestJob struct {
	Stage     string
	Name      string
	Commands  []string
	Artifacts ManifestPassthrough
}

type ManifestPassthrough

type ManifestPassthrough map[string]string

func (ManifestPassthrough) MarshalYAML

func (m ManifestPassthrough) MarshalYAML() (interface{}, error)

func (*ManifestPassthrough) UnmarshalYAML

func (m *ManifestPassthrough) UnmarshalYAML(unmarshal func(interface{}) error) error

type ManifestSource

type ManifestSource struct {
	URL string
	Ref string
	Dir string
}

func (ManifestSource) MarshalYAML

func (s ManifestSource) MarshalYAML() (interface{}, error)

func (*ManifestSource) UnmarshalYAML

func (s *ManifestSource) UnmarshalYAML(unmarshal func(interface{}) error) error

type Namespace

type Namespace struct {
	ID               int64      `json:"id"`
	UserID           int64      `json:"user_id"`
	RootID           int64      `json:"root_id"`
	ParentID         NullInt64  `json:"parent_id"`
	Name             string     `json:"name"`
	Path             string     `json:"path"`
	Description      string     `json:"description"`
	Visibility       Visibility `json:"visibility"`
	CreatedAt        Time       `json:"created_at"`
	URL              URL        `json:"url"`
	BuildsURL        URL        `json:"builds_url"`
	NamespacesURL    URL        `json:"namespaces_url"`
	ImagesURL        URL        `json:"images_url"`
	ObjectsURL       URL        `json:"objects_url"`
	VariablesURL     URL        `json:"variables_url"`
	KeysURL          URL        `json:"keys_url"`
	InvitesURL       URL        `json:"invites_url"`
	CollaboratorsURL URL        `json:"collaborators_url"`
	WebhooksURL      URL        `json:"webhooks_url"`
	User             *User      `json:"user"`
	Parent           *Namespace `json:"parent"`
	Build            *Build     `json:"build"`
}

func CreateNamespace

func CreateNamespace(cli *Client, p NamespaceParams) (*Namespace, error)

func GetNamespace

func GetNamespace(cli *Client, owner, path string) (*Namespace, error)

func (*Namespace) CreateWebhook

func (n *Namespace) CreateWebhook(cli *Client, p WebhookParams) (*Webhook, error)

func (*Namespace) Delete

func (n *Namespace) Delete(cli *Client) error

func (*Namespace) DeleteCollaborator

func (n *Namespace) DeleteCollaborator(cli *Client, username string) error

func (*Namespace) Get

func (n *Namespace) Get(cli *Client) error

func (*Namespace) Invite

func (n *Namespace) Invite(cli *Client, handle string) (*Invite, error)

func (*Namespace) Update

func (n *Namespace) Update(cli *Client, p NamespaceParams) error

type NamespaceParams

type NamespaceParams struct {
	Parent      string     `json:"parent"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Visibility  Visibility `json:"visibility"`
}

type NullInt64

type NullInt64 struct {
	Int64 int64
	Valid bool
}

func (*NullInt64) MarshalJSON

func (n *NullInt64) MarshalJSON() ([]byte, error)

func (*NullInt64) UnmarshalJSON

func (n *NullInt64) UnmarshalJSON(p []byte) error

type NullString

type NullString struct {
	String string
	Valid  bool
}

func (*NullString) MarshalJSON

func (n *NullString) MarshalJSON() ([]byte, error)

func (*NullString) UnmarshalJSON

func (n *NullString) UnmarshalJSON(p []byte) error

type NullTime

type NullTime struct {
	Time  Time
	Valid bool
}

func (*NullTime) MarshalJSON

func (n *NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) UnmarshalJSON

func (n *NullTime) UnmarshalJSON(p []byte) error

type Object

type Object struct {
	ID          int64     `json:"id"`
	AuthorID    int64     `json:"author_id"`
	UserID      int64     `json:"user_id"`
	NamespaceID NullInt64 `json:"namespace_id"`
	Name        string    `json:"name"`
	Type        string    `json:"type"`
	Size        int64     `json:"size"`
	MD5         string    `json:"md5"`
	SHA256      string    `json:"sha256"`
	CreatedAt   Time      `json:"created_at"`
	URL         URL       `json:"url"`
}

func CreateObject

func CreateObject(cli *Client, p ObjectParams) (*Object, error)

func (*Object) Data

func (o *Object) Data(cli *Client) (io.ReadCloser, error)

func (*Object) Delete

func (o *Object) Delete(cli *Client) error

type ObjectParams

type ObjectParams struct {
	Namespace string    `json:"-"`
	Object    io.Reader `json:"-"`
	Name      string    `json:"-"`
}

type Schedule

type Schedule uint
const (
	Daily   Schedule = iota // daily
	Weekly                  // weekly
	Monthly                 // monthly
)

func (Schedule) MarshalJSON

func (s Schedule) MarshalJSON() ([]byte, error)

func (Schedule) String

func (i Schedule) String() string

func (*Schedule) UnmarshalJSON

func (s *Schedule) UnmarshalJSON(p []byte) error

type Status

type Status uint8
const (
	Queued             Status = iota // queued
	Running                          // running
	Passed                           // passed
	PassedWithFailures               // passed_with_failures
	Failed                           // failed
	Killed                           // killed
	TimedOut                         // timed_out
)

func (Status) String

func (i Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(p []byte) error

type Time

type Time struct {
	time.Time
}

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(p []byte) error

type URL

type URL struct {
	*url.URL
}

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(p []byte) error

type User

type User struct {
	ID        int64  `json:"id"`
	Email     string `json:"email"`
	Username  string `json:"username"`
	CreatedAt Time   `json:"created_at"`
}

type Variable

type Variable struct {
	ID          int64      `json:"id"`
	AuthorID    int64      `json:"author_id"`
	UserID      int64      `json:"user_id"`
	NamespaceID NullInt64  `json:"namespace_id"`
	Key         string     `json:"key"`
	Value       string     `json:"value"`
	CreatedAt   Time       `json:"created_at"`
	URL         URL        `json:"url"`
	Namespace   *Namespace `json:"namespace"`
}

func CreateVariable

func CreateVariable(cli *Client, p VariableParams) (*Variable, error)

func (*Variable) Delete

func (v *Variable) Delete(cli *Client) error

func (*Variable) Get

func (v *Variable) Get(cli *Client) error

type VariableParams

type VariableParams struct {
	Namespace string `json:"namespace"`
	Key       string `json:"key"`
	Value     string `json:"value"`
}

type Visibility

type Visibility uint8
const (
	Private  Visibility = iota // private
	Internal                   // internal
	Public                     // public
)

func (Visibility) MarshalJSON

func (v Visibility) MarshalJSON() ([]byte, error)

func (Visibility) String

func (i Visibility) String() string

func (*Visibility) UnmarshalJSON

func (v *Visibility) UnmarshalJSON(p []byte) error

type Webhook

type Webhook struct {
	ID           int64            `json:"id"`
	AuthorID     int64            `json:"author_id"`
	UserID       int64            `json:"user_id"`
	NamespaceID  NullInt64        `json:"namespace_id"`
	PayloadURL   URL              `json:"payload_url"`
	SSL          bool             `json:"ssl"`
	Active       bool             `json:"active"`
	URL          URL              `json:"url"`
	Events       []string         `json:"events"`
	LastResponse *WebhookResponse `json:"last_response"`
}

func (*Webhook) Update

func (wh *Webhook) Update(cli *Client, p WebhookParams) error

type WebhookParams

type WebhookParams struct {
	PayloadURL   string   `json:"payload_url"`
	Secret       string   `json:"secret"`
	RemoveSecret bool     `json:"remove_secret"`
	SSL          bool     `json:"ssl"`
	Active       bool     `json:"active"`
	Events       []string `json:"events"`
}

type WebhookResponse

type WebhookResponse struct {
	Error     NullString `json:"error"`
	Code      int        `json:"code"`
	Duration  Duration   `json:"duration"`
	CreatedAt Time       `json:"created_at"`
}

Jump to

Keyboard shortcuts

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