models

package
v1.0.58-beta Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ACTIONS
	ActionView     Action = "VIEW"
	ActionCreate   Action = "CREATE"
	ActionUpdate   Action = "UPDATE"
	ActionDelete   Action = "DELETE"
	ActionPush     Action = "PUSH"
	ActionPull     Action = "PULL"
	ActionAdmin    Action = "ADMIN"
	ActionLogin    Action = "LOGIN"
	ActionLogout   Action = "LOGOUT"
	ActionMigrate  Action = "MIGRATE"
	ActionUpload   Action = "UPLOAD"
	ActionDownload Action = "DOWNLOAD"

	// RESOURCES
	ResourceTask     Resource = "TASK"
	ResourceWebUI    Resource = "WEBUI"
	ResourceImage    Resource = "IMAGE"
	ResourceTag      Resource = "TAG"
	ResourceUser     Resource = "USER"
	ResourceGroup    Resource = "GROUP"
	ResourceSystem   Resource = "SYSTEM"
	ResourceArtifact Resource = "ARTIFACT"
	ResourceRepo     Resource = "REPO"

	// SCOPES
	ScopeGlobal     Scope = "global"
	ScopeRepository Scope = "repository"
	ScopeProject    Scope = "project"
)

PERMISSIONS - SINGLE SOURCE OF TRUTH

View Source
const (
	SettingKeyArtifacts = "artifacts"
	SettingKeyRegistry  = "registry"
	SettingKeyAuth      = "auth"
)

SETTINGS KEYS

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLogEntry

type AccessLogEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Username  string    `json:"username"`
	Action    string    `json:"action"`
	Resource  string    `json:"resource"`
	Path      string    `json:"path"`
	Method    string    `json:"method"`
	Status    int       `json:"status"`
}

type Action

type Action string

type Artifact

type Artifact struct {
	ID         string            `json:"id"`
	RepoID     int               `json:"repo_id"`
	Name       string            `json:"name"`
	Path       string            `json:"path"`
	UploadID   string            `json:"upload_id"`
	Version    string            `json:"version"`
	Size       int64             `json:"size"`
	MimeType   string            `json:"mime_type"`
	Metadata   string            `json:"metadata"`
	Properties map[string]string `json:"properties"`
	CreatedAt  time.Time         `json:"created_at"`
	UpdatedAt  time.Time         `json:"updated_at"`
}

type ArtifactRepository

type ArtifactRepository struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Owner       string    `json:"owner"`
	Private     bool      `json:"private"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type ArtifactSearchCriteria

type ArtifactSearchCriteria struct {
	RepoID     *int              `json:"repo_id,omitempty"`
	Username   string            `json:"username,omitempty"`
	Name       *string           `json:"name,omitempty"`
	Version    *string           `json:"version,omitempty"`
	Path       *string           `json:"path,omitempty"`
	Properties map[string]string `json:"properties,omitempty"`
	Sort       string            `json:"sort,omitempty"`
	Order      string            `json:"order,omitempty"`
	Limit      int               `json:"limit,omitempty"`
	Offset     int               `json:"offset,omitempty"`
}

type ArtifactSettings

type ArtifactSettings struct {
	Retention  RetentionPolicy  `json:"retention"`
	Storage    StorageConfig    `json:"storage"`
	Properties PropertiesConfig `json:"properties"`
	Search     SearchConfig     `json:"search"`
}

ARTIFACT SETTINGS

func (*ArtifactSettings) GetDefaults

func (s *ArtifactSettings) GetDefaults() Settings

func (*ArtifactSettings) IsStartupOnly

func (s *ArtifactSettings) IsStartupOnly() bool

func (*ArtifactSettings) Section

func (s *ArtifactSettings) Section() string

func (*ArtifactSettings) Validate

func (s *ArtifactSettings) Validate() error

type AuthConfig

type AuthConfig struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
	Username  string    `json:"username"`
	Server    string    `json:"server"`
}

type AuthSettings

type AuthSettings struct {
	TokenExpiry    int      `json:"tokenExpiry"`
	SessionTimeout int      `json:"sessionTimeout"`
	PasswordPolicy PwPolicy `json:"passwordPolicy"`
	AllowAnonymous bool     `json:"allowAnonymous"`
}

AUTH SETTINGS

func (*AuthSettings) GetDefaults

func (s *AuthSettings) GetDefaults() Settings

func (*AuthSettings) IsStartupOnly

func (s *AuthSettings) IsStartupOnly() bool

func (*AuthSettings) Section

func (s *AuthSettings) Section() string

func (*AuthSettings) Validate

func (s *AuthSettings) Validate() error

type BlobMetrics

type BlobMetrics struct {
	Total          int64   `json:"total"`
	Failed         int64   `json:"failed"`
	InProgress     int32   `json:"inProgress"`
	BytesProcessed int64   `json:"bytesProcessed"`
	AvgDuration    float64 `json:"avgDuration"`
}

METRIC TYPES

type CleanupPolicy

type CleanupPolicy struct {
	Enabled     bool `json:"enabled"`
	MaxAge      int  `json:"maxAge"` // DAYS
	UnusedOnly  bool `json:"unusedOnly"`
	MinVersions int  `json:"minVersions"` // MIN VERSIONS TO KEEP
}

type Config

type Config struct {
	Server struct {
		Port        string `json:"port" yaml:"port"`
		Domain      string `json:"domain" yaml:"domain"`
		RSAKeyFile  string `json:"rsaKeyFile" yaml:"rsa_key_file"`
		TLSKeyFile  string `json:"tlsKeyFile" yaml:"tls_key_file"`
		TLSCertFile string `json:"tlsCertFile" yaml:"tls_certificate"`
		CertBundle  string `json:"certBundle" yaml:"cert_bundle"`
	} `json:"server" yaml:"server"`

	Storage struct {
		RootDirectory string `json:"rootDirectory" yaml:"root_directory"`
	} `json:"storage" yaml:"storage"`

	Database struct {
		Path string `json:"path" yaml:"path"`
	} `json:"database" yaml:"database"`

	Auth struct {
		Realm   string `json:"realm" yaml:"realm"`
		Service string `json:"service" yaml:"service"`
		Issuer  string `json:"issuer" yaml:"issuer"`
	} `json:"auth" yaml:"auth"`

	Init struct {
		Drop       bool   `json:"drop" yaml:"drop"`
		Roles      bool   `json:"roles" yaml:"roles"`
		Groups     bool   `json:"groups" yaml:"groups"`
		User       bool   `json:"user" yaml:"user"`
		Username   string `json:"username" yaml:"username"`
		Password   string `json:"password" yaml:"password"`
		Migrations bool   `json:"migrations" yaml:"migrations"`
	} `json:"init" yaml:"init"`
}

type CustomClaims

type CustomClaims struct {
	Subject string             `json:"sub,omitempty"`
	Access  []*ResourceActions `json:"access,omitempty"`
	Groups  []string           `json:"groups,omitempty"`
	jwt.RegisteredClaims
}

func (CustomClaims) Valid

func (c CustomClaims) Valid() error

type DiskInfo

type DiskInfo struct {
	DiskTotal     int64
	DiskAvailable int64
}

type DockerManifest

type DockerManifest struct {
	SchemaVersion int    `json:"schemaVersion"`
	MediaType     string `json:"mediaType"`
	Config        struct {
		MediaType string `json:"mediaType"`
		Size      int64  `json:"size"`
		Digest    string `json:"digest"`
	} `json:"config"`
	Layers []struct {
		MediaType string `json:"mediaType"`
		Size      int64  `json:"size"`
		Digest    string `json:"digest"`
	} `json:"layers"`
}

type GlobalView

type GlobalView struct {
	TotalImages int64            `json:"total_images"`
	TotalSize   int64            `json:"total_size"`
	Images      []*ImageMetadata `json:"images"`
}

DEFAULT SYSTEM ROLES - TODO: USE THIS INSTEAD OF MANUAL MIGRATIONS

type Group

type Group struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Roles       []string  `json:"roles"`
	Scope       Scope     `json:"scope"`
	Target      string    `json:"target,omitempty"` // OPT TARGET W/ SCOPE
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

ROLES AND USERS

func (*Group) MarshalRoles

func (g *Group) MarshalRoles() (string, error)

ROLES TO JSON

func (*Group) UnmarshalRoles

func (g *Group) UnmarshalRoles(data string) error

JSON TO ROLES

type ImageMetadata

type ImageMetadata struct {
	ID        string            `json:"id"`
	Name      string            `json:"name"`
	Tags      []string          `json:"tags"`
	Size      int64             `json:"size"`
	Owner     string            `json:"owner"`
	Labels    map[string]string `json:"labels"`
	Private   bool              `json:"private"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

type ImageRepository

type ImageRepository struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Tags      []ImageTag `json:"tags"`
	UpdatedAt time.Time  `json:"updated_at"`
	Owner     string     `json:"owner"`
	Private   bool       `json:"private"`
	Size      int64      `json:"size"`
}

type ImageTag

type ImageTag struct {
	Name    string    `json:"name"`
	Size    int64     `json:"size"`
	Digest  string    `json:"digest"`
	Created time.Time `json:"created"`
}

type MetricsData

type MetricsData struct {
	BlobUploads    BlobMetrics        `json:"blobUploads"`
	BlobDownloads  BlobMetrics        `json:"blobDownloads"`
	Performance    PerformanceMetrics `json:"performance"`
	TimeseriesData []TimeSeriesPoint  `json:"timeseriesData"`
	AccessLogs     []AccessLogEntry   `json:"access_logs"`
}

type PerformanceMetrics

type PerformanceMetrics struct {
	AvgUploadSpeed   float64 `json:"avgUploadSpeed"`   // MB/S
	AvgDownloadSpeed float64 `json:"avgDownloadSpeed"` // MB/S
	DiskUsage        int64   `json:"diskUsage"`        // GB
	DiskTotal        int64   `json:"diskTotal"`        // GB
	MemoryUsage      int64   `json:"memoryUsage"`      // MB
	MemoryTotal      int64   `json:"memoryTotal"`      // MB
	CpuUsage         float64 `json:"cpuUsage"`
}

