Support units for `ByteCount` type
まだ誰も着手していません。
評価
調査の方向性
types.go の ByteCount の定義から始め、リンクされた Kubernetes Quantity と go-humanize の参照を確認して、単位のパース動作を調べます。ParseByteCount と MustParseByteCount が "16GiB" のような値を、無効な入力を含めてどのように扱うべきかを定義し、呼び出し元が結果の ByteCount を InstanceCreateParams で使用できることを検証します。
索引モデルが issue の本文から書いたものです。
説明
Overview
The Go SDK uses the ByteCount type to represent the number of bytes for instance memory, disks, and other Oxide resources. Instead of using values with units (e.g., 16GiB), users must convert these values to bytes (e.g., 17179869184). This can lead to issues if users leave off numbers or typo numbers. Some users opt to use a helper like the following to calculate the correct number of bytes.
> python3 -c 'print(16 * 1024**3)'
17179869184
This Go SDK should be updated to allow users to specify a value with a unit (e.g., 16GiB).
Implementation details
The implementation can take inspiration from the following.
- https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity
- https://pkg.go.dev/github.com/dustin/go-humanize
Here are function signatures that an implementation can use.
func MustParseByteCount(str string) ByteCount
func ParseByteCount(str string) (ByteCount, error)
Given those function signatures, here's how a user can use them in code.
params := oxide.InstanceCreateParams{
Memory: MustParseByteCount("16GiB"),
}
memory, err := ParseByteCount("16GiB")
if err != nil {
// Handle error.
}
params := oxide.InstanceCreateParams{
Memory: memory,
}
Anything else you would like to add?
No response
- 主要言語
- Go
- スター
- 26
- フォーク
- 6
- 平均マージ
- 17時間 27分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
oxidecomputer/oxide.go のほかの issue
-
Release: Go SDKオープンGo SDK Task
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
oxidecomputer/oxide.go#462 ·
-
Validate enum typesオープンEnhancement Go SDK
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
oxidecomputer/oxide.go#421 ·
-
Go SDK Task
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
oxidecomputer/oxide.go#392 ·
-
Go SDK Task
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
oxidecomputer/oxide.go#372 · コメント 2 件 ·
-
Enhancement Go SDK
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
oxidecomputer/oxide.go#358 · コメント 2 件 ·
oxidecomputer/oxide.go の issue をすべて見る
似ている issue
-
good first issue spec
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
open-telemetry/opentelemetry.io#12846 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
customer issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
dolthub/doltgresql#3969 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
hivecommons/hive#19912 ·
メンテナーはふだん 1 日以内に返信