model

package
v0.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResourceOption

type APIResourceOption func(*apiResourceOptions)

func WithSummary

func WithSummary(summary *api.DevicesSummary) APIResourceOption

type CertificateSigningRequest

type CertificateSigningRequest struct {
	Resource

	// The desired state of the enrollment request, stored as opaque JSON object.
	Spec *JSONField[api.CertificateSigningRequestSpec] `gorm:"type:jsonb"`

	// The last reported state of the enrollment request, stored as opaque JSON object.
	Status *JSONField[api.CertificateSigningRequestStatus] `gorm:"type:jsonb"`
}

func NewCertificateSigningRequestFromApiResource

func NewCertificateSigningRequestFromApiResource(resource *api.CertificateSigningRequest) (*CertificateSigningRequest, error)

func (*CertificateSigningRequest) ListSelectors added in v0.4.0

func (*CertificateSigningRequest) ResolveSelector added in v0.4.0

func (CertificateSigningRequest) String

func (e CertificateSigningRequest) String() string

func (*CertificateSigningRequest) ToApiResource

type CertificateSigningRequestList

type CertificateSigningRequestList []CertificateSigningRequest

func (CertificateSigningRequestList) ToApiResource

func (csrl CertificateSigningRequestList) ToApiResource(cont *string, numRemaining *int64) api.CertificateSigningRequestList

type Device

type Device struct {
	Resource

	// The alias for the device.
	Alias *string `selector:"metadata.alias"`

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.DeviceSpec] `gorm:"type:jsonb"`

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.DeviceStatus] `gorm:"type:jsonb"`

	// Conditions set by the service, as opposed to the agent.
	ServiceConditions *JSONField[ServiceConditions]

	// The rendered ignition config, exposed in a separate endpoint.
	RenderedConfig *string

	// The rendered application provided by the service.
	RenderedApplications *JSONField[*[]api.RenderedApplicationSpec] `gorm:"type:jsonb"`

	// Join table with the relationship of devices to repositories (only maintained for standalone devices)
	Repositories []Repository `gorm:"many2many:device_repos;constraint:OnDelete:CASCADE;"`
}

func NewDeviceFromApiResource

func NewDeviceFromApiResource(resource *api.Device) (*Device, error)

func (*Device) ListSelectors added in v0.4.0

func (m *Device) ListSelectors() selector.SelectorNameSet

func (*Device) MapSelectorName added in v0.4.0

func (m *Device) MapSelectorName(name selector.SelectorName) []selector.SelectorName

func (*Device) ResolveSelector added in v0.4.0

func (m *Device) ResolveSelector(name selector.SelectorName) (*selector.SelectorField, error)

func (Device) String

func (d Device) String() string

func (*Device) ToApiResource

func (d *Device) ToApiResource() api.Device

type DeviceList

type DeviceList []Device

func (DeviceList) ToApiResource

func (dl DeviceList) ToApiResource(cont *string, numRemaining *int64) api.DeviceList

type EnrollmentRequest

type EnrollmentRequest struct {
	Resource

	// The desired state of the enrollment request, stored as opaque JSON object.
	Spec *JSONField[api.EnrollmentRequestSpec] `gorm:"type:jsonb"`

	// The last reported state of the enrollment request, stored as opaque JSON object.
	Status *JSONField[api.EnrollmentRequestStatus] `gorm:"type:jsonb"`
}

func NewEnrollmentRequestFromApiResource

func NewEnrollmentRequestFromApiResource(resource *api.EnrollmentRequest) (*EnrollmentRequest, error)

func (*EnrollmentRequest) ListSelectors added in v0.4.0

func (m *EnrollmentRequest) ListSelectors() selector.SelectorNameSet

func (*EnrollmentRequest) ResolveSelector added in v0.4.0

func (m *EnrollmentRequest) ResolveSelector(name selector.SelectorName) (*selector.SelectorField, error)

func (EnrollmentRequest) String

func (e EnrollmentRequest) String() string

func (*EnrollmentRequest) ToApiResource

func (e *EnrollmentRequest) ToApiResource() api.EnrollmentRequest

type EnrollmentRequestList

type EnrollmentRequestList []EnrollmentRequest

func (EnrollmentRequestList) ToApiResource

func (el EnrollmentRequestList) ToApiResource(cont *string, numRemaining *int64) api.EnrollmentRequestList

