Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
version: "2"
run:
modules-download-mode: readonly
timeout: 3m0s # none by default in v2
timeout: 10m0s # none by default in v2

formatters:
enable:
Expand Down Expand Up @@ -126,6 +126,8 @@ linters:
- github.com/mdlayher/arp
# for github.com/sapcc/vpa_butler
- k8s.io/client-go
# until https://github.com/openconfig/ygnmi/pull/157 is merged
- github.com/openconfig/ygnmi
toolchain-forbidden: true
go-version-pattern: 1\.\d+(\.0)?$
gosec:
Expand Down Expand Up @@ -183,6 +185,7 @@ linters:
- third_party$
- builtin$
- examples$
- internal/provider/openconfig

output:
formats:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ builds:
- -X github.com/sapcc/go-api-declarations/bininfo.version={{ .Version }}
- -X github.com/sapcc/go-api-declarations/bininfo.commit={{ .FullCommit }}
- -X github.com/sapcc/go-api-declarations/bininfo.buildDate={{ .CommitDate }} # use CommitDate instead of Date for reproducibility
main: ./cmd/manager
main: ./cmd
# Set the modified timestamp on the output binary to ensure that builds are reproducible.
mod_timestamp: "{{ .CommitTimestamp }}"

Expand Down
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ install-kustomize: FORCE

fmt: FORCE install-gofumpt
@printf "\e[1;36m>> gofumpt -l -w .\e[0m\n"
@gofumpt -l -w .
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')

# Run the e2e tests against a k8s cluster.
test-e2e: FORCE
Expand Down Expand Up @@ -84,17 +84,13 @@ undeploy: FORCE install-kustomize

# Install CRDs into the k8s cluster
deploy-crds: FORCE generate install-kustomize
@if [ -d config/crd ]; then \
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"; \
@kustomize build config/crd | kubectl apply -f -; \
fi
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"
@kustomize build config/crd | kubectl apply -f -

# Uninstall CRDs from the k8s cluster
undeploy-crds: FORCE install-kustomize
@if [ -d config/crd ]; then \
@printf "\e[1;36m>> kustomize build config/crd | kubectl delete -f -\e[0m\n"; \
@kustomize build config/crd | kubectl delete --ignore-not-found=true -f -; \
fi
@printf "\e[1;36m>> kustomize build config/crd | kubectl delete -f -\e[0m\n"
@kustomize build config/crd | kubectl delete --ignore-not-found=true -f -

# Create a Kind cluster for local development and testing.
kind-create: FORCE
Expand Down Expand Up @@ -173,7 +169,7 @@ BININFO_BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
build-all: build/network-operator

build/network-operator: FORCE generate
env $(GO_BUILDENV) go build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -o build/network-operator ./cmd/manager
env $(GO_BUILDENV) go build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -o build/network-operator ./cmd

DESTDIR =
ifeq ($(shell uname -s),Darwin)
Expand All @@ -192,7 +188,7 @@ ifeq ($(GO_TESTPKGS),)
GO_TESTPKGS := ./...
endif
# which packages to measure coverage for
GO_COVERPKGS := $(shell go list ./... | grep -E '/internal')
GO_COVERPKGS := $(shell go list ./... | grep -E '/internal' | grep -Ev '/internal/provider/openconfig')
# to get around weird Makefile syntax restrictions, we need variables containing nothing, a space and comma
null :=
space := $(null) $(null)
Expand Down
20 changes: 10 additions & 10 deletions Makefile.maker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:

binaries:
- name: network-operator
fromPackage: ./cmd/manager
fromPackage: ./cmd
installTo: bin/

controllerGen:
Expand All @@ -16,6 +16,7 @@ controllerGen:

coverageTest:
only: "/internal"
except: "/internal/provider/openconfig"

dockerfile:
enabled: false
Expand All @@ -25,6 +26,9 @@ golang:

golangciLint:
createConfig: true
skipDirs:
- internal/provider/openconfig
timeout: 10m

goReleaser:
createConfig: true
Expand Down Expand Up @@ -76,7 +80,7 @@ verbatim: |

fmt: FORCE install-gofumpt
@printf "\e[1;36m>> gofumpt -l -w .\e[0m\n"
@gofumpt -l -w .
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')

