Documentation ¶
Index ¶
- Constants
- Variables
- type AccurateDuration
- type AdditionalColumns
- type ApiAuth
- type ApiAuthSpecs
- type ApiProxy
- type ApiSpec
- type BatchRespError
- type ErrorCode
- type Event
- type EventKind
- type Label
- type LabelList
- type NSID
- type Namespace
- type ObjID
- type Object
- type ObjectListItem
- type ObjectMeta
- type Page
- type Product
- type ResKind
- type RespError
- func BadRequest(errStr string) *RespError
- func Duplicate(kind ResKind) *RespError
- func ErrInvalidCron() *RespError
- func ErrInvalidJSON(err error) *RespError
- func FieldError(fieldName string, code ErrorCode) *RespError
- func InternalError(err error) *RespError
- func MissQueryParameters(errStr string) *RespError
- func NewError(status int, code ErrorCode) *RespError
- func NotFound(kind ResKind) *RespError
- func (r RespError) Error() string
- func (r *RespError) WithArgs(keyAndValues ...string) *RespError
- func (r *RespError) WithCode(code ErrorCode) *RespError
- func (r *RespError) WithDetail(s string) *RespError
- func (r *RespError) WithDetailErr(err error) *RespError
- func (r *RespError) WithMessage(msg string) *RespError
- type Time
- type TypeMeta
- type Webhook
Constants ¶
const HdrRequestID = "X-Request-Id"
Variables ¶
var (
FixturePath = os.Getenv("FIXTURE_PATH")
)
Global env var
var UnlimitedPaging = &Page{ Page: 1, Size: 9999999, }
UnlimitedPaging all results within one page
Functions ¶
This section is empty.
Types ¶
type AccurateDuration ¶
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 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" 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 LabelList ¶
type LabelList []Label
LabelList as replacement for map, for it takes less memory
func (LabelList) MarshalJSON ¶
MarshalJSON marshal label list into a map JSON
func (*LabelList) UnmarshalJSON ¶
UnmarshalJSON extract from map JSON to label list
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 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) GetKeyword ¶
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 FieldError ¶
FieldError field error
func MissQueryParameters ¶
MissQueryParameters miss query parameters
func (*RespError) WithDetail ¶
WithDetail with detail
func (*RespError) WithDetailErr ¶
WithDetailErr with detail
func (*RespError) WithMessage ¶
WithMessage add a message, may be overridden by locale translation
type Time ¶
Time with a special marshal/unmarshal
func ExampleTime ¶
func ExampleTime() Time
ExampleTime return example time to generate stable document
func (*Time) Scan ¶
Scan implements the sql.Scanner interface, and turns the bitfield incoming from MySQL into a BitBool
func (*Time) UnmarshalJSON ¶
UnmarshalJSON read ms from JSON and convert to Time