types

package
v0.0.0-...-297d307 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const HdrRequestID = "X-Request-Id"

Variables

View Source
var (
	FixturePath = os.Getenv("FIXTURE_PATH")
)

Global env var

View Source
var UnlimitedPaging = &Page{
	Page: 1,
	Size: 9999999,
}

UnlimitedPaging all results within one page

Functions

This section is empty.

Types

type AccurateDuration

type AccurateDuration time.Duration

AccurateDuration can be used to marshal/unmarshal JSON for time duration The accuracy is 1ms. "1" = 1ms "10ms" = 10ms "1s" = 1s "1m" = 60s "1h" = 3600s / "1d" = 24h

func (AccurateDuration) MarshalJSON

func (d AccurateDuration) MarshalJSON() ([]byte, error)

func (*AccurateDuration) UnmarshalJSON

func (d *AccurateDuration) UnmarshalJSON(b []byte) error

type AdditionalColumns

type AdditionalColumns []interface{}

type ApiAuth

type ApiAuth struct {
	Method string
	Path   string `json:"Path,omitemtpy"`
	Name   string
	// Provider default is "", means it is handled by beacon
	// Else it is handled via this webhook
	Auth *Webhook `json:"Auth,omitempty"`
	// Webhooks is called on every call
	Webhooks []string `json:"Webhooks,omitempty"`

	Proxy string
}

type ApiAuthSpecs

type ApiAuthSpecs []ApiAuth

type ApiProxy

type ApiProxy struct {
	Backends []string
}

type ApiSpec

type ApiSpec struct {
	ProductID string

	ApiGroup          string `db:"api_group"`
	ApiVersion        string `db:"api_version"`
	Kind              string
	NamespaceScoped   bool           `db:"namespace_scoped"`
	AdditionalColumns types.JSONText `db:"additional_columns"`
	SpecSchema        interface{}    `db:"spec_schema"`
}

type BatchRespError

type BatchRespError struct {
	Status    int          `json:"-"`
	Errors    []*RespError `json:"-"`          // Errors
	Code      string       `json:"code"`       // 程序用的错误码
	Message   string       `json:"message"`    // 用于返回可读的、本地语言化的提示信息
	Detail    string       `json:"detail"`     // 详细信息
	RequestID string       `json:"request_id"` // 本次请求的RequestID
}

func (BatchRespError) Error

func (b BatchRespError) Error() string

type ErrorCode

type ErrorCode string

ErrorCode code for error

