Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partitionable model with generated partitions #32

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Partitionable model with generated partitions
  • Loading branch information
johnbelamaric committed Jun 16, 2024
commit 8c008ed21ba1dd6fa6c74fd7fbdbc571ca15ba3f
56 changes: 51 additions & 5 deletions dra-evolution/pkg/api/capacity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,48 @@ type DeviceShape struct {
SharedCapacity []SharedCapacity `json:"sharedCapacity,omitempty"`
}

// Device represents one individual hardware instance that can be selected based
// on its attributes.
// StringOrExpression contains either an explicit string Value or
// a CEL expression that will return a string.
type StringOrExpression struct {
Value *string `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// QuantityOrExpression contains either an explicit resource.Quantity Value
// or a CEL expression that results in a resource.Quantity (or a string that parses
// to one).
type QuantityOrExpression struct {
Value *resource.Quantity `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// QuantityOrExpression contains either an explicit bool Value
// or a CEL expression that results in a bool
type BoolOrExpression struct {
Value *bool `json:"value,omitempty"`
Expression *string `json:"expression,omitempty"`
}

// Device represents a format for a partition, and a count. The actual partitions of
// the device are generated in-memory by evaluating the format for the index values
// 0..Count.
type DevicePartition struct {

// Count identifies the number of partitions using this format.
//
// +required
Count int `json:"count"`

// Name is unique identifier among all partitions for this device. The
// device name as recorded in the allocation will be the concatenation
// of the device name and the partition name with a '-' separator.
//
// NOTE: may need a better naming scheme
//
// It must be a DNS label.
Name string `json:"name" protobuf:"bytes,1,name=name"`
//
// +required
Name StringOrExpression `json:"name" protobuf:"bytes,1,name=name"`

// Attributes defines the attributes of this partition.
// The name of each attribute must be unique. The values
Expand All @@ -129,7 +160,7 @@ type DevicePartition struct {
//
// +listType=atomic
// +optional
Attributes []DeviceAttribute `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"`
Attributes []DeviceAttributeFormat `json:"attributes,omitempty" protobuf:"bytes,3,opt,name=attributes"`

// SharedCapacityConsumed defines the set of shared capacity consumed by
// this partition.
Expand All @@ -138,7 +169,7 @@ type DevicePartition struct {
//
// +listType=atomic
// +optional
SharedCapacityConsumed []SharedCapacity `json:"sharedCapacityConsumed,omitempty"`
SharedCapacityConsumed []SharedCapacityFormat `json:"sharedCapacityConsumed,omitempty"`
}

type Device struct {
Expand Down Expand Up @@ -233,6 +264,21 @@ type SharedCapacity struct {
Capacity resource.Quantity `json:"capacity"`
}

type DeviceAttributeFormat struct {
Name StringOrExpression `json:"name"`

QuantityValue *QuantityOrExpression `json:"quantity,omitempty"`
BoolValue *BoolOrExpression `json:"bool,omitempty"`
StringValue *StringOrExpression `json:"string,omitempty"`
VersionValue *StringOrExpression `json:"version,omitempty"`
}

type SharedCapacityFormat struct {
Name StringOrExpression `json:"name"`

Capacity *QuantityOrExpression `json:"capacity,omitempty"`
}

// CStyleIdentifierMaxLength is the maximum length of a c-style identifier used for naming.
const CStyleIdentifierMaxLength = 32

Expand Down
Loading