Skip to content

Commit

Permalink
feat: fix reading "broken" Hyper-V DMI data
Browse files Browse the repository at this point in the history
The fix goes into the `digitalocean/go-smbios` library which seems to be
no longer supported now. So I put as `internal/` sub-package so we can
make easy changes to it in sync with our library.

License check was disabled so that it doesn't complain about Apache
licensed files imported.

Adds support for and testing of extracting HyperV SMBIOS data.

Signed-off-by: Tim Jones <[email protected]>
Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
TimJones authored and smira committed Feb 20, 2023
1 parent 10c1dd8 commit c526764
Show file tree
Hide file tree
Showing 45 changed files with 2,444 additions and 84 deletions.
15 changes: 2 additions & 13 deletions .conform.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-09-30T12:50:10Z by kres fe71103.
# Generated on 2023-02-20T16:38:15Z by kres latest.

---
policies:
Expand All @@ -23,15 +23,4 @@ policies:
required: true
conventional:
types: ["chore","docs","perf","refactor","style","test","release"]
scopes: [".*"]
- type: license
spec:
skipPaths:
- .git/
- testdata/
includeSuffixes:
- .go
excludeSuffixes:
- .pb.go
- .pb.gw.go
header: "// This Source Code Form is subject to the terms of the Mozilla Public\u000A// License, v. 2.0. If a copy of the MPL was not distributed with this\u000A// file, You can obtain one at http://mozilla.org/MPL/2.0/.\u000A"
scopes: [".*"]
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-12-02T19:34:17Z by kres latest.
# Generated on 2023-02-20T12:41:30Z by kres latest.

**
*
!smbios
!docs
!go.mod
Expand Down
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-09-30T12:50:10Z by kres fe71103.
# Generated on 2023-02-20T12:41:30Z by kres latest.

kind: pipeline
type: kubernetes
Expand Down Expand Up @@ -174,7 +174,7 @@ steps:

services:
- name: docker
image: docker:20.10-dind
image: docker:23.0-dind
entrypoint:
- dockerd
commands:
Expand Down
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-09-30T12:52:42Z by kres fe71103.
# Generated on 2023-02-20T12:41:30Z by kres latest.

# options for analysis running
run:
Expand Down Expand Up @@ -150,6 +150,12 @@ linters:
- maligned
- golint
- scopelint
- varcheck
- deadcode
- structcheck
- ifshort
# disabled as it seems to be broken - goes into imported libraries and reports issues there
- musttag

issues:
exclude: []
Expand Down
3 changes: 3 additions & 0 deletions .kres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: common.Repository
spec:
conformLicenseCheck: false
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# syntax = docker/dockerfile-upstream:1.2.0-labs
# syntax = docker/dockerfile-upstream:1.5.2-labs

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-09-30T12:52:42Z by kres fe71103.
# Generated on 2023-02-20T12:41:30Z by kres latest.

ARG TOOLCHAIN

# cleaned up specs and compiled versions
FROM scratch AS generate

# runs markdownlint
FROM docker.io/node:18.9.0-alpine3.16 AS lint-markdown
FROM docker.io/node:19.6.0-alpine3.16 AS lint-markdown
WORKDIR /src
RUN npm i -g markdownlint-cli@0.32.2
RUN npm i -g markdownlint-cli@0.33.0
RUN npm i [email protected]
COPY .markdownlint.json .
COPY ./docs ./docs
Expand All @@ -26,21 +26,22 @@ RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev
# build tools
FROM --platform=${BUILDPLATFORM} toolchain AS tools
ENV GO111MODULE on
ENV CGO_ENABLED 0
ARG CGO_ENABLED
ENV CGO_ENABLED ${CGO_ENABLED}
ENV GOPATH /go
ARG GOLANGCILINT_VERSION
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
&& mv /go/bin/golangci-lint /bin/golangci-lint
ARG GOFUMPT_VERSION
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumpt /bin/gofumpt
RUN go install golang.org/x/vuln/cmd/govulncheck@latest \
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/vuln/cmd/govulncheck@latest \
&& mv /go/bin/govulncheck /bin/govulncheck
ARG GOIMPORTS_VERSION
RUN go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
&& mv /go/bin/goimports /bin/goimports
ARG DEEPCOPY_VERSION
RUN go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
&& mv /go/bin/deep-copy /bin/deep-copy