# Run the e2e tests against a k8s cluster.
test-e2e: FORCE
Expand Down Expand Up @@ -118,17 +122,13 @@ verbatim: |

# Install CRDs into the k8s cluster
deploy-crds: FORCE generate install-kustomize
@if [ -d config/crd ]; then \
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"; \
@kustomize build config/crd | kubectl apply -f -; \
fi
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"
@kustomize build config/crd | kubectl apply -f -

# Uninstall CRDs from the k8s cluster
undeploy-crds: FORCE install-kustomize
@if [ -d config/crd ]; then \
@printf "\e[1;36m>> kustomize build config/crd | kubectl delete -f -\e[0m\n"; \
@kustomize build config/crd | kubectl delete --ignore-not-found=true -f -; \
fi
@printf "\e[1;36m>> kustomize build config/crd | kubectl delete -f -\e[0m\n"
@kustomize build config/crd | kubectl delete --ignore-not-found=true -f -

# Create a Kind cluster for local development and testing.
kind-create: FORCE
Expand Down
12 changes: 11 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: ironcore.dev
domain: cloud.sap
layout:
- go.kubebuilder.io/v4
plugins:
helm.kubebuilder.io/v1-alpha: {}
projectName: network-operator
repo: github.com/ironcore-dev/network-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cloud.sap
group: networking
kind: Interface
path: github.com/ironcore-dev/network-operator/api/v1alpha1
version: v1alpha1
version: "3"
16 changes: 14 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ docker_build('controller:latest', '.', ignore=['*/*/zz_generated.deepcopy.go', '
'api/', 'cmd/', 'hack/', 'internal/', 'go.mod', 'go.sum', 'Makefile',
])

local_resource('controller-gen', 'make generate', ignore=['*/*/zz_generated.deepcopy.go', 'config/crd/bases/*'], deps=[
'api/', 'cmd/', 'hack/', 'internal/', 'go.mod', 'go.sum', 'Makefile',
])

k8s_yaml(kustomize('config/default'))
k8s_resource('network-operator-controller-manager')
k8s_resource('network-operator-controller-manager', resource_deps=['controller-gen'])

# Sample resources with manual trigger mode
k8s_yaml('./config/samples/v1alpha1_interface.yaml')
k8s_resource(new_name='lo0', objects=['lo0:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
k8s_resource(new_name='lo1', objects=['lo1:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
k8s_resource(new_name='eth1-1', objects=['eth1-1:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
k8s_resource(new_name='eth1-2', objects=['eth1-2:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
k8s_resource(new_name='eth1-10', objects=['eth1-10:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)

print('🚀 network-operator development environment')
print('👉 Edit the controller code inside the api/, cmd/, or internal/ directories')
print('👉 Edit the code inside the api/, cmd/, or internal/ directories')
print('👉 Tilt will automatically rebuild and redeploy when changes are detected')
# vim: ft=tiltfile syn=python
55 changes: 55 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

// Package v1alpha1 contains API Schema definitions for the networking.cloud.sap v1alpha1 API group.
// +kubebuilder:validation:Required
// +kubebuilder:object:generate=true
// +groupName=networking.cloud.sap
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "networking.cloud.sap", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// WatchLabel is a label that can be applied to any Network API object.
//
// Controllers which allow for selective reconciliation may check this label and proceed
// with reconciliation of the object only if this label and a configured value is present.
const WatchLabel = "networking.cloud.sap/watch-filter"

// FinalizerName is the identifier used by the controllers to perform cleanup before a resource is deleted.
// It is added when the resource is created and ensures that the controller can handle teardown logic
// (e.g., deleting external dependencies) before Kubernetes finalizes the deletion.
const FinalizerName = "networking.cloud.sap/finalizer"

// Condition types that are used across different objects.
const (
// Ready is the top-level status condition that reports if an object is ready.
// This condition indicates whether the resource is ready to be used and will be calculated by the
// controller based on child conditions, if present.
ReadyCondition = "Ready"
)

// Reasons that are used across different objects.
const (
// ReadyReason indicates that the resource is ready for use.
ReadyReason = "Ready"

// NotReadyReason indicates that the resource is not ready for use.
NotReadyReason = "NotReady"

// ReconcilePendingReason indicates that the controller is waiting for resources to be reconciled.
ReconcilePendingReason = "ReconcilePending"
)
Loading
Loading