Add public constants or getters for additional properties
Opened by @farshidtz · Assignees: None
Solve & Merge Reward: Up to +210 XP & +60 Coins
+30 XP on PR open · +180 XP & +60 coins on merge
Claim Status & GitHub Signal
Unassigned, with 1 comment. Unassigned does not guarantee unclaimed—read comments and linked PRs first.
Estimated from issue labels (good first issue), Go context, and discussion depth. There are 1 GitHub comments to review for maintainer clarifications. Note: this is an estimate, not a guarantee.
What It's About
Add public constants or getters for additional properties. The additional properties, such as VRAM, microarchitecture, CUDA compute-capability are exposed in a [map](https://github.com/canonical/lscompute/blob/9b1c317124f65f7a22054ee2198ea13df0130cb1/pkg/machine/device/pci/pci.goL32). The consumer reads the keys with
Why It Matters
Resolving #39 improves reliability and developer experience in canonical/lscompute.
Expected Outcome
A focused pull request addressing #39 with relevant checks or tests verified locally.
Log in to compare this issue's requirements against your profile skills. Required concepts: Go, Git & Collaboration, Codebase Reading.
Progressive AI Hints
Hint #1 is always free and calibrated to your experience level. Extra hints unlock with coins without spoiling the full solution.
Skill-Gap Learning
Issue Description
The additional properties, such as VRAM, microarchitecture, CUDA compute-capability are exposed in a map. The consumer reads the keys with an assumption on the naming convention (currently kebab-case). This is pretty fragile.
Linked Pull Requests (0)
No linked or cross-referenced pull requests detected via GitHub timeline. Check comments below for informal claims before starting.
GitHub Comments (1)
I'd like to pick this up.
Reproduced it by changing the key to props["compute_capability"] in newPciAdditionalDeviceProperties. It builds and passes go vet, but compute-capability no longer shows up in the output.
Only the Example_marshal* expected-output blocks catch it.
Proposed approach:
- A small leaf package, e.g.
pkg/machine/device/pci/properties, exporting the keys:Vram,Microarchitecture,ComputeCapability. It can't live inpciitself becausepciimportspci/amd,pci/intelandpci/nvidia, which write the keys, so that would be an import cycle. - Vendor packages write the keys using these constants.
- Typed getters on
pci.Device, so consumers need neither the keys nor type assertions:Vram(),Microarchitecture(),ComputeCapability(), each returning(value, ok).
Issue Troubleshooting Threads (0)
No troubleshooting threads opened for this issue yet. If you hit a test, build, or navigation blocker, post what you've tried so fellow contributors can help.
PR Verification & Rewards
Sign in and link GitHub to verify your PR against this issue and earn XP + coins.
Contribution Workflow
Track your local progress before opening a pull request on GitHub.
Repository Context
Top Repository Paths
CONTRIBUTING.md Excerpt
Contributing to lscompute
How to add a new hardware bus
Adding support for a new bus (e.g. I2C, MIPI CSI, AMBA) follows a fixed recipe.
You only add a new package inside device directory and load it in machine.go.
Step 1 — Create the bus package directory
pkg/machine/device/<busname>/
<busname>.go ← BusName constant, Device struct, Options, NewBus(), Devices()
<anything> ← sysfs reader, ID lookup, vendor logic, tests, …
The simplest bus implementation lives entirely in a single <busname>.go file.
Add extra files (e.g. sys<busname>.go, vendor.go) when the implementation grows.
Step 2 — Implement <busname>.go
package <busname>
import (
"github.com/canonical/lscompute/pkg/machine/host"
)
const BusName = "<busname>"
// Device represents a single <busType> device detected on the system.
//
// Public device structs carry no serialization tags: the human-readable
// JSON/YAML rendering lives in `cmd/lscompute` (see `MachineDetails`).
type Device struct {
Bus string
// TODO: add bus-specific fields here
// Optional: vendor-specific key-value pairs
AdditionalProperties map[string]string
}
// Options holds <busType>-specific bus configuration.
type Options struct{}
// <busType> is the <busType> bus implementation.
type <busType> struct {
host host.Host
opts Options
}
// NewBus returns a <busType> bus configured with the given options.
func NewBus(h host.Host, opts Options) *<busType> {
return &<busType>{host: h, opts: opts}
}
// Devices discovers all <busType> devices on the host and returns them along
// with any warnings and a hard error if the bus could not be enumerated.
func (bus *<busType>) Devices() ([]Device, []string, error) {
// TODO: enumerate devices; set device.Bus = BusName on each result
return nil, nil, nil
}
Step 3 — Add the bus in machine.go
Add your bus to the Get() method in pkg/machine/machine.go:
<busname> := <busname>.NewBus(h, <busname>.Options{})
if d, w, err := <busname>.Devices(); err != nil {
return nil, nil, fmt.Errorf("getting <busname> devices: %w", err)
} else {
machineInfo.<BusType>Devices = d
warnings = append(warnings, w...)
}
Also import "github.com/canonical/lscompute/pkg/machine/device/<busname>" in pkg/machine/machine.go.
Advisory PR Assistant
Helps structure your PR description or unpack reviewer feedback. Does not perform GitHub actions.