models

package
v0.0.0-...-67365ed Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID     primitive.ObjectID `json:"id" bson:"_id"`
	UserID primitive.ObjectID `json:"-" bson:"user_id"`

	Token            string           `json:"token" bson:"token"`
	Provider         Provider         `json:"provider" bson:"provider"`
	BuildOptions     BuildOptions     `json:"build_options" validate:"required" bson:"build_options"`
	ContainerOptions ContainerOptions `json:"container_options" bson:"container_options"`
	Owner            string           `json:"owner" bson:"owner"`
	Name             string           `json:"name" bson:"name"`

	ContainerID string `json:"-" bson:"container_id"`
	State       State  `json:"state" bson:"state"`

	CompleteURL string `json:"complete_url" bson:"complete_url"`
	URL         string `json:"url" bson:"url"`

	LastBuild Build     `json:"last_build" bson:"-"` // Dynamic
	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
}

App struct

func (*App) Save

func (app *App) Save() error

Save deployment

func (*App) SaveBuildOptions

func (app *App) SaveBuildOptions(options BuildOptions) error

SaveBuildOptions : set app build options

func (*App) SaveContainerOptions

func (app *App) SaveContainerOptions(options ContainerOptions) error

SaveContainerOptions : set app container options

func (*App) SetContainerID

func (app *App) SetContainerID(id string) error

SetContainerID util function

func (*App) SetState

func (app *App) SetState(state State) error

SetState : set app state

func (*App) Validate

func (app *App) Validate() error

Validate deployment

type Build

type Build struct {
	ID     primitive.ObjectID `json:"id" bson:"_id"`
	AppID  primitive.ObjectID `json:"app_id" bson:"app_id"`
	UserID primitive.ObjectID `json:"user_id" bson:"user_id"`

	Branch        string   `json:"branch" bson:"branch"`
	CommitHash    string   `json:"commit_hash" bson:"commit_hash"`
	CommitMessage string   `json:"commit_message" bson:"commit_message"`
	Logs          []string `json:"logs" bson:"logs"`

	Status DeployStatus `json:"status" bson:"status"`
	Error  string       `json:"error" bson:"error"`

	CreatedAt time.Time `json:"created_at" bson:"created_at"`
}

Build struct

func (*Build) Create

func (b *Build) Create() error

Create build

func (*Build) Log

func (b *Build) Log(log string) error

Log build details

func (*Build) SetCommit

func (b *Build) SetCommit(hash string, message string) error

SetCommit of build

func (*Build) SetStatus

func (b *Build) SetStatus(status DeployStatus, errorMessage string) error

SetStatus of build

type BuildOptions

type BuildOptions struct {
	Branch string   `json:"branch" bson:"branch"`
	Env    []EnvVar `json:"env" bson:"env"`
}

BuildOptions struct

type ContainerOptions

type ContainerOptions struct {
	MaxRAM int64 `json:"max_ram" bson:"max_ram"`
}

type ContainerStats

type ContainerStats struct {
	RAMUsage int64   `json:"ram_usage"`
	MaxRAM   int64   `json:"max_ram"`
	CPU      float64 `json:"cpu_usage"`
}

ContainerStats struct

type DeployStatus

type DeployStatus int
const (
	Building DeployStatus = iota
	Deploying
	Deployed
	Idle
	BuildError
	DeployError
)

type EnvVar

type EnvVar struct {
	Key   string `json:"key" bson:"key"`
	Value string `json:"value" bson:"value"`
}

EnvVar struct

type Profile

type Profile struct {
	ID        primitive.ObjectID `json:"id"`
	Username  string             `json:"username"`
	Email     string             `json:"email"`
	UpdatedAt time.Time          `json:"updated_at"`
	CreatedAt time.Time          `json:"created_at"`
}

Profile struct

type Provider

type Provider int
const (
	GitHubProvider Provider = iota
	GitLabProvider
	BitBucketProvider
)

type State

type State string
const (
	Stopped State = "stopped"
	Running State = "running"
)

type User

type User struct {
	ID primitive.ObjectID `json:"id" bson:"_id"`

	Username string `json:"username" bson:"username"`
	Email    string `json:"email" bson:"email" validate:"required,email"`
	Password string `json:"password" bson:"password" validate:"required"`

	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
}

User struct

func (*User) HashPassword

func (u *User) HashPassword()

HashPassword hash user's password

func (*User) Public

func (u *User) Public() Profile

Public returns public data

func (*User) Save

func (u *User) Save() error

Save to db

func (*User) Validate

func (u *User) Validate() error

Validate user

Jump to

Keyboard shortcuts

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