github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/pkg/vars/vars.go (about) 1 package vars 2 3 import ( 4 "os" 5 "regexp" 6 7 "k8s.io/apimachinery/pkg/runtime" 8 "k8s.io/client-go/rest" 9 10 "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" 11 ) 12 13 var ( 14 // Namespace contains k8s namespace 15 Namespace string 16 17 // ClusterType used by the operator to specify the platform it's running on 18 // supported values [kubernetes,openshift] 19 ClusterType string 20 21 // DevMode controls the developer mode in the operator 22 // developer mode allows the operator to use un-supported network devices 23 DevMode bool 24 25 // NodeName initialize and used by the config-daemon to identify the node it's running on 26 NodeName = "" 27 28 // Destdir destination directory for the checkPoint file on the host 29 Destdir string 30 31 // PlatformType specify the current platform the operator is running on 32 PlatformType = consts.Baremetal 33 // PlatformsMap contains supported platforms for virtual VF 34 PlatformsMap = map[string]consts.PlatformTypes{ 35 "openstack": consts.VirtualOpenStack, 36 } 37 38 // SupportedVfIds list of supported virtual functions IDs 39 // loaded on daemon initialization by reading the supported-nics configmap 40 SupportedVfIds []string 41 42 // DpdkDrivers supported DPDK drivers for virtual functions 43 DpdkDrivers = []string{"igb_uio", "vfio-pci", "uio_pci_generic"} 44 45 // InChroot global variable to mark that the config-daemon code is inside chroot on the host file system 46 InChroot = false 47 48 // UsingSystemdMode global variable to mark the config-daemon is running on systemd mode 49 UsingSystemdMode = false 50 51 // ParallelNicConfig global variable to perform NIC configuration in parallel 52 ParallelNicConfig = false 53 54 // FilesystemRoot used by test to mock interactions with filesystem 55 FilesystemRoot = "" 56 57 //Cluster variables 58 Config *rest.Config = nil 59 Scheme *runtime.Scheme = nil 60 61 // PfPhysPortNameRe regex to find switchdev devices on the host 62 PfPhysPortNameRe = regexp.MustCompile(`p\d+`) 63 64 // ResourcePrefix is the device plugin prefix we use to expose the devices to the nodes 65 ResourcePrefix = "" 66 67 // DisableablePlugins contains which plugins can be disabled in sriov config daemon 68 DisableablePlugins = map[string]struct{}{"mellanox": {}} 69 ) 70 71 func init() { 72 Namespace = os.Getenv("NAMESPACE") 73 74 ClusterType = os.Getenv("CLUSTER_TYPE") 75 76 DevMode = false 77 mode := os.Getenv("DEV_MODE") 78 if mode == "TRUE" { 79 DevMode = true 80 } 81 82 Destdir = "/host/tmp" 83 destdir := os.Getenv("DEST_DIR") 84 if destdir != "" { 85 Destdir = destdir 86 } 87 88 ResourcePrefix = os.Getenv("RESOURCE_PREFIX") 89 }