Skip to content

feat(BREV-2083): Split Byte Sizes into Value and Unit#55

Merged
drewmalin merged 14 commits intomainfrom
dmalin/BREV-2083
Nov 6, 2025
Merged

feat(BREV-2083): Split Byte Sizes into Value and Unit#55
drewmalin merged 14 commits intomainfrom
dmalin/BREV-2083

Conversation

@drewmalin
Copy link
Contributor

No description provided.

@drewmalin drewmalin requested a review from a team as a code owner November 5, 2025 22:29
ImageID string
InstanceType string
DiskSize units.Base2Bytes
DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue
Copy link
Contributor

@patelspratik patelspratik Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the internet says that changing this to
// Deprecated: TODO deprecate in favor of DiskSizeByteValue will actually mark this as deprecated. Though do you actually want to do that, or defer that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little worried it will blow up our linter but could give it a shot...

v1/bytes.go Outdated
Comment on lines 3 to 21
var zeroBytes = ByteValue{value: 0, unit: Byte}

type ByteValue struct {
// Value is the whole non-negative number of bytes of the specified unit
value uint32

// Unit is the unit of the byte value
unit ByteUnit
}

func NewByteValue(value int32, unit ByteUnit) ByteValue {
if value < 0 {
return zeroBytes
}
return ByteValue{
value: uint32(value),
unit: unit,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts on

Suggested change
var zeroBytes = ByteValue{value: 0, unit: Byte}
type ByteValue struct {
// Value is the whole non-negative number of bytes of the specified unit
value uint32
// Unit is the unit of the byte value
unit ByteUnit
}
func NewByteValue(value int32, unit ByteUnit) ByteValue {
if value < 0 {
return zeroBytes
}
return ByteValue{
value: uint32(value),
unit: unit,
}
}
var zeroBytes = byteValue{value: 0, unit: Byte}
type ByteValue interface {
Value() uint32
Unit() ByteUnit
}
type byteValue struct {
// Value is the whole non-negative number of bytes of the specified unit
value uint32
// Unit is the unit of the byte value
unit ByteUnit
}
func NewByteValue(value int32, unit ByteUnit) ByteValue {
if value < 0 {
return zeroBytes
}
return byteValue{
value: uint32(value),
unit: unit,
}
}
func (b byteValue) Value() uint32 {
return b.value
}
func (b byteValue) Unit() ByteUnit {
return b.unit
}

so that we don't have to expose the struct and callers must use NewByteValue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

patelspratik
patelspratik previously approved these changes Nov 6, 2025
@drewmalin drewmalin merged commit 7b15365 into main Nov 6, 2025
6 checks passed
@drewmalin drewmalin deleted the dmalin/BREV-2083 branch November 6, 2025 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants