Put the Config in a new env package [#67]
I'd like to be able to make calls like NewUpgrade(cfg) rather than
Upgrade{...}.Prepare, but I wouldn't be able to define a NewUpgrade
function while Config is in the helm package; there would be a circular
import when Plan tried to import run.
This commit is contained in:
@@ -1,125 +0,0 @@
|
||||
package helm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
justNumbers = regexp.MustCompile(`^\d+$`)
|
||||
deprecatedVars = []string{"PURGE", "RECREATE_PODS", "TILLER_NS", "UPGRADE", "CANARY_IMAGE", "CLIENT_ONLY", "STABLE_REPO_URL"}
|
||||
)
|
||||
|
||||
// The Config struct captures the `settings` and `environment` blocks in the application's drone
|
||||
// config. Configuration in drone's `settings` block arrives as uppercase env vars matching the
|
||||
// config key, prefixed with `PLUGIN_`. Config from the `environment` block is uppercased, but does
|
||||
// not have the `PLUGIN_` prefix.
|
||||
type Config struct {
|
||||
// Configuration for drone-helm itself
|
||||
Command string `envconfig:"mode"` // Helm command to run
|
||||
DroneEvent string `envconfig:"DRONE_BUILD_EVENT"` // Drone event that invoked this plugin.
|
||||
UpdateDependencies bool `split_words:"true"` // Call `helm dependency update` before the main command
|
||||
AddRepos []string `split_words:"true"` // Call `helm repo add` before the main command
|
||||
Debug bool `` // Generate debug output and pass --debug to all helm commands
|
||||
Values string `` // Argument to pass to --set in applicable helm commands
|
||||
StringValues string `split_words:"true"` // Argument to pass to --set-string in applicable helm commands
|
||||
ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands
|
||||
Namespace string `` // Kubernetes namespace for all helm commands
|
||||
KubeToken string `split_words:"true"` // Kubernetes authentication token to put in .kube/config
|
||||
SkipTLSVerify bool `envconfig:"SKIP_TLS_VERIFY"` // Put insecure-skip-tls-verify in .kube/config
|
||||
Certificate string `envconfig:"kube_certificate"` // The Kubernetes cluster CA's self-signed certificate (must be base64-encoded)
|
||||
APIServer string `envconfig:"kube_api_server"` // The Kubernetes cluster's API endpoint
|
||||
ServiceAccount string `envconfig:"kube_service_account"` // Account to use for connecting to the Kubernetes cluster
|
||||
ChartVersion string `split_words:"true"` // Specific chart version to use in `helm upgrade`
|
||||
DryRun bool `split_words:"true"` // Pass --dry-run to applicable helm commands
|
||||
Wait bool `envconfig:"wait_for_upgrade"` // Pass --wait to applicable helm commands
|
||||
ReuseValues bool `split_words:"true"` // Pass --reuse-values to `helm upgrade`
|
||||
KeepHistory bool `split_words:"true"` // Pass --keep-history to `helm uninstall`
|
||||
Timeout string `` // Argument to pass to --timeout in applicable helm commands
|
||||
Chart string `` // Chart argument to use in applicable helm commands
|
||||
Release string `` // Release argument to use in applicable helm commands
|
||||
Force bool `envconfig:"force_upgrade"` // Pass --force to applicable helm commands
|
||||
AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade`
|
||||
CleanupOnFail bool `envconfig:"CLEANUP_FAILED_UPGRADE"` // Pass --cleanup-on-fail to `helm upgrade`
|
||||
LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint`
|
||||
|
||||
Stdout io.Writer `ignored:"true"`
|
||||
Stderr io.Writer `ignored:"true"`
|
||||
}
|
||||
|
||||
// NewConfig creates a Config and reads environment variables into it, accounting for several possible formats.
|
||||
func NewConfig(stdout, stderr io.Writer) (*Config, error) {
|
||||
var aliases settingAliases
|
||||
if err := envconfig.Process("plugin", &aliases); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := envconfig.Process("", &aliases); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cfg := Config{
|
||||
Command: aliases.Command,
|
||||
AddRepos: aliases.AddRepos,
|
||||
APIServer: aliases.APIServer,
|
||||
ServiceAccount: aliases.ServiceAccount,
|
||||
Wait: aliases.Wait,
|
||||
Force: aliases.Force,
|
||||
KubeToken: aliases.KubeToken,
|
||||
Certificate: aliases.Certificate,
|
||||
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
}
|
||||
if err := envconfig.Process("plugin", &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := envconfig.Process("", &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if justNumbers.MatchString(cfg.Timeout) {
|
||||
cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout)
|
||||
}
|
||||
|
||||
if cfg.Debug && cfg.Stderr != nil {
|
||||
cfg.logDebug()
|
||||
}
|
||||
|
||||
cfg.deprecationWarn()
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func (cfg Config) logDebug() {
|
||||
if cfg.KubeToken != "" {
|
||||
cfg.KubeToken = "(redacted)"
|
||||
}
|
||||
fmt.Fprintf(cfg.Stderr, "Generated config: %+v\n", cfg)
|
||||
}
|
||||
|
||||
func (cfg *Config) deprecationWarn() {
|
||||
for _, varname := range deprecatedVars {
|
||||
_, barePresent := os.LookupEnv(varname)
|
||||
_, prefixedPresent := os.LookupEnv("PLUGIN_" + varname)
|
||||
if barePresent || prefixedPresent {
|
||||
fmt.Fprintf(cfg.Stderr, "Warning: ignoring deprecated '%s' setting\n", strings.ToLower(varname))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type settingAliases struct {
|
||||
Command string `envconfig:"helm_command"`
|
||||
AddRepos []string `envconfig:"helm_repos"`
|
||||
APIServer string `envconfig:"api_server"`
|
||||
ServiceAccount string `split_words:"true"`
|
||||
Wait bool ``
|
||||
Force bool ``
|
||||
KubeToken string `envconfig:"kubernetes_token"`
|
||||
Certificate string `envconfig:"kubernetes_certificate"`
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
package helm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type ConfigTestSuite struct {
|
||||
suite.Suite
|
||||
// These tests need to mutate the environment, so the suite.setenv and .unsetenv functions store the original contents of the
|
||||
// relevant variable in this map. Its use of *string is so they can distinguish between "not set" and "set to empty string"
|
||||
envBackup map[string]*string
|
||||
}
|
||||
|
||||
func TestConfigTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(ConfigTestSuite))
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigWithPluginPrefix() {
|
||||
suite.unsetenv("MODE")
|
||||
suite.unsetenv("UPDATE_DEPENDENCIES")
|
||||
suite.unsetenv("DEBUG")
|
||||
|
||||
suite.setenv("PLUGIN_MODE", "iambic")
|
||||
suite.setenv("PLUGIN_UPDATE_DEPENDENCIES", "true")
|
||||
suite.setenv("PLUGIN_DEBUG", "true")
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.Equal("iambic", cfg.Command)
|
||||
suite.True(cfg.UpdateDependencies)
|
||||
suite.True(cfg.Debug)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigWithNoPrefix() {
|
||||
suite.unsetenv("PLUGIN_MODE")
|
||||
suite.unsetenv("PLUGIN_UPDATE_DEPENDENCIES")
|
||||
suite.unsetenv("PLUGIN_DEBUG")
|
||||
|
||||
suite.setenv("MODE", "iambic")
|
||||
suite.setenv("UPDATE_DEPENDENCIES", "true")
|
||||
suite.setenv("DEBUG", "true")
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.Equal("iambic", cfg.Command)
|
||||
suite.True(cfg.UpdateDependencies)
|
||||
suite.True(cfg.Debug)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigWithConflictingVariables() {
|
||||
suite.setenv("PLUGIN_MODE", "iambic")
|
||||
suite.setenv("MODE", "haiku") // values from the `environment` block override those from `settings`
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.Equal("haiku", cfg.Command)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigInfersNumbersAreSeconds() {
|
||||
suite.setenv("PLUGIN_TIMEOUT", "42")
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
suite.Equal("42s", cfg.Timeout)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigWithAliases() {
|
||||
for _, varname := range []string{
|
||||
"MODE",
|
||||
"ADD_REPOS",
|
||||
"KUBE_API_SERVER",
|
||||
"KUBE_SERVICE_ACCOUNT",
|
||||
"WAIT_FOR_UPGRADE",
|
||||
"FORCE_UPGRADE",
|
||||
"KUBE_TOKEN",
|
||||
"KUBE_CERTIFICATE",
|
||||
} {
|
||||
suite.unsetenv(varname)
|
||||
suite.unsetenv("PLUGIN_" + varname)
|
||||
}
|
||||
suite.setenv("PLUGIN_HELM_COMMAND", "beware the jabberwock")
|
||||
suite.setenv("PLUGIN_HELM_REPOS", "chortle=http://calloo.callay/frabjous/day")
|
||||
suite.setenv("PLUGIN_API_SERVER", "http://tumtum.tree")
|
||||
suite.setenv("PLUGIN_SERVICE_ACCOUNT", "tulgey")
|
||||
suite.setenv("PLUGIN_WAIT", "true")
|
||||
suite.setenv("PLUGIN_FORCE", "true")
|
||||
suite.setenv("PLUGIN_KUBERNETES_TOKEN", "Y29tZSB0byBteSBhcm1z")
|
||||
suite.setenv("PLUGIN_KUBERNETES_CERTIFICATE", "d2l0aCBpdHMgaGVhZA==")
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
suite.Equal("beware the jabberwock", cfg.Command)
|
||||
suite.Equal([]string{"chortle=http://calloo.callay/frabjous/day"}, cfg.AddRepos)
|
||||
suite.Equal("http://tumtum.tree", cfg.APIServer)
|
||||
suite.Equal("tulgey", cfg.ServiceAccount)
|
||||
suite.True(cfg.Wait, "Wait should be aliased")
|
||||
suite.True(cfg.Force, "Force should be aliased")
|
||||
suite.Equal("Y29tZSB0byBteSBhcm1z", cfg.KubeToken, "KubeToken should be aliased")
|
||||
suite.Equal("d2l0aCBpdHMgaGVhZA==", cfg.Certificate, "Certificate should be aliased")
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestAliasedSettingWithoutPluginPrefix() {
|
||||
suite.unsetenv("FORCE_UPGRADE")
|
||||
suite.unsetenv("PLUGIN_FORCE_UPGRADE")
|
||||
suite.unsetenv("PLUGIN_FORCE")
|
||||
suite.setenv("FORCE", "true")
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.Require().NoError(err)
|
||||
suite.True(cfg.Force)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigWithAliasConflicts() {
|
||||
suite.unsetenv("FORCE_UPGRADE")
|
||||
suite.setenv("PLUGIN_FORCE", "true")
|
||||
suite.setenv("PLUGIN_FORCE_UPGRADE", "false") // should override even when set to the zero value
|
||||
|
||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||
suite.NoError(err)
|
||||
suite.False(cfg.Force, "official names should override alias names")
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {
|
||||
stdout := &strings.Builder{}
|
||||
stderr := &strings.Builder{}
|
||||
cfg, err := NewConfig(stdout, stderr)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.Equal(stdout, cfg.Stdout)
|
||||
suite.Equal(stderr, cfg.Stderr)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestDeprecatedSettingWarnings() {
|
||||
for _, varname := range deprecatedVars {
|
||||
suite.setenv(varname, "deprecoat") // environment-block entries should cause warnings
|
||||
}
|
||||
|
||||
suite.unsetenv("PURGE")
|
||||
suite.setenv("PLUGIN_PURGE", "true") // settings-block entries should cause warnings
|
||||
suite.setenv("UPGRADE", "") // entries should cause warnings even when set to empty string
|
||||
|
||||
stderr := &strings.Builder{}
|
||||
_, err := NewConfig(&strings.Builder{}, stderr)
|
||||
suite.NoError(err)
|
||||
|
||||
for _, varname := range deprecatedVars {
|
||||
suite.Contains(stderr.String(), fmt.Sprintf("Warning: ignoring deprecated '%s' setting\n", strings.ToLower(varname)))
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestLogDebug() {
|
||||
suite.setenv("DEBUG", "true")
|
||||
suite.setenv("MODE", "upgrade")
|
||||
|
||||
stderr := strings.Builder{}
|
||||
stdout := strings.Builder{}
|
||||
_, err := NewConfig(&stdout, &stderr)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.Equal("", stdout.String())
|
||||
|
||||
suite.Regexp(`^Generated config: \{Command:upgrade.*\}`, stderr.String())
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) TestLogDebugCensorsKubeToken() {
|
||||
stderr := &strings.Builder{}
|
||||
kubeToken := "I'm shy! Don't put me in your build logs!"
|
||||
cfg := Config{
|
||||
Debug: true,
|
||||
KubeToken: kubeToken,
|
||||
Stderr: stderr,
|
||||
}
|
||||
|
||||
cfg.logDebug()
|
||||
|
||||
suite.Contains(stderr.String(), "KubeToken:(redacted)")
|
||||
suite.Equal(kubeToken, cfg.KubeToken) // The actual config value should be left unchanged
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) setenv(key, val string) {
|
||||
orig, ok := os.LookupEnv(key)
|
||||
if ok {
|
||||
suite.envBackup[key] = &orig
|
||||
} else {
|
||||
suite.envBackup[key] = nil
|
||||
}
|
||||
os.Setenv(key, val)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) unsetenv(key string) {
|
||||
orig, ok := os.LookupEnv(key)
|
||||
if ok {
|
||||
suite.envBackup[key] = &orig
|
||||
} else {
|
||||
suite.envBackup[key] = nil
|
||||
}
|
||||
os.Unsetenv(key)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) BeforeTest(_, _ string) {
|
||||
suite.envBackup = make(map[string]*string)
|
||||
}
|
||||
|
||||
func (suite *ConfigTestSuite) AfterTest(_, _ string) {
|
||||
for key, val := range suite.envBackup {
|
||||
if val == nil {
|
||||
os.Unsetenv(key)
|
||||
} else {
|
||||
os.Setenv(key, *val)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package helm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pelotech/drone-helm3/internal/env"
|
||||
"github.com/pelotech/drone-helm3/internal/run"
|
||||
"os"
|
||||
)
|
||||
@@ -20,12 +21,12 @@ type Step interface {
|
||||
// A Plan is a series of steps to perform.
|
||||
type Plan struct {
|
||||
steps []Step
|
||||
cfg Config
|
||||
cfg env.Config
|
||||
runCfg run.Config
|
||||
}
|
||||
|
||||
// NewPlan makes a plan for running a helm operation.
|
||||
func NewPlan(cfg Config) (*Plan, error) {
|
||||
func NewPlan(cfg env.Config) (*Plan, error) {
|
||||
p := Plan{
|
||||
cfg: cfg,
|
||||
runCfg: run.Config{
|
||||
@@ -54,7 +55,7 @@ func NewPlan(cfg Config) (*Plan, error) {
|
||||
|
||||
// determineSteps is primarily for the tests' convenience: it allows testing the "which stuff should
|
||||
// we do" logic without building a config that meets all the steps' requirements.
|
||||
func determineSteps(cfg Config) *func(Config) []Step {
|
||||
func determineSteps(cfg env.Config) *func(env.Config) []Step {
|
||||
switch cfg.Command {
|
||||
case "upgrade":
|
||||
return &upgrade
|
||||
@@ -91,7 +92,7 @@ func (p *Plan) Execute() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var upgrade = func(cfg Config) []Step {
|
||||
var upgrade = func(cfg env.Config) []Step {
|
||||
steps := initKube(cfg)
|
||||
steps = append(steps, addRepos(cfg)...)
|
||||
if cfg.UpdateDependencies {
|
||||
@@ -116,7 +117,7 @@ var upgrade = func(cfg Config) []Step {
|
||||
return steps
|
||||
}
|
||||
|
||||
var uninstall = func(cfg Config) []Step {
|
||||
var uninstall = func(cfg env.Config) []Step {
|
||||
steps := initKube(cfg)
|
||||
if cfg.UpdateDependencies {
|
||||
steps = append(steps, depUpdate(cfg)...)
|
||||
@@ -130,7 +131,7 @@ var uninstall = func(cfg Config) []Step {
|
||||
return steps
|
||||
}
|
||||
|
||||
var lint = func(cfg Config) []Step {
|
||||
var lint = func(cfg env.Config) []Step {
|
||||
steps := addRepos(cfg)
|
||||
if cfg.UpdateDependencies {
|
||||
steps = append(steps, depUpdate(cfg)...)
|
||||
@@ -146,14 +147,14 @@ var lint = func(cfg Config) []Step {
|
||||
return steps
|
||||
}
|
||||
|
||||
var help = func(cfg Config) []Step {
|
||||
var help = func(cfg env.Config) []Step {
|
||||
help := &run.Help{
|
||||
HelmCommand: cfg.Command,
|
||||
}
|
||||
return []Step{help}
|
||||
}
|
||||
|
||||
func initKube(cfg Config) []Step {
|
||||
func initKube(cfg env.Config) []Step {
|
||||
return []Step{
|
||||
&run.InitKube{
|
||||
SkipTLSVerify: cfg.SkipTLSVerify,
|
||||
@@ -167,7 +168,7 @@ func initKube(cfg Config) []Step {
|
||||
}
|
||||
}
|
||||
|
||||
func addRepos(cfg Config) []Step {
|
||||
func addRepos(cfg env.Config) []Step {
|
||||
steps := make([]Step, 0)
|
||||
for _, repo := range cfg.AddRepos {
|
||||
steps = append(steps, &run.AddRepo{
|
||||
@@ -178,7 +179,7 @@ func addRepos(cfg Config) []Step {
|
||||
return steps
|
||||
}
|
||||
|
||||
func depUpdate(cfg Config) []Step {
|
||||
func depUpdate(cfg env.Config) []Step {
|
||||
return []Step{
|
||||
&run.DepUpdate{
|
||||
Chart: cfg.Chart,
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pelotech/drone-helm3/internal/env"
|
||||
"github.com/pelotech/drone-helm3/internal/run"
|
||||
)
|
||||
|
||||
@@ -25,14 +26,14 @@ func (suite *PlanTestSuite) TestNewPlan() {
|
||||
stepTwo := NewMockStep(ctrl)
|
||||
|
||||
origHelp := help
|
||||
help = func(cfg Config) []Step {
|
||||
help = func(cfg env.Config) []Step {
|
||||
return []Step{stepOne, stepTwo}
|
||||
}
|
||||
defer func() { help = origHelp }()
|
||||
|
||||
stdout := strings.Builder{}
|
||||
stderr := strings.Builder{}
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "help",
|
||||
Debug: false,
|
||||
Namespace: "outer",
|
||||
@@ -65,12 +66,12 @@ func (suite *PlanTestSuite) TestNewPlanAbortsOnError() {
|
||||
stepTwo := NewMockStep(ctrl)
|
||||
|
||||
origHelp := help
|
||||
help = func(cfg Config) []Step {
|
||||
help = func(cfg env.Config) []Step {
|
||||
return []Step{stepOne, stepTwo}
|
||||
}
|
||||
defer func() { help = origHelp }()
|
||||
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "help",
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ func (suite *PlanTestSuite) TestExecuteAbortsOnError() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgrade() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
ChartVersion: "seventeen",
|
||||
DryRun: true,
|
||||
Wait: true,
|
||||
@@ -172,7 +173,7 @@ func (suite *PlanTestSuite) TestUpgrade() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
UpdateDependencies: true,
|
||||
}
|
||||
steps := upgrade(cfg)
|
||||
@@ -182,7 +183,7 @@ func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgradeWithAddRepos() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
AddRepos: []string{
|
||||
"machine=https://github.com/harold_finch/themachine",
|
||||
},
|
||||
@@ -193,7 +194,7 @@ func (suite *PlanTestSuite) TestUpgradeWithAddRepos() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUninstall() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
KubeToken: "b2YgbXkgYWZmZWN0aW9u",
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "cHJvY2xhaW1zIHdvbmRlcmZ1bCBmcmllbmRzaGlw",
|
||||
@@ -233,7 +234,7 @@ func (suite *PlanTestSuite) TestUninstall() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUninstallWithUpdateDependencies() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
UpdateDependencies: true,
|
||||
}
|
||||
steps := uninstall(cfg)
|
||||
@@ -243,7 +244,7 @@ func (suite *PlanTestSuite) TestUninstallWithUpdateDependencies() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestInitKube() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
KubeToken: "cXVlZXIgY2hhcmFjdGVyCg==",
|
||||
SkipTLSVerify: true,
|
||||
Certificate: "b2Ygd29rZW5lc3MK",
|
||||
@@ -269,7 +270,7 @@ func (suite *PlanTestSuite) TestInitKube() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDepUpdate() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
UpdateDependencies: true,
|
||||
Chart: "scatterplot",
|
||||
}
|
||||
@@ -286,7 +287,7 @@ func (suite *PlanTestSuite) TestDepUpdate() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddRepos() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
AddRepos: []string{
|
||||
"first=https://add.repos/one",
|
||||
"second=https://add.repos/two",
|
||||
@@ -304,7 +305,7 @@ func (suite *PlanTestSuite) TestAddRepos() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLint() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Chart: "./flow",
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
@@ -326,7 +327,7 @@ func (suite *PlanTestSuite) TestLint() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLintWithUpdateDependencies() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
UpdateDependencies: true,
|
||||
}
|
||||
steps := lint(cfg)
|
||||
@@ -335,7 +336,7 @@ func (suite *PlanTestSuite) TestLintWithUpdateDependencies() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLintWithAddRepos() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
AddRepos: []string{"friendczar=https://github.com/logan_pierce/friendczar"},
|
||||
}
|
||||
steps := lint(cfg)
|
||||
@@ -344,7 +345,7 @@ func (suite *PlanTestSuite) TestLintWithAddRepos() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanUpgradeCommand() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "upgrade",
|
||||
}
|
||||
stepsMaker := determineSteps(cfg)
|
||||
@@ -352,7 +353,7 @@ func (suite *PlanTestSuite) TestDeterminePlanUpgradeCommand() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanUpgradeFromDroneEvent() {
|
||||
cfg := Config{}
|
||||
cfg := env.Config{}
|
||||
|
||||
upgradeEvents := []string{"push", "tag", "deployment", "pull_request", "promote", "rollback"}
|
||||
for _, event := range upgradeEvents {
|
||||
@@ -363,7 +364,7 @@ func (suite *PlanTestSuite) TestDeterminePlanUpgradeFromDroneEvent() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanUninstallCommand() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "uninstall",
|
||||
}
|
||||
stepsMaker := determineSteps(cfg)
|
||||
@@ -372,7 +373,7 @@ func (suite *PlanTestSuite) TestDeterminePlanUninstallCommand() {
|
||||
|
||||
// helm_command = delete is provided as an alias for backward-compatibility with drone-helm
|
||||
func (suite *PlanTestSuite) TestDeterminePlanDeleteCommand() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "delete",
|
||||
}
|
||||
stepsMaker := determineSteps(cfg)
|
||||
@@ -380,7 +381,7 @@ func (suite *PlanTestSuite) TestDeterminePlanDeleteCommand() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanDeleteFromDroneEvent() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
DroneEvent: "delete",
|
||||
}
|
||||
stepsMaker := determineSteps(cfg)
|
||||
@@ -388,7 +389,7 @@ func (suite *PlanTestSuite) TestDeterminePlanDeleteFromDroneEvent() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanLintCommand() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "lint",
|
||||
}
|
||||
|
||||
@@ -397,7 +398,7 @@ func (suite *PlanTestSuite) TestDeterminePlanLintCommand() {
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanHelpCommand() {
|
||||
cfg := Config{
|
||||
cfg := env.Config{
|
||||
Command: "help",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user