Path: blob/main/install/installer/pkg/helm/settings.go
2500 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package helm56import (7"bytes"8"fmt"9"helm.sh/helm/v3/pkg/action"10"helm.sh/helm/v3/pkg/cli"11"helm.sh/helm/v3/pkg/cli/values"12"log"13"time"14)1516type Config struct {17Debug bool18KubeConfig string19KubeContext string20Name string21Namespace string22Timeout time.Duration23}2425type Settings struct {26ActionConfig *action.Configuration27Chart string28Config *Config29Env *cli.EnvSettings30Values *values.Options31}3233func SettingsFactory(config *Config, chart string, vals *values.Options) Settings {34if vals == nil {35vals = &values.Options{}36}3738settings := Settings{39ActionConfig: new(action.Configuration),40Config: config,41Env: cli.New(),42Chart: chart, // This can be a directory or a change name43Values: vals,44}4546if config.KubeConfig != "" {47settings.Env.KubeConfig = config.KubeConfig48}4950if config.KubeContext != "" {51settings.Env.KubeContext = config.KubeContext52}5354if !settings.Config.Debug {55// If not debugging, send logs to a buffer56log.SetOutput(&bytes.Buffer{})57}5859return settings60}6162func (settings *Settings) Write(format string, v ...interface{}) {63format = fmt.Sprintf("[Gitpod] %s\n", format)64log.Output(2, fmt.Sprintf(format, v...))65}666768