model

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 13 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

View Source
var (
	CertificateSigningRequestAPI      = "v1alpha1"
	CertificateSigningRequestKind     = "CertificateSigningRequest"
	CertificateSigningRequestListKind = "CertificateSigningRequestList"
)
View Source
var (
	DeviceAPI      = "v1alpha1"
	DeviceKind     = "Device"
	DeviceListKind = "DeviceList"

	DeviceAnnotationTemplateVersion = "fleet-controller/templateVersion"
	DeviceAnnotationRenderedVersion = "device-controller/renderedVersion"
	DeviceAnnotationConsole         = "device-controller/console"
)
View Source
var (
	EnrollmentRequestAPI      = "v1alpha1"
	EnrollmentRequestKind     = "EnrollmentRequest"
	EnrollmentRequestListKind = "EnrollmentRequestList"
)
View Source
var (
	FleetAPI      = "v1alpha1"
	FleetKind     = "Fleet"
	FleetListKind = "FleetList"

	FleetAnnotationTemplateVersion = "fleet-controller/templateVersion"
)
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 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) 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 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

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

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

	// 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
	ResourceVersion *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] `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) 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 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;"`
	FleetName       string         `gorm:"primary_key;"`
	Fleet           Fleet          `gorm:"foreignkey:OrgID,FleetName;constraint:OnDelete:CASCADE;"`
	Labels          pq.StringArray `gorm:"type:text[]"`
	Annotations     pq.StringArray `gorm:"type:text[]"`
	Generation      *int64
	ResourceVersion *int64
	CreatedAt       time.Time
	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"`

	// 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, 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