model

package
v0.0.0-...-2b06d51 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DeviceAPI      = "v1alpha1"
	DeviceKind     = "Device"
	DeviceListKind = "DeviceList"

	DeviceAnnotationMultipleOwners = "MultipleOwners"
)
View Source
var (
	EnrollmentRequestAPI      = "v1alpha1"
	EnrollmentRequestKind     = "EnrollmentRequest"
	EnrollmentRequestListKind = "EnrollmentRequestList"
)
View Source
var (
	FleetAPI      = "v1alpha1"
	FleetKind     = "Fleet"
	FleetListKind = "FleetList"
)
View Source
var (
	RepositoryAPI      = "v1alpha1"
	RepositoryKind     = "Repository"
	RepositoryListKind = "RepositoryList"
)
View Source
var (
	ResourceSyncAPI      = "v1alpha1"
	ResourceSyncKind     = "ResourceSync"
	ResourceSyncListKind = "ResourceSyncList"
)
View Source
var (
	TemplateVersionAPI      = "v1alpha1"
	TemplateVersionKind     = "TemplateVersion"
	TemplateVersionListKind = "TemplateVersionList"
)

Functions

This section is empty.

Types

type Device

type Device struct {
	Resource

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.DeviceSpec]

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.DeviceStatus]
}

func NewDeviceFromApiResource

func NewDeviceFromApiResource(resource *api.Device) *Device

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]

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

func NewEnrollmentRequestFromApiResource

func NewEnrollmentRequestFromApiResource(resource *api.EnrollmentRequest) *EnrollmentRequest

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]

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.FleetStatus]
}

func NewFleetFromApiResource

func NewFleetFromApiResource(resource *api.Fleet) *Fleet

func (Fleet) String

func (d Fleet) String() string

func (*Fleet) ToApiResource

func (f *Fleet) ToApiResource() 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 Repository

type Repository struct {
	Resource

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.RepositorySpec]

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.RepositoryStatus]
}

func NewRepositoryFromApiResource

func NewRepositoryFromApiResource(resource *api.Repository) *Repository

func (Repository) String

func (d Repository) String() string

func (*Repository) ToApiResource

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

type RepositoryList

type RepositoryList []Repository

func (RepositoryList) ToApiResource

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

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;"`

	// 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;"`

	// The "kind/name" of the resource owner of this resource.
	Owner *string

	// User-defined labels, used to select resources in queries.
	// Labels are inserted in the device column as a string array, in a way
	// that we can perform indexing and queries on them.
	Labels pq.StringArray `gorm:"type:text[]"`

	Annotations pq.StringArray `gorm:"type:text[]"`

	Generation *int64

	CreatedAt time.Time
	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]

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.ResourceSyncStatus]
}

func NewResourceSyncFromApiResource

func NewResourceSyncFromApiResource(resource *api.ResourceSync) *ResourceSync

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) NeedsSyncToHash

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

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

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 ResourceWithPrimaryKeyOwner

type ResourceWithPrimaryKeyOwner struct {
	OrgID       uuid.UUID      `gorm:"type:uuid;primary_key;"`
	Name        string         `gorm:"primary_key;"`
	Owner       *string        `gorm:"primary_key;"`
	Labels      pq.StringArray `gorm:"type:text[]"`
	Annotations pq.StringArray `gorm:"type:text[]"`
	Generation  *int64
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
}

type TemplateVersion

type TemplateVersion struct {
	ResourceWithPrimaryKeyOwner

	// The desired state, stored as opaque JSON object.
	Spec *JSONField[api.TemplateVersionSpec]

	// The last reported state, stored as opaque JSON object.
	Status *JSONField[api.TemplateVersionStatus]

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

	// An indication if this version is valid. It exposed in a Condition but easier to query here.
	Valid *bool
}

func NewTemplateVersionFromApiResource

func NewTemplateVersionFromApiResource(resource *api.TemplateVersion) *TemplateVersion

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