const (
	ECNone ErrorCode = ""

	ECInternalAPIForbidden ErrorCode = "internal_api_forbidden"
	ECInvalidPageRequest   ErrorCode = "invalid_page_request"
	ECInvalidSorts         ErrorCode = "invalid_sorts"
	ECInvalidJSON          ErrorCode = "invalid_json"
	ECDBFailure            ErrorCode = "db_failure"
	ECUnauthorized         ErrorCode = "unauthorized"
	ECPermFailure          ErrorCode = "permission_failure"
	ECPermDenied           ErrorCode = "permission_denied"
	ECInvalidSMTPConfig    ErrorCode = "invalid_smtp_config"
	ECInvalidOAuthConfig   ErrorCode = "invalid_oauth_config"
	ECInvalidRegExp        ErrorCode = "invalid_regexp"

	ECNSChildNotDeleted ErrorCode = "ns.child_not_deleted"

	ECCodeDeleteConflict ErrorCode = "code.delete_conflict"

	ECPipelineBadFlow                ErrorCode = "pipeline.bad_flow"
	ECPipelineTemplateBadFlow        ErrorCode = "pipeline_template.bad_flow"
	ECPipelineTemplateEditDisabled   ErrorCode = "pipeline_template.edit_disabled"
	ECPipelineTemplateDeleteDisabled ErrorCode = "pipeline_template.delete_disabled"
	ECInvalidStageIndex              ErrorCode = "pipeline.invalid_stage_index"
	ECInvalidTaskIndex               ErrorCode = "pipeline.invalid_task_index"
	ECUnknownTemplate                ErrorCode = "pipeline.unknown_template"
	ECEmptyFlow                      ErrorCode = "pipeline.empty_flow"
	ECTriggerCodeDuplicate           ErrorCode = "pipeline.trigger_code_duplicate"
	ECInvalidCron                    ErrorCode = "pipeline.invalid_cron"
	ECPipelineTriggerInfiniteLoop    ErrorCode = "pipeline.trigger_infinite_loop"
	ECPipelineTriggerNoCondition     ErrorCode = "pipeline.trigger_no_condition"
	ECIncompatibleTmpl               ErrorCode = "pipeline.incompatible_template"

	ECInvalidStageName  ErrorCode = "stage.invalid_name"
	ECInvalidTaskName   ErrorCode = "task.invalid_name"
	ECInvalidImage      ErrorCode = "flow.invalid_image"
	ECInvalidEmail      ErrorCode = "flow.invalid_email"
	ECInvalidTag        ErrorCode = "flow.invalid_tag"
	ECInvalidRegistry   ErrorCode = "flow.invalid_registry"
	ECInvalidVolume     ErrorCode = "flow.invalid_volume"
	ECInvalidLimit      ErrorCode = "flow.invalid_limit"
	ECNoSonarLogin      ErrorCode = "flow.no_sonar_login"
	ECNoJenkinsPassword ErrorCode = "flow.no_jenkins_password"
	ECNoCloneURL        ErrorCode = "flow.no_clone_url"
	ECTaskNameRepeat    ErrorCode = "flow.task_name_repeat"
	ECStageNameRepeat   ErrorCode = "flow.stage_name_repeat"
	ECInvalidReceiver   ErrorCode = "flow.invalid_email_receivers"
	ECInvalidTimeout    ErrorCode = "flow.invalid_timeout"

	ECReportTooLarge        ErrorCode = "report.file_too_large"
	ECReportCompressFailure ErrorCode = "report.compress_failure"

	ECTaskRenderError ErrorCode = "job.task_render"
	ECRunFailed       ErrorCode = "job.run_failure"
	ECK8sFailed       ErrorCode = "job.k8s_failure"
	ECPasswordFailure ErrorCode = "job.password_failure"
	ECStatusDone      ErrorCode = "job.status_done"

	ECRepoDriverNotFound ErrorCode = "repo.driver_not_found"
	ECRepoBindsDuplicate ErrorCode = "repo.binds_duplicate"
	ECRepoTagList        ErrorCode = "repo.tags_list"
	ECRepoBranchesList   ErrorCode = "repo.branches_list"
	ECRepoInsights       ErrorCode = "repo.insights"
	ECRepoFileGet        ErrorCode = "repo.file_get"
	ECRepoFileCreate     ErrorCode = "repo.file_create"
	ECRepoWebhookParse   ErrorCode = "repo.webhook_parse"
	ECRepoWebhookCreate  ErrorCode = "repo.webhook_create"
	ECRepoGenerateKey    ErrorCode = "repo.generate_key"
	ECRepoGetUser        ErrorCode = "repo.get_user"
	ECUnknownRefKind     ErrorCode = "repo.unknown_refkind"

	ECUserMailNotFound ErrorCode = "user.mail_not_found"
	ECUserNotFound     ErrorCode = "user.not_found"

	ECFieldTooLong    ErrorCode = "field.too_long"
	ECFieldTooShort   ErrorCode = "field.too_short"
	ECFieldEmpty      ErrorCode = "field.empty"
	ECFieldExclude    ErrorCode = "field.exclude"
	ECInvalidUUID     ErrorCode = "field.invalid_uuid"
	ECInvalidName     ErrorCode = "field.invalid_name"
	ECInvalidPipName  ErrorCode = "field.invalid_pip_name"
	ECFieldInvalid    ErrorCode = "field.invalid"
	ECFieldNameExists ErrorCode = "field.name_exists"
)

Common ErrorCode

