models

package
v0.0.0-...-11ae3f5 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BootentrySearchFields = []string{
	"name",
}
View Source
var ComputerSearchFields = []string{
	"name",
	"hostname",
	"mac",
	"ip",
	"serial",
}
View Source
var IpxeAccountSearchFields = []string{
	"username",
}

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword : Encrypt user password

Types

type Bootentry

type Bootentry struct {
	Uuid        uuid.UUID       `gorm:"type:uuid;primaryKey" json:"id"`
	Name        string          `gorm:"uniqueIndex:idx_name" json:"name"`
	Description string          `json:"description"`
	Persistent  *bool           `gorm:"not null;default:FALSE" json:"persistent"`
	IpxeScript  string          `json:"ipxe_script"`
	GrupScript  string          `json:"grub_script"`
	Files       []BootentryFile `gorm:"foreignkey:bootentry_uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"files"`
	Bootorder   []*Bootorder    `gorm:"foreignKey:bootentry_uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

func (*Bootentry) GetDownloadBasePath

func (b *Bootentry) GetDownloadBasePath() (string, *Token)

func (*Bootentry) GetFile

func (b *Bootentry) GetFile(filename string) *BootentryFile

func (*Bootentry) UnmarshalJSON

func (o *Bootentry) UnmarshalJSON(data []byte) error

type BootentryFile

type BootentryFile struct {
	Name          string     `gorm:"primaryKey;index" json:"name"`
	SubPath       string     `gorm:"default:''" json:"subpath"`
	Protected     *bool      `gorm:"not null;default:FALSE" json:"protected"`
	Templatized   *bool      `gorm:"not null;default:FALSE" json:"templatized"`
	BootentryUUID uuid.UUID  `gorm:"type:uuid;primaryKey;index" json:"-"`
	Bootentry     *Bootentry `gorm:"foreignkey:bootentry_uuid;References:Uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func (*BootentryFile) GetAPIDownloadPath

func (b *BootentryFile) GetAPIDownloadPath() string

func (*BootentryFile) GetDownloadPath

func (b *BootentryFile) GetDownloadPath() (string, *Token)

func (*BootentryFile) GetFileStorePath

func (b *BootentryFile) GetFileStorePath() string

func (BootentryFile) MarshalJSON

func (o BootentryFile) MarshalJSON() ([]byte, error)

MarshalJSON initializes nil slices and then marshals the bag to JSON

func (*BootentryFile) UnmarshalJSON

func (o *BootentryFile) UnmarshalJSON(data []byte) error

type Bootorder

type Bootorder struct {
	Order         int        `gorm:"not null;" json:"-"`
	ComputerUuid  uuid.UUID  `gorm:"primaryKey;not null;"`
	Computer      *Computer  `gorm:"foreignkey:computer_uuid;References:Uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	BootentryUuid uuid.UUID  `gorm:"primaryKey;not null;"`
	Bootentry     *Bootentry `gorm:"foreignkey:bootentry_uuid;References:Uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	CreatedAt     time.Time  `gorm:"autoCreateTime;not null;default:current_timestamp" json:"-"`
	UpdatedAt     time.Time  `gorm:"autoUpdateTime;not null;default:current_timestamp" json:"-"`
}

type Computer

type Computer struct {
	Uuid              uuid.UUID      `gorm:"type:uuid;primaryKey" json:"id"`
	Mac               pgtype.Macaddr `gorm:"type:macaddr;index:idx_mac" json:"-"`
	IP                pgtype.Inet    `gorm:"type:inet;index:idx_ip" json:"-"`
	Asset             string         `json:"asset"`
	BuildArch         string         `json:"build_arch"`
	Hostname          string         `json:"hostname"`
	LastSeen          time.Time      `json:"last_seen"`
	Manufacturer      string         `json:"manufacturer"`
	Name              string         `json:"name"`
	Platform          string         `json:"platform"`
	Product           string         `json:"product"`
	Serial            string         `json:"serial"`
	Version           string         `json:"version"`
	Tags              []*Tag         `gorm:"foreignkey:computer_uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"tags"`
	Bootorder         []*Bootorder   `gorm:"foreignKey:computer_uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	LastIpxeaccountID *string        `json:"last_ipxeaccount"`
	LastIpxeaccount   *Ipxeaccount   `gorm:"foreignkey:last_ipxeaccount_id;References:Username;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;default:NULL" json:"-"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
}

func (Computer) MarshalJSON

func (c Computer) MarshalJSON() ([]byte, error)

MarshalJSON initializes nil slices and then marshals the bag to JSON

func (*Computer) UnmarshalJSON

func (c *Computer) UnmarshalJSON(data []byte) error

type Error

type Error struct {
	Error string `json:"message"`
}

type Ipxeaccount

type Ipxeaccount struct {
	Username  string    `gorm:"primarykey" json:"username"`
	Password  string    `json:"password,omitempty"`
	IsAdmin   *bool     `gorm:"not null;default:FALSE" json:"is_admin"`
	LastLogin time.Time `json:"last_login"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (Ipxeaccount) MarshalJSON

func (o Ipxeaccount) MarshalJSON() ([]byte, error)

MarshalJSON initializes nil slices and then marshals the bag to JSON

func (*Ipxeaccount) UnmarshalJSON

func (c *Ipxeaccount) UnmarshalJSON(data []byte) error

type Tag

type Tag struct {
	Key          string    `gorm:"primaryKey;index" json:"key"`
	Value        string    `json:"value"`
	ComputerUUID uuid.UUID `gorm:"primaryKey;type:uuid;index" json:"-"`
}

type Token

type Token struct {
	Token         string    `gorm:"primaryKey" json:"token"`
	Computer      Computer  `gorm:"ForeignKey:ComputerUUID;References:Uuid;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	ComputerUUID  uuid.UUID `gorm:"not null" json:"computer_uuid"`
	Bootentry     Bootentry `gorm:"ForeignKey:BootentryUUID;References:Uuid,Name;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	BootentryUUID uuid.UUID `gorm:"not null" json:"bootentry_uuid"`
	// BootentryFile can be null if we generate DownloadBaseURL
	BootentryFile *BootentryFile `gorm:"ForeignKey:BootentryUUID,Filename;References:BootentryUUID,Name;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
	Filename      *string        `json:"filename"`
	ExpireAt      time.Time      `gorm:"index:idx_expire_at" json:"expire"`
}

Jump to

Keyboard shortcuts

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