package inventory import ( "context" "encoding/json" "errors" "fmt" "github.com/jackc/pgx/v5" ) // Described is what a machine said about itself beyond its capabilities: the architecture and kernel // its node-engine runs on (novox/hq to-be 45 §9, the facts snapshot). type Described struct { Architecture string `json:"architecture"` Kernel string `json:"kernel"` } // DescribedOf is the architecture and kernel a machine last reported; empty for one that never has. func (i *Inventory) DescribedOf(ctx context.Context, nodeName string) (Described, error) { var raw []byte err := i.store.Pool().QueryRow(ctx, `select profile from node where name = $1`, nodeName).Scan(&raw) if errors.Is(err, pgx.ErrNoRows) { return Described{}, fmt.Errorf("%w: %s", ErrNoSuchNode, nodeName) } if err != nil || len(raw) == 0 { return Described{}, err } var r Described if err := json.Unmarshal(raw, &r); err != nil { return Described{}, err } return r, nil } // ServerVersion is the store's own word for the release it runs — the version a test suite standing in // for it must run (novox/hq ADR 0227 rule 9). func (i *Inventory) ServerVersion(ctx context.Context) (string, error) { var v string err := i.store.Pool().QueryRow(ctx, `show server_version`).Scan(&v) return v, err }