model

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnapshotVersionV1 = 1 + iota
	SnapshotVersionV2
)
View Source
const (
	SourceTypeAgent   string = "agent"
	SourceTypeRvtools string = "rvtools"
)
View Source
const (
	JobStatusPending    = "pending"
	JobStatusParsing    = "parsing"
	JobStatusValidating = "validating"
	JobStatusCompleted  = "completed"
	JobStatusFailed     = "failed"
	JobStatusCancelled  = "cancelled"
)

Job status constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	gorm.Model
	ID         uuid.UUID `json:"id" gorm:"primaryKey"`
	Status     string
	StatusInfo string
	CredUrl    string
	Version    string
	SourceID   uuid.UUID
}

func NewAgentForSource

func NewAgentForSource(id uuid.UUID, source Source) Agent

func (Agent) String

func (a Agent) String() string

type AgentList

type AgentList []Agent

type Assessment

type Assessment struct {
	ID             uuid.UUID `gorm:"primaryKey;column:id;type:VARCHAR(255);"`
	CreatedAt      time.Time `gorm:"not null;default:now()"`
	UpdatedAt      *time.Time
	Name           string     `gorm:"not null;uniqueIndex:org_id_name"`
	OrgID          string     `gorm:"not null;uniqueIndex:org_id_name;index:assessments_org_id_idx"`
	Username       string     `gorm:"type:VARCHAR(255)"`
	OwnerFirstName *string    `gorm:"type:VARCHAR(100)"`
	OwnerLastName  *string    `gorm:"type:VARCHAR(100)"`
	SourceType     string     `gorm:"not null;type:VARCHAR(100)"`
	SourceID       *uuid.UUID `gorm:"type:TEXT"`
	Snapshots      []Snapshot `gorm:"foreignKey:AssessmentID;references:ID;constraint:OnDelete:CASCADE;"`
}

func (Assessment) String

func (a Assessment) String() string

type AssessmentList

type AssessmentList []Assessment

type CustomerAssessments added in v0.2.2

type CustomerAssessments struct {
	AgentCount  int
	RvToolCount int
}

type ImageInfra

type ImageInfra struct {
	gorm.Model
	SourceID         uuid.UUID `gorm:"primaryKey"`
	HttpProxyUrl     string
	HttpsProxyUrl    string
	NoProxyDomains   string
	CertificateChain string
	SshPublicKey     string
	ImageTokenKey    string
	IpAddress        string
	SubnetMask       string
	DefaultGateway   string
	Dns              string
}

type InventoryStats

type InventoryStats struct {
	Vms                                VmStats
	Os                                 OsStats
	TotalCustomers                     int
	TotalAssessmentsByCustomerBySource map[string]CustomerAssessments
	TotalInventories                   int
	Storage                            []StorageCustomerStats
}

func NewInventoryStats

func NewInventoryStats(assessments []Assessment) InventoryStats

type JSONField

type JSONField[T any] struct {
	Data T
}

JSONField wraps an arbitrary struct so that it can be included in a GORM model, for use in a JSON/JSONB field

func MakeJSONField

func MakeJSONField[T any](data T) *JSONField[T]

Return a copy of 'data', wrapped in a JSONField object

func (JSONField[T]) MarshalJSON

func (j JSONField[T]) MarshalJSON() ([]byte, error)

func (*JSONField[T]) Scan

func (j *JSONField[T]) Scan(src any) error

func (*JSONField[T]) UnmarshalJSON

func (j *JSONField[T]) UnmarshalJSON(b []byte) error

func (JSONField[T]) Value

func (j JSONField[T]) Value() (driver.Value, error)

type Key

type Key struct {
	gorm.Model
	OrgID      string          `gorm:"primaryKey"`
	ID         string          `gorm:"not null;unique"`
	PrivateKey *rsa.PrivateKey `gorm:"type:text;not null;serializer:key_serializer"`
}

type KeySerializer

type KeySerializer struct{}

func (KeySerializer) Scan

func (ks KeySerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)

func (KeySerializer) Value

func (ks KeySerializer) Value(ctx context.Context, field *schema.Field, dst reflect.Value, fieldValue interface{}) (interface{}, error)

type Label

type Label struct {
	Key      string `gorm:"primaryKey;column:key;type:VARCHAR;size:100;"`
	Value    string `gorm:"column:value;type:VARCHAR;size:100;not null"`
	SourceID string `gorm:"primaryKey;column:source_id;type:TEXT;"`
}

type OsStats

type OsStats struct {
	// TotalTypes is total of os types. (e.g. how many different os we found)
	Total int
}

type RVToolsJobMetadata added in v0.3.0

type RVToolsJobMetadata struct {
	Status       string     `json:"status,omitempty"`        // parsing, validating
	Error        string     `json:"error,omitempty"`         // error message if failed
	AssessmentID *uuid.UUID `json:"assessment_id,omitempty"` // set when completed
}

RVToolsJobMetadata is stored in river_job.metadata to track progress and results.

type Snapshot

type Snapshot struct {
	ID           uint      `gorm:"primaryKey;autoIncrement"`
	CreatedAt    time.Time `gorm:"not null;default:now()"`
	Inventory    []byte    `gorm:"type:jsonb;not null"`
	AssessmentID uuid.UUID `gorm:"not null;type:VARCHAR(255);"`
	Version      uint      `gorm:"type:smallint;not null;default:1"`
}

func (Snapshot) String

func (s Snapshot) String() string

type Source

type Source struct {
	gorm.Model
	ID          uuid.UUID `gorm:"primaryKey;"`
	Name        string    `gorm:"uniqueIndex:name_org_id;not null"`
	VCenterID   string
	Username    string
	OrgID       string `gorm:"uniqueIndex:name_org_id;not null"`
	Inventory   []byte `gorm:"type:jsonb"`
	OnPremises  bool
	Agents      []Agent    `gorm:"constraint:OnDelete:CASCADE;"`
	ImageInfra  ImageInfra `gorm:"constraint:OnDelete:CASCADE;"`
	Labels      []Label    `gorm:"foreignKey:SourceID;references:ID;constraint:OnDelete:CASCADE;"`
	EmailDomain *string
}

func (Source) String

func (s Source) String() string

type SourceList

type SourceList []Source

type StorageCustomerStats

type StorageCustomerStats struct {
	TotalByProvider map[string]int
	Domain          string
}

type VmStats

type VmStats struct {
	// Total is the total number of vms
	Total int
	// Total number of vm by customer (key is organization id)
	TotalByCustomer map[string]int
	// Total number of vm by OS.
	TotalByOS map[string]int
}

Jump to

Keyboard shortcuts

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