model

package
v0.0.0-...-1927dbb Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TaskStatusDefault means task is currently created.
	TaskStatusDefault uint = iota
	// TaskStatusProcessing means task is under processing.
	TaskStatusProcessing
	// TaskStatusSucc means task is executed success.
	TaskStatusSucc
	// TaskStatusFail means task is executed fail.
	TaskStatusFail
)
View Source
const (
	// FormString means variable is an input item of string
	FormString = iota + 1
	// FormNumber means variable is an input item of number
	FormNumber
	// Percentage means variable is an input item of percentage range
	FormPercentage
	// FormSelect means variable is an select item
	FormSelect
	// FormDatetime means variable is an datetime picker item
	FormDatetime
)

VarFormType defines variable's type in a submitted form.

Variables

View Source
var (
	// ErrInvalidType is returned when the client sent wrong template type.
	ErrInvalidType = errors.New("invalid template type")
	// ErrJSONUnmarshal is returned when JSON message can't be unmarshal.
	ErrJSONUnmarshal = errors.New("JSON unmarshal fail")
)
View Source
var MockUsers = map[string]User{
	"admin": {
		ID:       1,
		Name:     "admin",
		Password: "admin",
	},
	"user": {
		ID:       2,
		Name:     "user",
		Password: "user",
	},
	"test-01": {
		ID:       3,
		Name:     "test-01",
		Password: "test-01",
	},
	"test-02": {
		ID:       4,
		Name:     "test-02",
		Password: "test-02",
	},
}

MockUsers stores some fake users.

Functions

func ExecTmpl

func ExecTmpl(tasktmpl TaskTmpl, varMap string) (content string, e error)

ExecTmpl executes template and returns outputs.

Types

type Task

type Task struct {
	ID         uint       `json:"id" gorm:"primary_key"`
	CreatedAt  time.Time  `json:"createAt"`
	UpdatedAt  time.Time  `json:"updateAt"`
	DeletedAt  *time.Time `json:"deleteAt" sql:"index"`
	Content    string     `json:"content"`
	Revision   uint       `json:"revision"`
	Operator   string     `json:"operator"`
	TaskTmplID uint       `json:"taskTmplID"`
	ServiceUID string     `json:"serviceUID"`
	Status     uint       `json:"status"`
	TaskTmpl   TaskTmpl   `gorm:"ForeignKey:TaskTmplID"`
	Command    TaskCmd    `json:"command"`
	PrevState  string     `json:"prevState"`
	Namespace  string     `json:"namespace"`
}

Task defines fields of table `tasks`.

type TaskCmd

type TaskCmd int

TaskCmd defines istioctl subcommand.

const (
	// Apply combines Create command and Replace Command,
	// Apply command will try "replace" command first, if the command goes wrong, we try "Create" command later.
	Apply TaskCmd = iota + 1
	// Create represents istioctl "create" subcommand.
	Create
	// Replace represents istioctl "create" subcommand.
	Replace
	// Delete represents istioctl "delete" subcommand.
	Delete
	// Rollback rollbacks task with prev istio resource yaml.
	Rollback
)

type TaskTmpl

type TaskTmpl struct {
	ID        uint          `json:"id" gorm:"primary_key"`
	CreatedAt time.Time     `json:"createAt"`
	UpdatedAt time.Time     `json:"updateAt"`
	DeletedAt *time.Time    `json:"deleteAt" sql:"index"`
	Name      string        `json:"name"`
	Content   string        `json:"content"`
	Brief     string        `json:"brief"`
	Revision  uint          `json:"revision"`
	Operator  string        `json:"operator"`
	Icon      string        `json:"icon"`
	VarMap    []TaskTmplVar `json:"varMap" gorm:"-"`
}

TaskTmpl defines fields of table `task_tmpls`.

type TaskTmplVar

type TaskTmplVar struct {
	TaskTmplID uint        `json:"taskTmplID" gorm:"task_tmpl_id"`
	Name       string      `json:"name"`
	Title      string      `json:"title"`
	Comment    string      `json:"comment"`
	FormType   uint        `json:"formType"`
	DataSource string      `json:"dataSource" gorm:"column:data_source"`
	Default    string      `json:"default"`
	Data       interface{} `json:"data" gorm:"-"`
}

TaskTmplVar defines template variable fields.

type User

type User struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	DepID    int    `json:"depId"`
	Email    string `json:"email"`
	NickName string `json:"nickname"`
	Password string `json:"password"`
}

User defines user information.

type Var

type Var struct {
	Name       string      `json:"name"`
	Title      string      `json:"comment" gorm:"column:title"`
	Type       string      `json:"type" gorm:"column:form_type"`
	DataSource interface{} `json:"value" gorm:"column:data_source"`
}

Var defines template variable fields.

type VarType

type VarType int

VarType defines variable's type.

const (
	// String means variable is a string.
	String VarType = iota + 1
	// Int means variable is an integer.
	Int
	// Float means variable is a float.
	Float
)

Jump to

Keyboard shortcuts

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