type Event

type Event struct {
	Action string
	Old    *Object `json:"old,omitempty"`
	Obj    *Object `json:"obj,omitempty"`
}

Event event for changes

type EventKind

type EventKind string
const (
	EventAdd    EventKind = "add"
	EventUpdate EventKind = "update"
	EventDelete EventKind = "delete"
)

type Label

type Label struct {
	Key   string `validate:"required,max=255"`
	Value string `validate:"max=255"`
}

type LabelList

type LabelList []Label

LabelList as replacement for map, for it takes less memory

func (LabelList) MarshalJSON

func (l LabelList) MarshalJSON() ([]byte, error)

MarshalJSON marshal label list into a map JSON

func (*LabelList) UnmarshalJSON

func (l *LabelList) UnmarshalJSON(b []byte) error

UnmarshalJSON extract from map JSON to label list

type NSID

type NSID uint16

NSID id of namespace

type Namespace

type Namespace struct {
	ID        NSID
	Name      string `validate:"required,max=64"`
	Key       string `validate:"required,max=64"`
	ParentID  NSID   `db:"parent_id"`
	CreatedAt Time   `db:"created_at"`
	UpdatedAt Time   `db:"updated_at"`
}

Namespace is the highest level of resource isolation Namespace with id 0 stands for "no namespace"

type ObjID

type ObjID uint64

type Object

type Object struct {
	ObjectMeta `json:",inline"`
	Spec       json.RawMessage
	Status     json.RawMessage
}

type ObjectListItem

type ObjectListItem struct {
	ObjectMeta        `json:",inline"`
	AdditionalColumns []interface{}
}

type ObjectMeta

type ObjectMeta struct {
	TypeMeta        `json:",inline"`
	ID              ObjID
	Name            string  `validate:"required,max=64"`
	NSID            NSID    `json:"-" db:"ns_id"`
	Namespace       string  `db:"-" validate:"max=64"`
	Labels          []Label `json:"labels,omitempty"`
	ResourceVersion int     `db:"resource_version"`
	Generation      int
	CreatedAt       Time `db:"created_at"`
	UpdatedAt       Time `db:"updated_at"`
}

type Page

type Page struct {
	Offset  *int              `json:"offset,omitempty" description:"直接传递offset时接受此值"`
	Page    int               `json:"page" description:"页码,从1开始,默认为1"`
	Size    int               `json:"size" description:"默认值为20,无上限,如要求所有,则为-1"`
	Total   int               `json:"total" description:"符合条件的结果条目总数"`
	Keyword string            `json:"keyword,omitempty" description:"查询参数"`
	Params  map[string]string `json:"params,omitempty" description:"其它查询参数,视接口而定"`
}

Page 分页查询参数, 也会被嵌入到查询结果中

func (Page) Copy

func (p Page) Copy() *Page

Copy make a deep copy of page query

func (Page) GetKeyword

func (p Page) GetKeyword() string

func (Page) GetLimit

func (p Page) GetLimit() int

GetLimit limit

func (Page) GetOffset

func (p Page) GetOffset() int

Offset offset

type Product

type Product struct {
	ID    string
	Names map[string]string // lang->name
}

Product third party product

type ResKind

type ResKind string

ResKind res kind

const (
	ResKindPipeline         ResKind = "pipeline"
	ResKindPipelineTemplate ResKind = "pipeline_template"
	ResKindStage            ResKind = "stage"
	ResKindJob              ResKind = "job"
	ResKindTask             ResKind = "task"
	ResKindRepo             ResKind = "repo"
	ResKindRegistry         ResKind = "registry"
	ResKindCode             ResKind = "code"
	ResKindRepoDriver       ResKind = "repo_driver"
	ResKindRepoBind         ResKind = "repo_bind"
	ResKindRepoFile         ResKind = "repo_file"
	ResKindRepoKey          ResKind = "repo_key"
	ResKindTrigger          ResKind = "trigger"
	ResKindTriggerArchive   ResKind = "trigger_archive"
	ResKindLog              ResKind = "log"
	ResKeyPair              ResKind = "key_pair"
	ResPassword             ResKind = "password"
	ResReport               ResKind = "report"
	ResAudit                ResKind = "audit"
	ResUser                 ResKind = "user"
	ResOrg                  ResKind = "org"
	ResProject              ResKind = "project"
	ResHTML                 ResKind = "html"
)

