Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: BIOS version & settings management #138

Closed
wants to merge 13 commits into from
3 changes: 3 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Files:
mkdocs.yml
go.sum
hack/*
api/gen/*
api/proto/buf.yaml
buf.gen.yaml
Copyright: 2024 SAP SE or an SAP affiliate company and IronCore contributors
License: Apache-2.0

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ RUN go mod download
# Copy the go source
COPY cmd/manager/main.go cmd/manager/main.go
COPY cmd/metalprobe/main.go cmd/metalprobe/main.go
COPY cmd/fmiserver/main.go cmd/fmiserver/main.go
COPY api/ api/
COPY internal/ internal/
COPY bmc/ bmc/
COPY fmi/ fmi/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand All @@ -26,10 +28,15 @@ COPY bmc/ bmc/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/manager/main.go

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o metalprobe cmd/metalprobe/main.go

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o fmi-server cmd/fmiserver/main.go


# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand All @@ -48,3 +55,11 @@ COPY --from=builder /workspace/metalprobe .
USER 65532:65532

ENTRYPOINT ["/metalprobe"]

FROM gcr.io/distroless/static:nonroot AS fmi-server
LABEL source_repository="https://github.com/ironcore-dev/metal-operator"
WORKDIR /
COPY --from=builder /workspace/fmi-server .
USER 65532:65532

ENTRYPOINT ["/fmi-server"]
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: gen-proto
gen-proto: buf
$(BUF) generate

.PHONY: fmt
fmt: goimports ## Run goimports against code.
$(GOIMPORTS) -w .
Expand Down Expand Up @@ -117,10 +121,12 @@ cleandocs: ## Remove all local mkdocs Docker images (cleanup).
.PHONY: add-license
add-license: addlicense ## Add license headers to all go files.
find . -name '*.go' -exec $(ADDLICENSE) -f hack/license-header.txt {} +
find . -name '*.proto' -exec $(ADDLICENSE) -f hack/license-header.txt {} +

.PHONY: check-license
check-license: addlicense ## Check that every file has a license header present.
find . -name '*.go' -exec $(ADDLICENSE) -check -c 'IronCore authors' {} +
find . -name '*.proto' -exec $(ADDLICENSE) -check -c 'IronCore authors' {} +

.PHONY: check
check: generate manifests add-license fmt lint test # Generate manifests, code, lint, add licenses, test
Expand Down Expand Up @@ -220,6 +226,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
GOIMPORTS ?= $(LOCALBIN)/goimports-$(GOIMPORTS_VERSION)
GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs-$(GEN_CRD_API_REFERENCE_DOCS_VERSION)
ADDLICENSE ?= $(LOCALBIN)/addlicense-$(ADDLICENSE_VERSION)
BUF ?= $(LOCALBIN)/buf-$(BUF_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
Expand All @@ -229,6 +236,7 @@ GOLANGCI_LINT_VERSION ?= v1.61.0
GOIMPORTS_VERSION ?= v0.25.0
GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0
ADDLICENSE_VERSION ?= v1.1.1
BUF_VERSION ?= v1.46.0

.PHONY: addlicense
addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
Expand Down Expand Up @@ -272,6 +280,11 @@ gen-crd-api-reference-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Download gen-crd-ap
$(GEN_CRD_API_REFERENCE_DOCS): $(LOCALBIN)
$(call go-install-tool,$(GEN_CRD_API_REFERENCE_DOCS),github.com/ahmetb/gen-crd-api-reference-docs,$(GEN_CRD_API_REFERENCE_DOCS_VERSION))

.PHONY: buf
buf: $(BUF) ## Download buf locally if necessary.
$(BUF): $(LOCALBIN)
$(call go-install-tool,$(BUF),github.com/bufbuild/buf/cmd/buf,$(BUF_VERSION))

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,12 @@ resources:
kind: ServerClaim
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: ironcore.dev
group: metal
kind: ServerBIOS
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
version: v1alpha1
version: "3"
149 changes: 149 additions & 0 deletions api/gen/common/v1alpha1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading