From ef2a21774abd7c72ee32966eb7346cb608a9144d Mon Sep 17 00:00:00 2001 From: Nashwan Azhari Date: Mon, 9 Jan 2023 12:59:43 +0200 Subject: [PATCH] cnitool: define default NETCONFPATH constant on Windows. Signed-off-by: Nashwan Azhari --- cnitool/cnitool.go | 2 -- cnitool/constants_unix.go | 22 ++++++++++++++++++++++ cnitool/constants_windows.go | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 cnitool/constants_unix.go create mode 100644 cnitool/constants_windows.go diff --git a/cnitool/cnitool.go b/cnitool/cnitool.go index b5de4808..0ab2c85d 100644 --- a/cnitool/cnitool.go +++ b/cnitool/cnitool.go @@ -34,8 +34,6 @@ const ( EnvCNIArgs = "CNI_ARGS" EnvCNIIfname = "CNI_IFNAME" - DefaultNetDir = "/etc/cni/net.d" - CmdAdd = "add" CmdCheck = "check" CmdDel = "del" diff --git a/cnitool/constants_unix.go b/cnitool/constants_unix.go new file mode 100644 index 00000000..dda0a500 --- /dev/null +++ b/cnitool/constants_unix.go @@ -0,0 +1,22 @@ +// Copyright 2023 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package main + +const ( + DefaultNetDir = "/etc/cni/net.d" +) diff --git a/cnitool/constants_windows.go b/cnitool/constants_windows.go new file mode 100644 index 00000000..d14d3e14 --- /dev/null +++ b/cnitool/constants_windows.go @@ -0,0 +1,22 @@ +// Copyright 2023 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +const ( + // NOTE: this is the most reasonable default as most CNI setups on Windows + // will have been made using the helper script in the containerd repo. + // https://github.com/containerd/containerd/blob/main/script/setup/install-cni-windows + DefaultNetDir = "C:\\Program Files\\containerd\\cni\\conf" +)