mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-19 21:22:19 +00:00
Refactor exec plugin load to error if plugin isn't executable
This commit is contained in:
@@ -44,8 +44,15 @@ type ExecPlugin struct {
|
||||
h *resmap.PluginHelpers
|
||||
}
|
||||
|
||||
func NewExecPlugin(p string) *ExecPlugin {
|
||||
return &ExecPlugin{path: p}
|
||||
func NewExecPlugin(p string) (*ExecPlugin, error) {
|
||||
f, err := os.Stat(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if f.Mode()&0111 == 0000 {
|
||||
return nil, fmt.Errorf("unable to execute plugin on path: %s", p)
|
||||
}
|
||||
return &ExecPlugin{path: p}, nil
|
||||
}
|
||||
|
||||
func (p *ExecPlugin) Path() string {
|
||||
@@ -60,15 +67,6 @@ func (p *ExecPlugin) Cfg() []byte {
|
||||
return p.cfg
|
||||
}
|
||||
|
||||
// isAvailable checks to see if the plugin is available
|
||||
func (p *ExecPlugin) IsAvailable() bool {
|
||||
f, err := os.Stat(p.path)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return f.Mode()&0111 != 0000
|
||||
}
|
||||
|
||||
func (p *ExecPlugin) Config(h *resmap.PluginHelpers, config []byte) error {
|
||||
p.h = h
|
||||
p.cfg = config
|
||||
|
||||
Reference in New Issue
Block a user