Skip to content

Commit

Permalink
Make net plugins build on non-unix
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Mar 19, 2015
1 parent bec527f commit 4ee6eb8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/kubelet/network/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import (
"io/ioutil"
"path"
"strings"
"syscall"

"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
Expand All @@ -72,7 +71,6 @@ const (
setUpCmd = "setup"
tearDownCmd = "teardown"
execDir = "/usr/libexec/kubernetes/kubelet-plugins/net/exec/"
X_OK = 0x1
)

func ProbeNetworkPlugins() []network.NetworkPlugin {
Expand Down Expand Up @@ -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)
}
Expand Down
27 changes: 27 additions & 0 deletions pkg/kubelet/network/exec/exec_unix.go
Original file line number Diff line number Diff line change
@@ -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
}
23 changes: 23 additions & 0 deletions pkg/kubelet/network/exec/exec_unsupported.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 4ee6eb8

Please sign in to comment.