Skip to content

Commit 3bf87e9

Browse files
committed
PR review
1 parent c2feeef commit 3bf87e9

37 files changed

+171
-1894
lines changed

.golangci.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,39 @@ run:
55
linters:
66
default: none
77
enable:
8+
- bodyclose
9+
- containedctx
810
- copyloopvar
9-
- dupl
11+
- dupword
12+
- durationcheck
1013
- errcheck
14+
- errname
15+
- errorlint
16+
- exptostd
17+
- forbidigo
1118
- ginkgolinter
19+
- gocheckcompilerdirectives
1220
- goconst
13-
- gocyclo
21+
- gocritic
22+
- gosec
1423
- govet
1524
- ineffassign
16-
- lll
25+
- intrange
1726
- misspell
18-
- nakedret
19-
- prealloc
20-
- revive
27+
- nilerr
28+
- nolintlint
29+
- nosprintfhostport
30+
- perfsprint
31+
- predeclared
32+
- rowserrcheck
33+
- sqlclosecheck
2134
- staticcheck
2235
- unconvert
2336
- unparam
2437
- unused
38+
- usestdlibvars
39+
- usetesting
40+
- whitespace
2541
settings:
2642
revive:
2743
rules:
@@ -30,6 +46,12 @@ linters:
3046
exclusions:
3147
generated: lax
3248
rules:
49+
- linters:
50+
- perfsprint
51+
- nolintlint
52+
- gosec
53+
- forbidigo
54+
path: test/
3355
- linters:
3456
- lll
3557
path: api/*
@@ -45,6 +67,8 @@ linters:
4567
path: test
4668
- linters:
4769
- lll
70+
- gosec
71+
- forbidigo
4872
path: hack/provider
4973
- linters:
5074
- gocyclo
@@ -55,6 +79,12 @@ linters:
5579
path: internal/provider/cisco/nxos
5680
- linters:
5781
- lll
82+
- perfsprint
83+
- gosec
84+
- gocritic
85+
- whitespace
86+
- errorlint
87+
- dupword
5888
path: internal/provider/openconfig
5989
- linters:
6090
- staticcheck
@@ -64,6 +94,10 @@ linters:
6494
- gofmt
6595
- gocyclo
6696
- dupl
97+
- gocritic
98+
- whitespace
99+
- perfsprint
100+
- errorlint
67101
path: internal/provider/cisco/nxos/genyang
68102
- linters:
69103
- staticcheck
@@ -81,6 +115,11 @@ formatters:
81115
enable:
82116
- gofmt
83117
- goimports
118+
settings:
119+
goimports:
120+
# Put local imports after 3rd-party packages
121+
local-prefixes:
122+
- github.com/ironcore-dev/network-operator
84123
exclusions:
85124
generated: lax
86125
paths:

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Image URL to use all building/pushing image targets
22
IMG ?= controller:latest
3+
TEST_SERVER_IMG ?= gnmi-test-server:latest
34

45
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
56
ifeq (,$(shell go env GOBIN))
@@ -135,6 +136,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
135136
.PHONY: helm
136137
helm: manifests kubebuilder
137138
$(KUBEBUILDER) edit --plugins=helm/v1-alpha
139+
@rm -rf charts/network-operator && mv dist/chart charts/network-operator && rm -rf dist
138140

139141
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
140142
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
@@ -170,6 +172,13 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
170172
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
171173
$(KUSTOMIZE) build config/default > dist/install.yaml
172174

175+
.PHONY: build-test-gnmi-server
176+
build-test-gnmi-server: ## Build docker image with the gnmi test server.
177+
$(CONTAINER_TOOL) build -t ${TEST_SERVER_IMG} ./test/gnmi/
178+
179+
run-test-gnmi-server: build-test-gnmi-server
180+
@$(CONTAINER_TOOL) run --rm -p 8000:8000 -p 9339:9339 $(TEST_SERVER_IMG)
181+
173182
##@ Deployment
174183

175184
ifndef ignore-not-found

charts/network-operator/Chart.lock

Lines changed: 0 additions & 6 deletions
This file was deleted.

charts/network-operator/Chart.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ type: application
55
version: 0.1.0
66
appVersion: "0.1.0"
77
icon: "https://example.com/icon.png"
8-
dependencies:
9-
# See: https://github.com/sapcc/helm-charts/pkgs/container/helm-charts%2Fowner-info
10-
- name: owner-info
11-
repository: oci://ghcr.io/sapcc/helm-charts
12-
version: 1.0.0

charts/network-operator/templates/crd/networking.cloud.sap_devices.yaml

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ spec:
2121
scope: Namespaced
2222
versions:
2323
- additionalPrinterColumns:
24-
- jsonPath: .spec.endpoint
24+
- jsonPath: .spec.endpoint.address
2525
name: Endpoint
2626
type: string
27-
- jsonPath: .metadata.creationTimestamp
28-
name: Age
29-
type: date
3027
- jsonPath: .status.phase
3128
name: Phase
3229
type: string
30+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
31+
name: Ready
32+
type: string
33+
- jsonPath: .metadata.creationTimestamp
34+
name: Age
35+
type: date
3336
name: v1alpha1
3437
schema:
3538
openAPIV3Schema:
@@ -278,10 +281,86 @@ spec:
278281
- domain
279282
type: object
280283
endpoint:
281-
description: Endpoint is the management address of the device provided
282-
as <ip:port>.
283-
pattern: ^(\d{1,3}\.){3}\d{1,3}:\d{1,5}$
284-
type: string
284+
description: Endpoint contains the connection information for the
285+
device.
286+
properties:
287+
address:
288+
description: Address is the management address of the device provided
289+
as <ip:port>.
290+
pattern: ^(\d{1,3}\.){3}\d{1,3}:\d{1,5}$
291+
type: string
292+
secretRef:
293+
description: |-
294+
SecretRef is name of the authentication secret for the device containing the username and password.
295+
The secret must be of type kubernetes.io/basic-auth and as such contain the following keys: 'username' and 'password'.
296+
properties:
297+
name:
298+
description: name is unique within a namespace to reference
299+
a secret resource.
300+
type: string
301+
namespace:
302+
description: namespace defines the space within which the
303+
secret name must be unique.
304+
type: string
305+
type: object
306+
x-kubernetes-map-type: atomic
307+
tls:
308+
description: Transport credentials for grpc connection to the
309+
switch.
310+
properties:
311+
ca:
312+
description: The CA certificate to verify the server's identity.
313+
properties:
314+
key:
315+
description: The key of the secret to select from. Must
316+
be a valid secret key.
317+
type: string
318+
name:
319+
default: ""
320+
description: |-
321+
Name of the referent.
322+
This field is effectively required, but due to backwards compatibility is
323+
allowed to be empty. Instances of this type with an empty value here are
324+
almost certainly wrong.
325+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
326+
type: string
327+
optional:
328+
description: Specify whether the Secret or its key must
329+
be defined
330+
type: boolean
331+
required:
332+
- key
333+
type: object
334+
x-kubernetes-map-type: atomic
335+
certificate:
336+
description: |-
337+
The client certificate and private key to use for mutual TLS authentication.
338+
Leave empty if mTLS is not desired.
339+
properties:
340+
secretRef:
341+
description: |-
342+
Secret containing the certificate.
343+
The secret must be of type kubernetes.io/tls and as such contain the following keys: 'tls.crt' and 'tls.key'.
344+
properties:
345+
name:
346+
description: name is unique within a namespace to
347+
reference a secret resource.
348+
type: string
349+
namespace:
350+
description: namespace defines the space within which
351+
the secret name must be unique.
352+
type: string
353+
type: object
354+
x-kubernetes-map-type: atomic
355+
required:
356+
- secretRef
357+
type: object
358+
required:
359+
- ca
360+
type: object
361+
required:
362+
- address
363+
type: object
285364
grpc:
286365
description: |-
287366
Configuration for the gRPC server on the device.
@@ -484,21 +563,6 @@ spec:
484563
required:
485564
- certificates
486565
type: object
487-
secretRef:
488-
description: |-
489-
SecretRef is name of the authentication secret for the device containing the username and password.
490-
The secret must be of type kubernetes.io/basic-auth and as such contain the following keys: 'username' and 'password'.
491-
properties:
492-
name:
493-
description: name is unique within a namespace to reference a
494-
secret resource.
495-
type: string
496-
namespace:
497-
description: namespace defines the space within which the secret
498-
name must be unique.
499-
type: string
500-
type: object
501-
x-kubernetes-map-type: atomic
502566
snmp:
503567
description: SNMP global configuration.
504568
properties:
@@ -577,59 +641,6 @@ spec:
577641
- location
578642
- srcIf
579643
type: object
580-
tls:
581-
description: Transport credentials for grpc connection to the switch.
582-
properties:
583-
ca:
584-
description: The CA certificate to verify the server's identity.
585-
properties:
586-
key:
587-
description: The key of the secret to select from. Must be
588-
a valid secret key.
589-
type: string
590-
name:
591-
default: ""
592-
description: |-
593-
Name of the referent.
594-
This field is effectively required, but due to backwards compatibility is
595-
allowed to be empty. Instances of this type with an empty value here are
596-
almost certainly wrong.
597-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
598-
type: string
599-
optional:
600-
description: Specify whether the Secret or its key must be
601-
defined
602-
type: boolean
603-
required:
604-
- key
605-
type: object
606-
x-kubernetes-map-type: atomic
607-
certificate:
608-
description: |-
609-
The client certificate and private key to use for mutual TLS authentication.
610-
Leave empty if mTLS is not desired.
611-
properties:
612-
secretRef:
613-
description: |-
614-
Secret containing the certificate.
615-
The secret must be of type kubernetes.io/tls and as such contain the following keys: 'tls.crt' and 'tls.key'.
616-
properties:
617-
name:
618-
description: name is unique within a namespace to reference
619-
a secret resource.
620-
type: string
621-
namespace:
622-
description: namespace defines the space within which
623-
the secret name must be unique.
624-
type: string
625-
type: object
626-
x-kubernetes-map-type: atomic
627-
required:
628-
- secretRef
629-
type: object
630-
required:
631-
- ca
632-
type: object
633644
users:
634645
description: List of local users on the switch.
635646
items:
@@ -677,7 +688,6 @@ spec:
677688
type: object
678689
type: array
679690
required:
680-
- bootstrap
681691
- endpoint
682692
type: object
683693
status:

charts/network-operator/templates/crd/networking.cloud.sap_interfaces.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ spec:
3535
- jsonPath: .spec.mtu
3636
name: MTU
3737
type: string
38+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
39+
name: Ready
40+
type: string
3841
- jsonPath: .metadata.creationTimestamp
3942
name: Age
4043
type: date

charts/network-operator/templates/network-policy/allow-metrics-traffic.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ spec:
1919
ingress:
2020
# This allows ingress traffic from any namespace with the label metrics: enabled
2121
- from:
22-
- namespaceSelector:
23-
matchLabels:
24-
metrics: enabled # Only from namespaces with this label
22+
- namespaceSelector:
23+
matchLabels:
24+
metrics: enabled # Only from namespaces with this label
2525
ports:
2626
- port: 8443
2727
protocol: TCP

charts/network-operator/templates/rbac/role.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rules:
1111
- ""
1212
resources:
1313
- configmaps
14-
- secrets
1514
verbs:
1615
- get
1716
- list
@@ -23,6 +22,15 @@ rules:
2322
verbs:
2423
- create
2524
- patch
25+
- apiGroups:
26+
- ""
27+
resources:
28+
- secrets
29+
verbs:
30+
- get
31+
- list
32+
- update
33+
- watch
2634
- apiGroups:
2735
- networking.cloud.sap
2836
resources:

0 commit comments

Comments
 (0)