Skip to content

Commit

Permalink
Compatibility with g/g 1.89 GNA (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Aug 13, 2024
1 parent 1f6d406 commit 63ee17b
Show file tree
Hide file tree
Showing 19 changed files with 1,801 additions and 298 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
args: --build-tags integration -p bugs -p unused -D protogetter --timeout=5m

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Test Action
on:
pull_request:
branches:
- master
release:
types:
- published
push:
branches:
- master

jobs:
build:
name: Test Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.22.x'

- name: Check (lint) and Test
run: |
mkdir -p hack/tools/bin
make test-in-docker
7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
run:
concurrency: 4
deadline: 10m

linters:
disable:
- unused
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ install: revendor $(CONTROLLER_GEN) $(GEN_CRD_API_REFERENCE_DOCS) $(HELM) $(MOCK
@LD_FLAGS="-w -X github.com/gardener/$(EXTENSION_PREFIX)-$(NAME)/pkg/version.Version=$(VERSION)" \
$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/install.sh ./...

.PHONY: tidy
tidy:
@GO111MODULE=on go mod tidy

.PHONY: revendor
revendor:
@GO111MODULE=on go mod vendor
@GO111MODULE=on go mod tidy
@GO111MODULE=on go mod vendor
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/*
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/.ci/*

Expand All @@ -76,6 +80,28 @@ generate-in-docker: revendor $(HELM) $(YQ)
&& make generate \
&& chown -R $(shell id -u):$(shell id -g) ."

.PHONY: check-generate
check-generate:
@$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/check-generate.sh $(REPO_ROOT)

.PHONY: check
check: $(GOIMPORTS) $(GOLANGCI_LINT) $(HELM)
@$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./pkg/...
@$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/check-charts.sh ./charts

.PHONY: test
test:
@SKIP_FETCH_TOOLS=1 $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/test.sh ./cmd/... ./pkg/...

.PHONY: test-in-docker
test-in-docker: revendor
docker run --rm -i$(DOCKER_TTY_ARG) \
--user $$(id -u):$$(id -g) \
--mount type=tmpfs,destination=/.cache \
--volume $(PWD):/go/src/github.com/metal-stack/os-metal-extension golang:$(GO_VERSION) \
sh -c "cd /go/src/github.com/metal-stack/os-metal-extension \
&& make install check test"

.PHONY: docker-image
docker-image:
@docker build --build-arg VERIFY=$(VERIFY) -t $(IMAGE_PREFIX)/os-metal-extension:$(IMAGE_TAG) -f Dockerfile .
Expand Down
4 changes: 4 additions & 0 deletions charts/os-metal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ controllers:
renewIntervalSeconds: 30

disableControllers: []

gardener:
gardenlet:
featureGates: {}
29 changes: 11 additions & 18 deletions cmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,24 @@ import (
"os"

extcontroller "github.com/gardener/gardener/extensions/pkg/controller"
corev1 "k8s.io/api/core/v1"
componentbaseconfig "k8s.io/component-base/config"

controllercmd "github.com/gardener/gardener/extensions/pkg/controller/cmd"
"github.com/gardener/gardener/extensions/pkg/controller/heartbeat"
heartbeatcmd "github.com/gardener/gardener/extensions/pkg/controller/heartbeat/cmd"
"github.com/gardener/gardener/extensions/pkg/controller/operatingsystemconfig/oscommon"
oscommoncmd "github.com/gardener/gardener/extensions/pkg/controller/operatingsystemconfig/oscommon/cmd"
osccontroller "github.com/gardener/gardener/extensions/pkg/controller/operatingsystemconfig"
"github.com/gardener/gardener/extensions/pkg/util"
"github.com/metal-stack/os-metal-extension/pkg/generator"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
componentbaseconfig "k8s.io/component-base/config"
"sigs.k8s.io/controller-runtime/pkg/client"
runtimelog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/metal-stack/os-metal-extension/pkg/controller/operatingsystemconfig"
)

const ctrlName = "os-metal"

var osTypes = []string{"ubuntu", "debian", "nvidia"}

// NewControllerCommand returns a new Command with a new Generator
func NewControllerCommand(ctx context.Context) *cobra.Command {
g := generator.IgnitionGenerator()
if g == nil {
runtimelog.Log.Error(fmt.Errorf("generator is nil"), "Error executing the main controller command")
os.Exit(1)
}

var (
generalOpts = &controllercmd.GeneralOptions{}
restOpts = &controllercmd.RESTOptions{}
Expand All @@ -68,7 +58,10 @@ func NewControllerCommand(ctx context.Context) *cobra.Command {

reconcileOpts = &controllercmd.ReconcilerOptions{}

controllerSwitches = oscommoncmd.SwitchOptions(ctrlName, osTypes, g)
controllerSwitches = controllercmd.NewSwitchOptions(
controllercmd.Switch(osccontroller.ControllerName, operatingsystemconfig.AddToManager),
controllercmd.Switch(heartbeat.ControllerName, heartbeat.AddToManager),
)

aggOption = controllercmd.NewOptionAggregator(
generalOpts,
Expand Down Expand Up @@ -115,10 +108,10 @@ func NewControllerCommand(ctx context.Context) *cobra.Command {
return fmt.Errorf("could not update manager scheme: %w", err)
}

ctrlOpts.Completed().Apply(&oscommon.DefaultAddOptions.Controller)
ctrlOpts.Completed().Apply(&operatingsystemconfig.DefaultAddOptions.Controller)
heartbeatCtrlOpts.Completed().Apply(&heartbeat.DefaultAddOptions)

reconcileOpts.Completed().Apply(&oscommon.DefaultAddOptions.IgnoreOperationAnnotation)
reconcileOpts.Completed().Apply(&operatingsystemconfig.DefaultAddOptions.IgnoreOperationAnnotation)

if err := controllerSwitches.Completed().AddToManager(ctx, mgr); err != nil {
return fmt.Errorf("could not add controller to manager: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion example/controller-registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: os-metal
type: helm
providerConfig:
chart: H4sIAAAAAAAAA+1abW/juBHez/oVU1+BboqVFL8kaV3cB5/juzOaS4I4l8OiKBa0RMu8yKJKUna8ue1v75CSZfklibObZJEuHwSWRHFeOMPhDBlx6U6oIrH/5vmwjzg6ODBXxPrV3NebrXrjoHF4qNvr9cZR6w0cPKNOJTKpiAB4IzhX9/V76P0rBV/43xvTeMKihAv61DK0gw9brTv9j25f83+z1ay/gf2nVmQbvnH/fwfnRCkqEgmKQ+5/mI1pAsOMxSFLIkhJcE0iKj3nO7gcMwkyS1MuFN7gnIkhivkQJkQFY+z9DgSNiWJTinRqXGknSYgMEhrhW57A21TQEbuhIcwY9vvTngdnSTwHnhhKrRKkVEDMEuo53vHgw0ChbsiiyycTZHDVHUDIhHS8iCnf/ObqO97wo/DN76JhHPn6Z/Eop4m/ZDTE8WUpjFhMpfNXT85S/B2Sa/xVE7z/L3a9IoLxTEL/uIcCU8F/p4FyPBZS4uf9sMnxpjLgIfWdr+3V3VHGf3dMhPLmZBI/uYyH4r/Rqq/Hf6N+aOP/JUBSdkWFxIhsw7TukDQtH2t1b7/mhFQGgqXKNHXgZ8wSEOi5AiMuQI0p/ERESBMM1S4G19kAL4kiTDecsCS7AXqja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