Skip to content

Commit

Permalink
Update everything to current metal
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchbg committed Jun 6, 2024
1 parent 7a90698 commit c959a46
Show file tree
Hide file tree
Showing 37 changed files with 1,837 additions and 1,258 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
metal-provider
20 changes: 10 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
version: 2
updates:
#- package-ecosystem: gomod
# directory: "/"
# schedule:
# interval: daily
# commit-message:
# prefix: ""
# reviewers:
# - Gchbg
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
commit-message:
prefix: ""
reviewers:
- Gchbg
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
commit-message:
prefix: ""
reviewers:
- Gchbg
- Gchbg
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
commit-message:
prefix: ""
reviewers:
- Gchbg
- Gchbg
8 changes: 7 additions & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ autolabeler:
- '/fix\/.+/'
title:
- '/fix/i'
- label: 'enhancement'
- label: 'feature'
branch:
- '/feature\/.+/'
- label: 'enhancement'
branch:
- '/enh\/.+/'
- label: 'chore'
branch:
- '/chore\/.+/'
template: |
## Changes
$CHANGES
20 changes: 20 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Enable auto-merge

on: pull_request_target

jobs:
auto-merge:
name: Enable auto-merge
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
if: ${{ github.event.pull_request.draft == false }}
steps:
- name: Set up CLI
uses: ksivamuthu/actions-setup-gh-cli@v3
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: Release Drafter
name: Draft release

on:
pull_request_target:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-drafter:
name: Draft release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Draft release
uses: release-drafter/release-drafter@v6
with:
disable-releaser: github.ref != 'refs/heads/main'
config-name: release-drafter.yml
commitish: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 10 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
args: --timeout=7m
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run linter
uses: golangci/golangci-lint-action@v6
11 changes: 5 additions & 6 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Publish Docker Image
name: Build and publish Docker image

env:
platforms: linux/amd64,linux/arm64
Expand All @@ -9,16 +9,15 @@ on:
- main
tags:
- v*
pull_request:

permissions:
contents: read
packages: write
pull_request_target:

jobs:
publish-docker:
name: Build and publish Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: REUSE Compliance Check
name: Check REUSE compliance

on: pull_request

Expand Down
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
Dockerfile.cross
metal-provider

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Go workspace file
go.work

# Kubernetes Generated files - skip generated files, except for vendored files
!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
24 changes: 24 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
run:
allow-parallel-runners: true
timeout: 5m

linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- goconst
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
FROM golang:1.22.3 as builder
ARG GOARCH
FROM golang:1.22.3 AS builder
ARG TARGETOS
ARG TARGETARCH

WORKDIR /metal-provider

COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY cmd/ cmd/
COPY internal/ internal/
COPY servers/ servers/
COPY *.go ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -a -o metal-provider .
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o metal-provider cmd/main.go

FROM debian:bookworm-20240513-slim

WORKDIR /

USER 65532:65532
ENTRYPOINT ["/metal-provider"]

Expand Down
37 changes: 29 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ SHELL = /usr/bin/env bash -o pipefail
.PHONY: all
all: build

##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand All @@ -17,17 +32,23 @@ vet: ## Run go vet against code.
@go vet ./...

.PHONY: test
test: fmt vet ## Run tests.
@go run github.com/onsi/ginkgo/v2/ginkgo -r --race --randomize-suites --randomize-all --keep-going --timeout=9223372036s -v
test: ## Run tests.
@go run github.com/onsi/ginkgo/v2/ginkgo -r --race --randomize-suites --keep-going --randomize-all --repeat=11

.PHONY: build
build: fmt vet ## Build manager binary.
@go build -o metal-provider .
.PHONY: lint
lint: ## Run golangci-lint linter & yamllint.
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run

.PHONY: addlicense
addlicense: ## Add license headers to all go files.
find . -name '*.go' -exec go run github.com/google/addlicense -f hack/license-header.txt {} +
@find . -name '*.go' -exec go run github.com/google/addlicense -f .reuse/license-header.txt {} +

.PHONY: checklicense
checklicense: ## Check that every file has a license header present.
find . -name '*.go' -exec go run github.com/google/addlicense -check -c 'IronCore authors' {} +
@find . -name '*.go' -exec go run github.com/google/addlicense -check -c 'IronCore authors' {} +

##@ Build

.PHONY: build
build: fmt vet ## Build manager binary.
@go build -o metal-provider cmd/main.go
6 changes: 6 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
domain: ironcore.dev
layout:
- go.kubebuilder.io/v4
projectName: metal-provider
repo: github.com/ironcore-dev/metal-provider
version: "3"
Loading

0 comments on commit c959a46

Please sign in to comment.