Common kinds

type RespError

type RespError struct {
	Status    int               `json:"-"`
	Code      string            `json:"code"`       // 程序用的错误码
	Message   string            `json:"message"`    // 用于返回可读的、本地语言化的提示信息
	Detail    string            `json:"detail"`     // 详细信息
	RequestID string            `json:"request_id"` // 本次请求的RequestID
	Args      map[string]string `json:"-"`
}

RespError 用于JSON形式返回HTTP错误

func BadRequest

func BadRequest(errStr string) *RespError

BadRequest bad request

func Duplicate

func Duplicate(kind ResKind) *RespError

Duplicate duplicate things

func ErrInvalidCron

func ErrInvalidCron() *RespError

ErrInvalidCron ErrInvalidCron

func ErrInvalidJSON

func ErrInvalidJSON(err error) *RespError

ErrInvalidJSON ErrInvalidJSON

func FieldError

func FieldError(fieldName string, code ErrorCode) *RespError

FieldError field error

func InternalError

func InternalError(err error) *RespError

InternalError internal error

func MissQueryParameters

func MissQueryParameters(errStr string) *RespError

MissQueryParameters miss query parameters

func NewError

func NewError(status int, code ErrorCode) *RespError

NewError new error

func NotFound

func NotFound(kind ResKind) *RespError

NotFound not found

func (RespError) Error

func (r RespError) Error() string

Error implemented for error interface

func (*RespError) WithArgs

func (r *RespError) WithArgs(keyAndValues ...string) *RespError

WithArgs set args

func (*RespError) WithCode

func (r *RespError) WithCode(code ErrorCode) *RespError

WithCode set code

func (*RespError) WithDetail

func (r *RespError) WithDetail(s string) *RespError

WithDetail with detail

func (*RespError) WithDetailErr

func (r *RespError) WithDetailErr(err error) *RespError

WithDetailErr with detail

func (*RespError) WithMessage

func (r *RespError) WithMessage(msg string) *RespError

WithMessage add a message, may be overridden by locale translation

type Time

type Time time.Time

Time with a special marshal/unmarshal

func ExampleTime

func ExampleTime() Time

ExampleTime return example time to generate stable document

func NewTime

func NewTime(t time.Time) Time

NewTime return new time

func NewTimeSeconds

func NewTimeSeconds(s int64) Time

NewTimeMS new time with millisecond

func Now

func Now() Time

Now return now

func (Time) IsZero

func (t Time) IsZero() bool

IsZero is zero

func (Time) MarshalJSON

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

MarshalJSON put ms into JSON

func (*Time) Scan

func (t *Time) Scan(src interface{}) error

Scan implements the sql.Scanner interface, and turns the bitfield incoming from MySQL into a BitBool

func (Time) Sub

func (t Time) Sub(v Time) time.Duration

Sub destination time

func (Time) Unix

func (t Time) Unix() int64

Unix unix timestamp in millisecond

func (*Time) UnmarshalJSON

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

UnmarshalJSON read ms from JSON and convert to Time

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements the driver.Valuer interface, and turns the BitBool into a bitfield (BIT(1)) for MySQL storage.

type TypeMeta

type TypeMeta struct {
	ApiVersion string `db:"api_version" validate:"max=64"`
	ApiGroup   string `db:"api_group" validate:"max=64"`
	Kind       string `validate:"max=64"`
}

func (TypeMeta) GetTypeSignature

func (t TypeMeta) GetTypeSignature() uint32

GetTypeSignature get type signature

type Webhook

type Webhook struct {
	URL     string
	Headers map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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