DevWeave logoDevWeave
CommunitiesDiscoverHelp ForumFeaturesWhy DevWeaveAI & Verification
Log inGet started
Back to Issue Discovery
canonical/lscompute #39openGoOpen-Source Beginners

Add public constants or getters for additional properties

Opened by @farshidtz · Assignees: None

View on GitHub
good first issue

Solve & Merge Reward: Up to +210 XP & +60 Coins

+30 XP on PR open · +180 XP & +60 coins on merge

7 GitHub Stars

Claim Status & GitHub Signal

Unassigned, with 1 comment. Unassigned does not guarantee unclaimed—read comments and linked PRs first.

AI Issue Assessment · Grounded Analyzer
2.8 / 10 · 3–4 · Beginner

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.

Skill Match Breakdown

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.

Log in to receive your free level-adapted Hint #1 grounded in this repository's files.

Skill-Gap Learning

Gap-Targeted
Learn Git

Branching, commits, rebasing, and collaborative Git workflows.

Addresses skill gap: Git & Collaboration

Learn Go

Go syntax, interfaces, error handling, goroutines, and channels.

Addresses skill gap: Go

Hands-On CodeCrafters Practice
Skill-Gap Challenge
Build your own Shell
Go

Parse commands, manage PATH lookups, pipes, and process execution.

Practice skill gap: Go

Build your own Git
Go

Implement .git storage, blob/tree objects, SHA hashing, and plumbing commands.

Practice skill gap: Go

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)

@saaicasm
View comment →

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:

  1. A small leaf package, e.g. pkg/machine/device/pci/properties, exporting the keys: Vram, Microarchitecture, ComputeCapability. It can't live in pci itself because pci imports pci/amd, pci/intel and pci/nvidia, which write the keys, so that would be an import cycle.
  2. Vendor packages write the keys using these constants.
  3. Typed getters on pci.Device, so consumers need neither the keys nor type assertions: Vram(), Microarchitecture(), ComputeCapability(), each returning (value, ok).
Peer Help Forum · canonical/lscompute #39

Issue Troubleshooting Threads (0)

Ask Peers for Help

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.

Sign In

Contribution Workflow

Track your local progress before opening a pull request on GitHub.

Repository Context

Top Repository Paths

[dir] .github
.github/.jira_sync_config.yaml
[dir] .github/workflows
.github/workflows/cla-check.yaml
.github/workflows/release-artifacts.yaml
.github/workflows/snap-ci.yaml
.gitignore
CONTRIBUTING.md
LICENSE
README.md
[dir] cmd
[dir] cmd/lscompute
cmd/lscompute/machine_details.go
cmd/lscompute/machine_details_test.go
cmd/lscompute/main.go
go.mod
go.sum
[dir] pkg
[dir] pkg/machine
[dir] pkg/machine/cpu
pkg/machine/cpu/architecture.go
pkg/machine/cpu/architecture_test.go
pkg/machine/cpu/constants.go
pkg/machine/cpu/cpu.go

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.