mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #882 from sethpollack/xdg_home
honor XDG_CONFIG_HOME
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
|||||||
var _ Factory = &goFactory{}
|
var _ Factory = &goFactory{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dir = "$HOME/.config/kustomize/plugins/kvsource"
|
pluginDir = "kustomize/plugins/kvsource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newGoFactory() *goFactory {
|
func newGoFactory() *goFactory {
|
||||||
@@ -38,12 +38,20 @@ type goFactory struct {
|
|||||||
plugins map[string]KVSource
|
plugins map[string]KVSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configDir() string {
|
||||||
|
xdghome := os.Getenv("XDG_CONFIG_HOME")
|
||||||
|
if len(xdghome) == 0 {
|
||||||
|
return os.ExpandEnv("$HOME/.config")
|
||||||
|
}
|
||||||
|
return xdghome
|
||||||
|
}
|
||||||
|
|
||||||
func (p *goFactory) load(name string) (KVSource, error) {
|
func (p *goFactory) load(name string) (KVSource, error) {
|
||||||
if plug, ok := p.plugins[name]; ok {
|
if plug, ok := p.plugins[name]; ok {
|
||||||
return plug, nil
|
return plug, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
goPlugin, err := plugin.Open(fmt.Sprintf("%s/kustomize-%s.so", os.ExpandEnv(dir), name))
|
goPlugin, err := plugin.Open(fmt.Sprintf("%s/%s/kustomize-%s.so", configDir(), pluginDir, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user