github.com/webmeshproj/webmesh-cni@v0.0.27/internal/controllers/controller.go (about) 1 /* 2 Copyright 2023 Avi Zimmerman <avi.zimmerman@gmail.com>. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Package controllers contains the controllers for the webmesh-cni. 18 package controllers 19 20 import ( 21 "net/netip" 22 23 meshnode "github.com/webmeshproj/webmesh/pkg/meshnode" 24 ) 25 26 //go:generate sh -x -c "go run sigs.k8s.io/controller-tools/cmd/controller-gen@latest rbac:roleName=webmesh-cni-role webhook paths='./...' output:rbac:artifacts:config=../../deploy/rbac" 27 28 // NewNode is the function for creating a new mesh node. Declared as a variable for testing purposes. 29 var NewNode = meshnode.NewWithLogger 30 31 func validOrEmpty(prefix netip.Prefix) string { 32 if prefix.IsValid() { 33 return prefix.String() 34 } 35 return "" 36 } 37 38 func validOrNone(prefix netip.Prefix) string { 39 if prefix.IsValid() { 40 return prefix.String() 41 } 42 return "none" 43 }