type Fleet

type Fleet struct {
	Resource

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.FleetSpec] `gorm:"type:jsonb"`

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.FleetStatus] `gorm:"type:jsonb"`

	// Join table with the relationship of fleets to repositories
	Repositories []Repository `gorm:"many2many:fleet_repos;constraint:OnDelete:CASCADE;"`
}

func NewFleetFromApiResource

func NewFleetFromApiResource(resource *api.Fleet) (*Fleet, error)

func (*Fleet) ListSelectors added in v0.4.0

func (m *Fleet) ListSelectors() selector.SelectorNameSet

func (*Fleet) ResolveSelector added in v0.4.0

func (m *Fleet) ResolveSelector(name selector.SelectorName) (*selector.SelectorField, error)

func (Fleet) String

func (d Fleet) String() string

func (*Fleet) ToApiResource

func (f *Fleet) ToApiResource(opts ...APIResourceOption) api.Fleet

type FleetList

type FleetList []Fleet

func (FleetList) ToApiResource

func (dl FleetList) ToApiResource(cont *string, numRemaining *int64) api.FleetList

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 JSONMap added in v0.4.0

type JSONMap[K comparable, V any] map[K]V

JSONMap represents a generic map that can be stored as JSONB in PostgreSQL.

func MakeJSONMap added in v0.4.0

func MakeJSONMap[K comparable, V any](src map[K]V) JSONMap[K, V]

MakeJSONMap initializes a JSONMap from a standard map.

func (*JSONMap[K, V]) Scan added in v0.4.0

func (m *JSONMap[K, V]) Scan(src interface{}) error

Scan implements the sql.Scanner interface for reading from PostgreSQL.

func (JSONMap[K, V]) Value added in v0.4.0

func (m JSONMap[K, V]) Value() (driver.Value, error)

Value implements the driver.Valuer interface for writing to PostgreSQL.

type Repository

type Repository struct {
	Resource

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.RepositorySpec] `gorm:"type:jsonb"`

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.RepositoryStatus] `gorm:"type:jsonb"`

	// Join table with the relationship of repository to fleets
	Fleets []Fleet `gorm:"many2many:fleet_repos;constraint:OnDelete:CASCADE;"`

	// Join table with the relationship of repository to devices (only maintained for standalone devices)
	Devices []Device `gorm:"many2many:device_repos;constraint:OnDelete:CASCADE;"`
}

func NewRepositoryFromApiResource

func NewRepositoryFromApiResource(resource *api.Repository) (*Repository, error)

func (*Repository) ListSelectors added in v0.4.0

func (m *Repository) ListSelectors() selector.SelectorNameSet

func (*Repository) ResolveSelector added in v0.4.0

func (m *Repository) ResolveSelector(name selector.SelectorName) (*selector.SelectorField, error)

func (Repository) String

func (d Repository) String() string

func (*Repository) ToApiResource

func (f *Repository) ToApiResource() (api.Repository, error)

type RepositoryList

type RepositoryList []Repository

func (RepositoryList) ToApiResource

func (dl RepositoryList) ToApiResource(cont *string, numRemaining *int64) (api.RepositoryList, error)

type Resource

type Resource struct {
	// Uniquely identifies the tenant the resource belongs to.
	// Assigned by IAM. Immutable.
	OrgID uuid.UUID `gorm:"type:uuid;primary_key;index:owner_idx,priority:2"`

	// Uniquely identifies the resource within a tenant and schema.
	// Depending on the schema (kind), assigned by the device management system or the crypto identity of the device (public key). Immutable.
	// This may become a URN later, so it's important API users treat this as an opaque handle.
	Name string `gorm:"primary_key;" selector:"metadata.name"`

	// The "kind/name" of the resource owner of this resource.
	Owner *string `gorm:"index:owner_idx,priority:1" selector:"metadata.owner"`

	// Labels associated with the resource, used for selecting and querying objects.
	// Labels are stored as a JSONB object, supporting flexible indexing and querying capabilities.
	Labels JSONMap[string, string] `gorm:"type:jsonb" selector:"metadata.labels,hidden,private"`

	// Annotations associated with the resource, used for storing additional metadata.
	// Similar to labels, annotations are stored as a JSONB object to support flexible indexing and querying.
	Annotations JSONMap[string, string] `gorm:"type:jsonb" selector:"metadata.annotations,hidden,private"`

	Generation      *int64
	ResourceVersion *int64
	CreatedAt       time.Time `selector:"metadata.creationTimestamp"`
	UpdatedAt       time.Time
	DeletedAt       gorm.DeletedAt `gorm:"index"`
}

