Make net plugins build on non-unix

This commit is contained in:
Tim Hockin 2015-03-19 16:08:08 -07:00
parent bec527f886
commit 4ee6eb8c73
3 changed files with 51 additions and 3 deletions

View File

@ -53,7 +53,6 @@ import (
"io/ioutil"
"path"
"strings"
"syscall"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
@ -72,7 +71,6 @@ const (
setUpCmd = "setup"
tearDownCmd = "teardown"
execDir = "/usr/libexec/kubernetes/kubelet-plugins/net/exec/"
X_OK = 0x1
)
func ProbeNetworkPlugins() []network.NetworkPlugin {
@ -120,7 +118,7 @@ func (plugin *execNetworkPlugin) Name() string {
}
func (plugin *execNetworkPlugin) validate() error {
if syscall.Access(plugin.getExecutable(), X_OK) != nil {
if !isExecutable(plugin.getExecutable()) {
errStr := fmt.Sprintf("Invalid exec plugin. Executable '%s' does not have correct permissions.", plugin.execName)
return errors.New(errStr)
}

View File

@ -0,0 +1,27 @@
// +build !windows
/*
Copyright 2015 Google Inc. All rights reserved.
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 exec
import "syscall"
const X_OK = 0x1
func isExecutable(path string) bool {
return syscall.Access(path, X_OK) == nil
}

View File

@ -0,0 +1,23 @@
// +build windows
/*
Copyright 2015 Google Inc. All rights reserved.
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 exec
func isExecutable(path string) bool {
return false
}