# tools and sources
Expand Down
66 changes: 43 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-09-30T12:50:10Z by kres fe71103.
# Generated on 2023-02-20T16:38:15Z by kres latest.

# common variables

SHA := $(shell git describe --match=none --always --abbrev=8 --dirty)
TAG := $(shell git describe --tag --always --dirty)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ARTIFACTS := _out
WITH_DEBUG ?= false
WITH_RACE ?= false
REGISTRY ?= ghcr.io
USERNAME ?= siderolabs
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
GOLANGCILINT_VERSION ?= v1.49.0
GOFUMPT_VERSION ?= v0.3.1
GO_VERSION ?= 1.19
GOIMPORTS_VERSION ?= v0.1.12
GOLANGCILINT_VERSION ?= v1.51.2
GOFUMPT_VERSION ?= v0.4.0
GO_VERSION ?= 1.20
GOIMPORTS_VERSION ?= v0.6.0
PROTOBUF_GO_VERSION ?= 1.28.1
GRPC_GO_VERSION ?= 1.2.0
GRPC_GATEWAY_VERSION ?= 2.11.3
VTPROTOBUF_VERSION ?= 0.3.0
GRPC_GATEWAY_VERSION ?= 2.15.0
VTPROTOBUF_VERSION ?= 0.4.0
DEEPCOPY_VERSION ?= v0.5.5
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
TESTPKGS ?= ./...
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest
Expand All @@ -35,22 +40,25 @@ COMMON_ARGS = --file=Dockerfile
COMMON_ARGS += --progress=$(PROGRESS)
COMMON_ARGS += --platform=$(PLATFORM)
COMMON_ARGS += --push=$(PUSH)
COMMON_ARGS += --build-arg=ARTIFACTS=$(ARTIFACTS)
COMMON_ARGS += --build-arg=SHA=$(SHA)
COMMON_ARGS += --build-arg=TAG=$(TAG)
COMMON_ARGS += --build-arg=USERNAME=$(USERNAME)
COMMON_ARGS += --build-arg=REGISTRY=$(REGISTRY)
COMMON_ARGS += --build-arg=TOOLCHAIN=$(TOOLCHAIN)
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION=$(GOLANGCILINT_VERSION)
COMMON_ARGS += --build-arg=GOFUMPT_VERSION=$(GOFUMPT_VERSION)
COMMON_ARGS += --build-arg=GOIMPORTS_VERSION=$(GOIMPORTS_VERSION)
COMMON_ARGS += --build-arg=PROTOBUF_GO_VERSION=$(PROTOBUF_GO_VERSION)
COMMON_ARGS += --build-arg=GRPC_GO_VERSION=$(GRPC_GO_VERSION)
COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION=$(GRPC_GATEWAY_VERSION)
COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION=$(VTPROTOBUF_VERSION)
COMMON_ARGS += --build-arg=DEEPCOPY_VERSION=$(DEEPCOPY_VERSION)
COMMON_ARGS += --build-arg=TESTPKGS=$(TESTPKGS)
TOOLCHAIN ?= docker.io/golang:1.19-alpine
COMMON_ARGS += --build-arg=ARTIFACTS="$(ARTIFACTS)"
COMMON_ARGS += --build-arg=SHA="$(SHA)"
COMMON_ARGS += --build-arg=TAG="$(TAG)"
COMMON_ARGS += --build-arg=USERNAME="$(USERNAME)"
COMMON_ARGS += --build-arg=REGISTRY="$(REGISTRY)"
COMMON_ARGS += --build-arg=TOOLCHAIN="$(TOOLCHAIN)"
COMMON_ARGS += --build-arg=CGO_ENABLED="$(CGO_ENABLED)"
COMMON_ARGS += --build-arg=GO_BUILDFLAGS="$(GO_BUILDFLAGS)"
COMMON_ARGS += --build-arg=GO_LDFLAGS="$(GO_LDFLAGS)"
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)"
COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)"
COMMON_ARGS += --build-arg=GOIMPORTS_VERSION="$(GOIMPORTS_VERSION)"
COMMON_ARGS += --build-arg=PROTOBUF_GO_VERSION="$(PROTOBUF_GO_VERSION)"
COMMON_ARGS += --build-arg=GRPC_GO_VERSION="$(GRPC_GO_VERSION)"
COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION="$(GRPC_GATEWAY_VERSION)"
COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION="$(VTPROTOBUF_VERSION)"
COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
TOOLCHAIN ?= docker.io/golang:1.20-alpine

