This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-can specify whether we watch for pods or endpoints while keeping the default behavior -can run gubernator with -tags local to make use of local k8s config -update peer list in add function again to get initial list of peers
- Loading branch information
Showing
5 changed files
with
152 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build !local | ||
|
||
package gubernator | ||
|
||
import ( | ||
"k8s.io/client-go/rest" | ||
) | ||
|
||
func RestConfig() (*rest.Config, error) { | ||
return rest.InClusterConfig() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// +build local | ||
|
||
package gubernator | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/pkg/errors" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
func homeDir() string { | ||
if h := os.Getenv("HOME"); h != "" { | ||
return h | ||
} | ||
return os.Getenv("USERPROFILE") // windows | ||
} | ||
|
||
func config() (*rest.Config, error) { | ||
home := homeDir() | ||
if home == "" { | ||
return nil, errors.New("could not find kube config file. cannot load config") | ||
|
||
} | ||
cfg := filepath.Join(home, ".kube", "config") | ||
r, err := clientcmd.BuildConfigFromFlags("", cfg) | ||
if nil != err { | ||
return nil, err | ||
} | ||
|
||
return r, nil | ||
} | ||
|
||
func RestConfig() (*rest.Config, error) { | ||
return config() | ||
} |