Merge pull request #11878 from Exchizz/feature/pass-basic-auth-to-download-plugin

feat: pass basic auth to env-vars when running download plugins
pull/11510/merge
Joe Julian 6 months ago committed by GitHub
commit c9366c3a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,6 +17,7 @@ package getter
import ( import (
"bytes" "bytes"
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -62,6 +63,13 @@ type pluginGetter struct {
opts options 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))
env = append(env, fmt.Sprintf("HELM_PLUGIN_PASS_CREDENTIALS_ALL=%t", p.opts.passCredentialsAll))
return env
}
// Get runs downloader plugin command // Get runs downloader plugin command
func (p *pluginGetter) Get(href string, options ...Option) (*bytes.Buffer, error) { func (p *pluginGetter) Get(href string, options ...Option) (*bytes.Buffer, error) {
for _, opt := range options { for _, opt := range options {
@ -71,7 +79,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) argv := append(commands[1:], p.opts.certFile, p.opts.keyFile, p.opts.caFile, href)
prog := exec.Command(filepath.Join(p.base, commands[0]), argv...) prog := exec.Command(filepath.Join(p.base, commands[0]), argv...)
plugin.SetupPluginEnv(p.settings, p.name, p.base) plugin.SetupPluginEnv(p.settings, p.name, p.base)
prog.Env = os.Environ() prog.Env = p.setupOptionsEnv(os.Environ())
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
prog.Stdout = buf prog.Stdout = buf
prog.Stderr = os.Stderr prog.Stderr = os.Stderr

Loading…
Cancel
Save