type Permission

type Permission struct {
	Action   Action   `json:"action"`
	Resource Resource `json:"resource"`
	Scope    Scope    `json:"scope,omitempty"`
	Target   string   `json:"target,omitempty"` // OPT TARGET W/ SCOPE
}

SINGLE CAPABILITY TO DO SOMETHING

func (Permission) String

func (p Permission) String() string

type PropertiesConfig

type PropertiesConfig struct {
	Required []string `json:"required"`
	Indexed  []string `json:"indexed"`
}

type ProxyConfig

type ProxyConfig struct {
	Enabled      bool   `json:"enabled"`
	RemoteURL    string `json:"remoteUrl"`
	CacheEnabled bool   `json:"cacheEnabled"`
	CacheMaxAge  int    `json:"cacheMaxAge"` // HOURS
}

type PwPolicy

type PwPolicy struct {
	MinLength      int  `json:"minLength"`
	RequireUpper   bool `json:"requireUpper"`
	RequireLower   bool `json:"requireLower"`
	RequireNumber  bool `json:"requireNumber"`
	RequireSpecial bool `json:"requireSpecial"`
}

type RegistrySettings

type RegistrySettings struct {
	Cleanup CleanupPolicy `json:"cleanup"`
	Proxy   ProxyConfig   `json:"proxy"`
	Storage StorageConfig `json:"storage"`
}

REGISTRY SETTINGS

func (*RegistrySettings) GetDefaults

func (s *RegistrySettings) GetDefaults() Settings

func (*RegistrySettings) IsStartupOnly

func (s *RegistrySettings) IsStartupOnly() bool

func (*RegistrySettings) Section

func (s *RegistrySettings) Section() string

func (*RegistrySettings) Validate

func (s *RegistrySettings) Validate() error

type RegistryStats

type RegistryStats struct {
	TotalImages int64            `json:"total_images"`
	TotalSize   int64            `json:"total_size"`
	Images      []*ImageMetadata `json:"images"`
}

type Resource

type Resource string

type ResourceActions

type ResourceActions struct {
	Type    string   `json:"type"`
	Name    string   `json:"name"`
	Actions []string `json:"actions"`
}

FOR UNDERLYING REGISTRY AUTH

type RetentionPolicy

type RetentionPolicy struct {
	Enabled       bool `json:"enabled"`
	MaxVersions   int  `json:"maxVersions"`
	MaxAge        int  `json:"maxAge"` // IN DAYS
	ExcludeLatest bool `json:"excludeLatest"`
}

type Role

type Role struct {
	ID          int          `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Permissions []Permission `json:"permissions"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
}

NAMED SET OF PERMISSIONS

func (*Role) MarshalPermissions

func (r *Role) MarshalPermissions() (string, error)

PERMISSIONS TO JSON

func (*Role) UnmarshalPermissions

func (r *Role) UnmarshalPermissions(data string) error

JSON TO PERMISSIONS

type Scope

type Scope string

type SearchConfig

type SearchConfig struct {
	MaxResults   int    `json:"maxResults"`
	DefaultSort  string `json:"defaultSort"`
	DefaultOrder string `json:"defaultOrder"`
}

type SearchResponse

type SearchResponse struct {
	Results []Artifact `json:"results"`
	Total   int        `json:"total"`
	Limit   int        `json:"limit"`
	Offset  int        `json:"offset"`
	Sort    string     `json:"sort"`
	Order   string     `json:"order"`
}

type Settings

type Settings interface {
	Validate() error
	GetDefaults() Settings
	Section() string
	IsStartupOnly() bool
}

SETTINGS INTERFACE

func GetSettingsWithDefaults

func GetSettingsWithDefaults(section string) (Settings, error)

GET SETTINGS WITH DEFAULTS

func NewSettings

func NewSettings(section string) (Settings, error)

type StorageConfig

type StorageConfig struct {
	MaxFileSize        int64    `json:"maxFileSize"` // IN MB
	AllowedTypes       []string `json:"allowedTypes"`
	CompressionEnabled bool     `json:"compressionEnabled"`
}

type TimeSeriesPoint

type TimeSeriesPoint struct {
	Timestamp     time.Time `json:"timestamp"`
	UploadSpeed   float64   `json:"uploadSpeed"`
	DownloadSpeed float64   `json:"downloadSpeed"`
	ActiveUploads int32     `json:"activeUploads"`
}

type User

type User struct {
	ID        int       `json:"id"`
	Username  string    `json:"username"`
	Password  []byte    `json:"-,omitempty"`
	Groups    []string  `json:"groups"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

SYSTEM USER WITH GROUPS

func (*User) MarshalGroups

func (u *User) MarshalGroups() (string, error)

GROUPS TO JSON

func (*User) UnmarshalGroups

func (u *User) UnmarshalGroups(data string) error

JSON TO GROUPS

type VisibilityUpdateRequest

type VisibilityUpdateRequest struct {
	ID      string `json:"id"`
	Private bool   `json:"private"`
}

type VisibilityUpdateResponse

type VisibilityUpdateResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

Jump to

Keyboard shortcuts

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