models

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyArtifactID = ArtifactID("")
View Source
const EmptyRepoID = RepoID("")

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	RepoID     RepoID           `gorm:"primaryKey;not null" validate:"required,validid"`
	ArtifactID ArtifactID       `gorm:"primaryKey;not null" validate:"required,validid"`
	Storage    string           `gorm:"not null" validate:"required,min=3,dir,abspath"`
	Size       types.Size       `gorm:"not null" validate:"required,gt=0"`
	State      vo.ArtifactState `gorm:"int" validate:"min=0,max=3"`
	CreatedAt  int64            `gorm:"index;column:created_at" validate:"required,gt=0"` // UTC Unix time of creation - equal to “`date +%s“`
	ExpiredAt  int64            `gorm:"index;column:expired_at" validate:"required,gt=0"` // UTC Unix time at which the artifacts expires
	Checksum   string           `gorm:"not null" validate:"required,min=8"`
	Meta       ArtifactMetas    `gorm:"foreignKey:RepoID,ArtifactID;constraint:OnDelete:CASCADE;" validate:"-"`
	Files      ArtifactFiles    `gorm:"foreignKey:RepoID,ArtifactID;constraint:OnDelete:CASCADE;" valudate:"-"`
}

func (*Artifact) Validate

func (model *Artifact) Validate(val *validator.Validate) error

type ArtifactFile

type ArtifactFile struct {
	RepoID     RepoID           `gorm:"primaryKey;not null" validate:"required,validid"`
	ArtifactID ArtifactID       `gorm:"primaryKey;not null" validate:"required,validid"`
	Name       string           `gorm:"primaryKey;not null" validate:"required"`
	Size       types.Size       `validate:"required,ge=0"`
	State      vo.ArtifactState `validate:"min=0,max=1"` // OK(0) or Broken(1)
}

type ArtifactFiles

type ArtifactFiles []*ArtifactFile

func (ArtifactFiles) Sort

func (files ArtifactFiles) Sort(path string)

type ArtifactID

type ArtifactID = string

type ArtifactMeta

type ArtifactMeta struct {
	RepoID     RepoID     `gorm:"primaryKey;not null" validate:"required,validid"`
	ArtifactID ArtifactID `gorm:"primaryKey;not null" validate:"required,validid"`
	Key        string     `gorm:"primaryKey;not null" validate:"required"`
	Value      string
}

func (*ArtifactMeta) Validate

func (model *ArtifactMeta) Validate() error

type ArtifactMetas

type ArtifactMetas []*ArtifactMeta

func (*ArtifactMetas) Secure

func (metas *ArtifactMetas) Secure()

type Artifacts

type Artifacts []*Artifact

func (Artifacts) HasArtifactID

func (a Artifacts) HasArtifactID(artifactID ArtifactID) bool

type File

type File struct {
	Name  string           `validate:"required"`
	Size  types.Size       `validate:"required,gt=0"`
	State vo.ArtifactState `validate:"min=0,max=1"` // OK(0) or Broken(1)
}

type Repo

type Repo struct {
	RepoID         RepoID         `gorm:"primaryKey;not null" validate:"required,validid"`
	Name           string         `gorm:"uniqueIndex;not null;column:name" validate:"required"`
	Description    string         `gorm:"string"`
	Input          string         `gorm:"index" validate:"required,min=3,dir,abspath"`
	Storage        string         `gorm:"uniqueIndex;not null" validate:"required,min=3,dir,abspath,nefield=Input"`
	Retention      types.Duration `gorm:"int64" validate:"min=0"`
	Broken         string         `gorm:"string" validate:"omitempty,min=3,eq=/dev/null|dir,abspath,nefield=Input,nefield=Storage"`
	Size           types.Size     `gorm:"int64" validate:"min=0"`
	ArtifactsCount int            `gorm:"int64" validate:"min=0"`
	Meta           RepoMetas      `gorm:"foreignKey:RepoID;constraint:OnDelete:CASCADE;" validate:"-"`
	Artifacts      Artifacts      `gorm:"foreignKey:RepoID;constraint:OnDelete:CASCADE;" yaml:"-" validate:"-"`
}

func (*Repo) Validate

func (model *Repo) Validate(val *validator.Validate) error

type RepoID

type RepoID = string

type RepoMeta

type RepoMeta struct {
	RepoID RepoID `gorm:"primaryKey;not null" validate:"required,validid"`
	Key    string `gorm:"primaryKey;not null" validate:"required"`
	Value  string
}

type RepoMetas

type RepoMetas []*RepoMeta

func (*RepoMetas) Secure

func (metas *RepoMetas) Secure()

func (*RepoMetas) UnmarshalYAML

func (meta *RepoMetas) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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