# help menu

Expand Down Expand Up @@ -85,6 +93,18 @@ respectively.

endef

ifneq (, $(filter $(WITH_RACE), t true TRUE y yes 1))
GO_BUILDFLAGS += -race
CGO_ENABLED := 1
GO_LDFLAGS += -linkmode=external -extldflags '-static'
endif

ifneq (, $(filter $(WITH_DEBUG), t true TRUE y yes 1))
GO_BUILDFLAGS += -tags sidero.debug
else
GO_LDFLAGS += -s -w
endif

all: unit-tests lint

.PHONY: clean
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module github.com/siderolabs/go-smbios

go 1.19
go 1.20

require (
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/stretchr/testify v1.8.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e h1:vUmf0yezR0y7jJ5pceLHthLaYf4bA5T14B6q39S4q2Q=
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e/go.mod h1:YTIHhz/QFSYnu/EhlF2SpU2Uk+32abacUYA5ZPljz1A=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
Expand Down
2 changes: 1 addition & 1 deletion smbios/baseboard_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package smbios

import "github.com/digitalocean/go-smbios/smbios"
import "github.com/siderolabs/go-smbios/smbios/internal/github.com/digitalocean/go-smbios/smbios"

// BaseboardInformation represents the SMBIOS baseboard information.
type BaseboardInformation struct {
Expand Down
2 changes: 1 addition & 1 deletion smbios/bios_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package smbios

import "github.com/digitalocean/go-smbios/smbios"
import "github.com/siderolabs/go-smbios/smbios/internal/github.com/digitalocean/go-smbios/smbios"

// BIOSInformation represents the BIOS information.
type BIOSInformation struct {
Expand Down
2 changes: 1 addition & 1 deletion smbios/bios_language_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package smbios

import "github.com/digitalocean/go-smbios/smbios"
import "github.com/siderolabs/go-smbios/smbios/internal/github.com/digitalocean/go-smbios/smbios"

// BIOSLanguageInformation represents the SMBIOS BIOS language information.
type BIOSLanguageInformation struct {
Expand Down
2 changes: 1 addition & 1 deletion smbios/cache_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package smbios

import "github.com/digitalocean/go-smbios/smbios"
import "github.com/siderolabs/go-smbios/smbios/internal/github.com/digitalocean/go-smbios/smbios"

// CacheInformation represents the SMBIOS cache information.
type CacheInformation struct {
Expand Down
2 changes: 1 addition & 1 deletion smbios/group_associations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package smbios

import "github.com/digitalocean/go-smbios/smbios"
import "github.com/siderolabs/go-smbios/smbios/internal/github.com/digitalocean/go-smbios/smbios"

// GroupAssociations represents the SMBIOS group associations.
type GroupAssociations struct {
Expand Down
11 changes: 11 additions & 0 deletions smbios/internal/github.com/digitalocean/go-smbios/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Maintainer
----------
DigitalOcean, Inc

Original Authors
----------------
Matt Layher <[email protected]>

Contributors
------------
Christopher Dudley <[email protected]>
Loading

0 comments on commit c526764

Please sign in to comment.