Skip to content

Commit

Permalink
feat: pass basic auth to env-vars when running download plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Neerup <github@mneerup.dk>
  • Loading branch information
Exchizz committed Apr 29, 2023
1 parent 01dabe5 commit f28447c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/getter/plugingetter.go
Expand Up @@ -17,6 +17,7 @@ package getter

import (
"bytes"
"fmt"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -62,6 +63,12 @@ type pluginGetter struct {
opts options
}

func (p *pluginGetter) setupOptionsEnv(env []string) []string {
env = append(env, fmt.Sprintf("HELM_PLUGIN_USERNAME=%s", p.opts.username))
env = append(env, fmt.Sprintf("HELM_PLUGIN_PASSWORD=%s", p.opts.password))
return env
}

// Get runs downloader plugin command
func (p *pluginGetter) Get(href string, options ...Option) (*bytes.Buffer, error) {
for _, opt := range options {
Expand All @@ -71,7 +78,7 @@ func (p *pluginGetter) Get(href string, options ...Option) (*bytes.Buffer, error
argv := append(commands[1:], p.opts.certFile, p.opts.keyFile, p.opts.caFile, href)
prog := exec.Command(filepath.Join(p.base, commands[0]), argv...)
plugin.SetupPluginEnv(p.settings, p.name, p.base)
prog.Env = os.Environ()
prog.Env = p.setupOptionsEnv(os.Environ())
buf := bytes.NewBuffer(nil)
prog.Stdout = buf
prog.Stderr = os.Stderr
Expand Down

0 comments on commit f28447c

Please sign in to comment.