Documentation ¶
Overview ¶
Package database provides the defined database types for Vela.
Usage:
import "github.com/go-vela/types/database"
Index ¶
- Variables
- func BuildWithContext(c context.Context, b *Build) context.Context
- func LogWithContext(c context.Context, l *Log) context.Context
- func RepoWithContext(c context.Context, r *Repo) context.Context
- func SecretWithContext(c context.Context, s *Secret) context.Context
- func StepWithContext(c context.Context, s *Step) context.Context
- func UserWithContext(c context.Context, u *User) context.Context
- type Build
- type Hook
- type Log
- type Repo
- type Secret
- type Service
- type Step
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyBuildNumber defines the error type when a // Build type has an empty Number field provided. ErrEmptyBuildNumber = errors.New("empty build number provided") // ErrEmptyBuildRepoID defines the error type when a // Build type has an empty `RepoID` field provided. ErrEmptyBuildRepoID = errors.New("empty build repo_id provided") )
var ( // ErrEmptyHookNumber defines the error type when a // Hook type has an empty Number field provided. ErrEmptyHookNumber = errors.New("empty webhook number provided") // ErrEmptyHookRepoID defines the error type when a // Hook type has an empty RepoID field provided. ErrEmptyHookRepoID = errors.New("empty webhook repo_id provided") // ErrEmptyHookSourceID defines the error type when a // Hook type has an empty SourceID field provided. ErrEmptyHookSourceID = errors.New("empty webhook source_id provided") )
var ( // ErrEmptyLogBuildID defines the error type when a // Log type has an empty BuildID field provided. ErrEmptyLogBuildID = errors.New("empty log build_id provided") // ErrEmptyLogRepoID defines the error type when a // Log type has an empty RepoID field provided. ErrEmptyLogRepoID = errors.New("empty log repo_id provided") // ErrEmptyLogStepOrServiceID defines the error type when a // Log type has an empty StepID or ServiceID field provided. ErrEmptyLogStepOrServiceID = errors.New("empty log step_id or service_id not provided") )
var ( // ErrEmptyRepoFullName defines the error type when a // Repo type has an empty FullName field provided. ErrEmptyRepoFullName = errors.New("empty repo full_name provided") // ErrEmptyRepoName defines the error type when a // Repo type has an empty Name field provided. ErrEmptyRepoName = errors.New("empty repo name provided") // ErrEmptyRepoOrg defines the error type when a // Repo type has an empty Org field provided. ErrEmptyRepoOrg = errors.New("empty repo org provided") // ErrEmptyRepoUserID defines the error type when a // Repo type has an empty UserID field provided. ErrEmptyRepoUserID = errors.New("empty repo user_id provided") )
var ( // ErrEmptySecretName defines the error type when a // Secret type has an empty Name field provided. ErrEmptySecretName = errors.New("empty secret name provided") // ErrEmptySecretOrg defines the error type when a // Secret type has an empty Org field provided. ErrEmptySecretOrg = errors.New("empty secret org provided") // ErrEmptySecretRepo defines the error type when a // Secret type has an empty Repo field provided. ErrEmptySecretRepo = errors.New("empty secret repo provided") // ErrEmptySecretTeam defines the error type when a // Secret type has an empty Team field provided. ErrEmptySecretTeam = errors.New("empty secret team provided") // ErrEmptySecretType defines the error type when a // Secret type has an empty Type field provided. ErrEmptySecretType = errors.New("empty secret type provided") // ErrEmptySecretValue defines the error type when a // Secret type has an empty Value field provided. ErrEmptySecretValue = errors.New("empty secret value provided") )
var ( // ErrEmptyServiceBuildID defines the error type when a // Service type has an empty BuildID field provided. ErrEmptyServiceBuildID = errors.New("empty service build_id provided") // ErrEmptyServiceName defines the error type when a // Service type has an empty Name field provided. ErrEmptyServiceName = errors.New("empty service name provided") // ErrEmptyServiceImage defines the error type when a // Service type has an empty Image field provided. ErrEmptyServiceImage = errors.New("empty service image provided") // ErrEmptyServiceNumber defines the error type when a // Service type has an empty Number field provided. ErrEmptyServiceNumber = errors.New("empty service number provided") // ErrEmptyServiceRepoID defines the error type when a // Service type has an empty RepoID field provided. ErrEmptyServiceRepoID = errors.New("empty service repo_id provided") )
var ( // ErrEmptyStepBuildID defines the error type when a // Step type has an empty BuildID field provided. ErrEmptyStepBuildID = errors.New("empty step build_id provided") // ErrEmptyStepName defines the error type when a // Step type has an empty Name field provided. ErrEmptyStepName = errors.New("empty step name provided") // ErrEmptyStepImage defines the error type when a // Step type has an empty Image field provided. ErrEmptyStepImage = errors.New("empty step image provided") // ErrEmptyStepNumber defines the error type when a // Step type has an empty Number field provided. ErrEmptyStepNumber = errors.New("empty step number provided") // ErrEmptyStepRepoID defines the error type when a // Step type has an empty RepoID field provided. ErrEmptyStepRepoID = errors.New("empty step repo_id provided") )
var ( // ErrEmptyUserHash defines the error type when a // User type has an empty Hash field provided. ErrEmptyUserHash = errors.New("empty user hash provided") // ErrEmptyUserName defines the error type when a // User type has an empty Name field provided. ErrEmptyUserName = errors.New("empty user name provided") // ErrEmptyUserToken defines the error type when a // User type has an empty Token field provided. ErrEmptyUserToken = errors.New("empty user token provided") // ErrInvalidUserName defines the error type when a // User type has an invalid Name field provided. ErrInvalidUserName = errors.New("invalid user name provided") )
Functions ¶
func BuildWithContext ¶
BuildWithContext inserts the Build type to the context.
func LogWithContext ¶
LogWithContext inserts the Log type to the context.
func RepoWithContext ¶
RepoWithContext inserts the Repo type to the context.
func SecretWithContext ¶
SecretWithContext inserts the Secret type to the context.
func StepWithContext ¶
StepWithContext inserts the Step type to the context.
Types ¶
type Build ¶
type Build struct { ID sql.NullInt64 `sql:"id"` RepoID sql.NullInt64 `sql:"repo_id"` Number sql.NullInt32 `sql:"number"` Parent sql.NullInt32 `sql:"parent"` Event sql.NullString `sql:"event"` Status sql.NullString `sql:"status"` Error sql.NullString `sql:"error"` Enqueued sql.NullInt64 `sql:"enqueued"` Created sql.NullInt64 `sql:"created"` Started sql.NullInt64 `sql:"started"` Finished sql.NullInt64 `sql:"finished"` Deploy sql.NullString `sql:"deploy"` Clone sql.NullString `sql:"clone"` Source sql.NullString `sql:"source"` Title sql.NullString `sql:"title"` Message sql.NullString `sql:"message"` Commit sql.NullString `sql:"commit"` Sender sql.NullString `sql:"sender"` Author sql.NullString `sql:"author"` Branch sql.NullString `sql:"branch"` Ref sql.NullString `sql:"ref"` BaseRef sql.NullString `sql:"base_ref"` Host sql.NullString `sql:"host"` Runtime sql.NullString `sql:"runtime"` Distribution sql.NullString `sql:"distribution"` }
Build is the database representation of a build for a pipeline.
func BuildFromContext ¶
BuildFromContext retrieves the Build type from the context.
func BuildFromLibrary ¶
BuildFromLibrary converts the libray Build type to a database build type.
func (*Build) Crop ¶
Crop prepares the Build type for inserting into the database by trimming values that may exceed the database column limit.
func (*Build) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Build type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Hook ¶ added in v0.2.0
type Hook struct { ID sql.NullInt64 `sql:"id"` RepoID sql.NullInt64 `sql:"repo_id"` BuildID sql.NullInt64 `sql:"build_id"` Number sql.NullInt32 `sql:"number"` SourceID sql.NullString `sql:"source_id"` Created sql.NullInt64 `sql:"created"` Host sql.NullString `sql:"host"` Event sql.NullString `sql:"event"` Branch sql.NullString `sql:"branch"` Error sql.NullString `sql:"error"` Status sql.NullString `sql:"status"` Link sql.NullString `sql:"link"` }
Hook is the database representation of a webhook for a repo.
func HookFromLibrary ¶ added in v0.2.0
HookFromLibrary converts the Hook type to a library Hook type.
func (*Hook) Nullify ¶ added in v0.2.0
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Hook type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Log ¶
type Log struct { ID sql.NullInt64 `sql:"id"` BuildID sql.NullInt64 `sql:"build_id"` RepoID sql.NullInt64 `sql:"repo_id"` ServiceID sql.NullInt64 `sql:"service_id"` StepID sql.NullInt64 `sql:"step_id"` Data []byte `sql:"data"` }
Log is the database representation of a log for a step in a build.
func LogFromContext ¶
LogFromContext retrieves the Log type from the context.
func LogFromLibrary ¶
LogFromLibrary converts the Log type to a library Log type.
func (*Log) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Log type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Repo ¶
type Repo struct { ID sql.NullInt64 `sql:"id"` UserID sql.NullInt64 `sql:"user_id"` Org sql.NullString `sql:"org"` Name sql.NullString `sql:"name"` FullName sql.NullString `sql:"full_name"` Link sql.NullString `sql:"link"` Clone sql.NullString `sql:"clone"` Branch sql.NullString `sql:"branch"` Timeout sql.NullInt64 `sql:"timeout"` Visibility sql.NullString `sql:"visibility"` Private sql.NullBool `sql:"private"` Trusted sql.NullBool `sql:"trusted"` Active sql.NullBool `sql:"active"` AllowPull sql.NullBool `sql:"allow_pull"` AllowPush sql.NullBool `sql:"allow_push"` AllowDeploy sql.NullBool `sql:"allow_deploy"` AllowTag sql.NullBool `sql:"allow_tag"` }
Repo is the database representation of a repo.
func RepoFromContext ¶
RepoFromContext retrieves the Repo type from the context.
func RepoFromLibrary ¶
RepoFromLibrary converts the libray Repo type to a database repo type.
func (*Repo) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Repo type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Secret ¶
type Secret struct { ID sql.NullInt64 `sql:"id"` Org sql.NullString `sql:"org"` Repo sql.NullString `sql:"repo"` Team sql.NullString `sql:"team"` Name sql.NullString `sql:"name"` Value sql.NullString `sql:"value"` Type sql.NullString `sql:"type"` Images pq.StringArray `sql:"images"` Events pq.StringArray `sql:"events"` AllowCommand sql.NullBool `sql:"allow_command"` }
Secret is the database representation of a secret.
func SecretFromContext ¶
SecretFromContext retrieves the Secret type from the context.
func SecretFromLibrary ¶
SecretFromLibrary converts the library Secret type to a database Secret type.
func (*Secret) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Secret type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Service ¶
type Service struct { ID sql.NullInt64 `sql:"id"` BuildID sql.NullInt64 `sql:"build_id"` RepoID sql.NullInt64 `sql:"repo_id"` Number sql.NullInt32 `sql:"number"` Name sql.NullString `sql:"name"` Image sql.NullString `sql:"image"` Status sql.NullString `sql:"status"` Error sql.NullString `sql:"error"` ExitCode sql.NullInt32 `sql:"exit_code"` Created sql.NullInt64 `sql:"created"` Started sql.NullInt64 `sql:"started"` Finished sql.NullInt64 `sql:"finished"` }
Service is the database representation of a service in a build.
func ServiceFromLibrary ¶
ServiceFromLibrary converts the library Service type to a database Service type.
func (*Service) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Service type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type Step ¶
type Step struct { ID sql.NullInt64 `sql:"id"` BuildID sql.NullInt64 `sql:"build_id"` RepoID sql.NullInt64 `sql:"repo_id"` Number sql.NullInt32 `sql:"number"` Name sql.NullString `sql:"name"` Image sql.NullString `sql:"image"` Stage sql.NullString `sql:"stage"` Status sql.NullString `sql:"status"` Error sql.NullString `sql:"error"` ExitCode sql.NullInt32 `sql:"exit_code"` Created sql.NullInt64 `sql:"created"` Started sql.NullInt64 `sql:"started"` Finished sql.NullInt64 `sql:"finished"` Host sql.NullString `sql:"host"` Runtime sql.NullString `sql:"runtime"` Distribution sql.NullString `sql:"distribution"` }
Step is the database representation of a step in a build.
func StepFromContext ¶
StepFromContext retrieves the Step type from the context.
func StepFromLibrary ¶
StepFromLibrary converts the library Step type to a database Step type.
func (*Step) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the Step type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.
type User ¶
type User struct { ID sql.NullInt64 `sql:"id"` Name sql.NullString `sql:"name"` Token sql.NullString `sql:"token"` Hash sql.NullString `sql:"hash"` Active sql.NullBool `sql:"active"` Admin sql.NullBool `sql:"admin"` }
User is the database representation of a user.
func UserFromContext ¶
UserFromContext retrieves the User type from the context.
func UserFromLibrary ¶
UserFromLibrary converts the library User type to a database User type.
func (*User) Nullify ¶ added in v0.1.2
Nullify ensures the valid flag for the sql.Null types are properly set.
When a field within the User type is the zero value for the field, the valid flag is set to false causing it to be NULL in the database.