func (*Resource) BeforeCreate

func (r *Resource) BeforeCreate(tx *gorm.DB) error

type ResourceSync

type ResourceSync struct {
	Resource

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.ResourceSyncSpec] `gorm:"type:jsonb"`

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.ResourceSyncStatus] `gorm:"type:jsonb"`
}

func NewResourceSyncFromApiResource

func NewResourceSyncFromApiResource(resource *api.ResourceSync) (*ResourceSync, error)

func (*ResourceSync) AddPathAccessCondition

func (rs *ResourceSync) AddPathAccessCondition(err error)

func (*ResourceSync) AddRepoAccessCondition

func (rs *ResourceSync) AddRepoAccessCondition(err error)

func (*ResourceSync) AddRepoNotFoundCondition

func (rs *ResourceSync) AddRepoNotFoundCondition(err error)

func (*ResourceSync) AddResourceParsedCondition

func (rs *ResourceSync) AddResourceParsedCondition(err error)

func (*ResourceSync) AddSyncedCondition

func (rs *ResourceSync) AddSyncedCondition(err error)

func (*ResourceSync) ListSelectors added in v0.4.0

func (m *ResourceSync) ListSelectors() selector.SelectorNameSet

func (*ResourceSync) NeedsSyncToHash

func (rs *ResourceSync) NeedsSyncToHash(hash string) bool

NeedsSyncToHash returns true if the resource needs to be synced to the given hash.

func (*ResourceSync) ResolveSelector added in v0.4.0

func (m *ResourceSync) ResolveSelector(name selector.SelectorName) (*selector.SelectorField, error)

func (*ResourceSync) SetCondition

func (rs *ResourceSync) SetCondition(conditionType api.ConditionType, okReason, failReason string, err error) bool

func (*ResourceSync) String

func (r *ResourceSync) String() string

func (*ResourceSync) ToApiResource

func (r *ResourceSync) ToApiResource() api.ResourceSync

type ResourceSyncList

type ResourceSyncList []ResourceSync

func (ResourceSyncList) ToApiResource

func (rl ResourceSyncList) ToApiResource(cont *string, numRemaining *int64) api.ResourceSyncList

type ServiceConditions

type ServiceConditions struct {
	Conditions *[]api.Condition `json:"conditions,omitempty"`
}

type TemplateVersion

type TemplateVersion struct {
	OrgID           uuid.UUID               `gorm:"type:uuid;primary_key;"`
	Name            string                  `gorm:"primary_key;" selector:"metadata.name"`
	FleetName       string                  `gorm:"primary_key;" selector:"metadata.owner"`
	Fleet           Fleet                   `gorm:"foreignkey:OrgID,FleetName;constraint:OnDelete:CASCADE;"`
	Labels          JSONMap[string, string] `gorm:"type:jsonb" selector:"metadata.labels,hidden,private"`
	Annotations     JSONMap[string, string] `gorm:"type:jsonb" selector:"metadata.annotations,hidden,private"`
	Generation      *int64
	ResourceVersion *int64
	CreatedAt       time.Time `selector:"metadata.creationTimestamp"`
	UpdatedAt       time.Time
	DeletedAt       gorm.DeletedAt `gorm:"index"`

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.TemplateVersionSpec] `gorm:"type:jsonb"`

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.TemplateVersionStatus] `gorm:"type:jsonb"`
}

func NewTemplateVersionFromApiResource

func NewTemplateVersionFromApiResource(resource *api.TemplateVersion) (*TemplateVersion, error)

func (TemplateVersion) String

func (t TemplateVersion) String() string

func (*TemplateVersion) ToApiResource

func (t *TemplateVersion) ToApiResource() api.TemplateVersion

type TemplateVersionList

type TemplateVersionList []TemplateVersion

func (TemplateVersionList) ToApiResource

func (tl TemplateVersionList) ToApiResource(cont *string, numRemaining *int64) api.TemplateVersionList

Jump to

Keyboard shortcuts

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