Compare commits
2 Commits
v0.11.0
...
alias-sett
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7892c9c0a6 | ||
|
|
b4b1f7882d |
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := helm.NewConfig(os.Stdout, os.Stderr)
|
cfg, err := helm.NewConfig(os.Stdout, os.Stderr, os.Args...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -5,9 +5,7 @@ go 1.13
|
|||||||
require (
|
require (
|
||||||
github.com/golang/mock v1.3.1
|
github.com/golang/mock v1.3.1
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/kelseyhightower/envconfig v1.4.0
|
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
github.com/urfave/cli/v2 v2.1.1
|
||||||
golang.org/x/tools v0.0.0-20191209225234-22774f7dae43 // indirect
|
|
||||||
gopkg.in/yaml.v2 v2.2.2
|
gopkg.in/yaml.v2 v2.2.2
|
||||||
)
|
)
|
||||||
|
|||||||
21
go.sum
21
go.sum
@@ -1,33 +1,30 @@
|
|||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
|
||||||
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
||||||
|
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE=
|
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg=
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f h1:kDxGY2VmgABOe55qheT/TFqUMtcTHnomIPS1iv3G4Ms=
|
|
||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd h1:Zc7EU2PqpsNeIfOoVA7hvQX4cS3YDJEs5KlfatT3hLo=
|
|
||||||
golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191209225234-22774f7dae43 h1:NfPq5mgc5ArFgVLCpeS4z07IoxSAqVfV/gQ5vxdgaxI=
|
|
||||||
golang.org/x/tools v0.0.0-20191209225234-22774f7dae43/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package helm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/urfave/cli/v2"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -20,67 +20,190 @@ var (
|
|||||||
// not have the `PLUGIN_` prefix.
|
// not have the `PLUGIN_` prefix.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Configuration for drone-helm itself
|
// Configuration for drone-helm itself
|
||||||
Command string `envconfig:"mode"` // Helm command to run
|
Command string // Helm command to run
|
||||||
DroneEvent string `envconfig:"DRONE_BUILD_EVENT"` // Drone event that invoked this plugin.
|
DroneEvent string // Drone event that invoked this plugin.
|
||||||
UpdateDependencies bool `split_words:"true"` // Call `helm dependency update` before the main command
|
UpdateDependencies bool // Call `helm dependency update` before the main command
|
||||||
AddRepos []string `split_words:"true"` // Call `helm repo add` before the main command
|
AddRepos []string // Call `helm repo add` before the main command
|
||||||
Debug bool `` // Generate debug output and pass --debug to all helm commands
|
Debug bool // Generate debug output and pass --debug to all helm commands
|
||||||
Values string `` // Argument to pass to --set in applicable 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
|
StringValues string // Argument to pass to --set-string in applicable helm commands
|
||||||
ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands
|
ValuesFiles []string // Arguments to pass to --values in applicable helm commands
|
||||||
Namespace string `` // Kubernetes namespace for all helm commands
|
Namespace string // Kubernetes namespace for all helm commands
|
||||||
KubeToken string `split_words:"true"` // Kubernetes authentication token to put in .kube/config
|
KubeToken string // Kubernetes authentication token to put in .kube/config
|
||||||
SkipTLSVerify bool `envconfig:"SKIP_TLS_VERIFY"` // Put insecure-skip-tls-verify in .kube/config
|
SkipTLSVerify bool // 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)
|
Certificate string // The Kubernetes cluster CA's self-signed certificate (must be base64-encoded)
|
||||||
APIServer string `envconfig:"kube_api_server"` // The Kubernetes cluster's API endpoint
|
APIServer string // The Kubernetes cluster's API endpoint
|
||||||
ServiceAccount string `envconfig:"kube_service_account"` // Account to use for connecting to the Kubernetes cluster
|
ServiceAccount string // Account to use for connecting to the Kubernetes cluster
|
||||||
ChartVersion string `split_words:"true"` // Specific chart version to use in `helm upgrade`
|
ChartVersion string // Specific chart version to use in `helm upgrade`
|
||||||
DryRun bool `split_words:"true"` // Pass --dry-run to applicable helm commands
|
DryRun bool // Pass --dry-run to applicable helm commands
|
||||||
Wait bool `envconfig:"wait_for_upgrade"` // Pass --wait to applicable helm commands
|
Wait bool // Pass --wait to applicable helm commands
|
||||||
ReuseValues bool `split_words:"true"` // Pass --reuse-values to `helm upgrade`
|
ReuseValues bool // Pass --reuse-values to `helm upgrade`
|
||||||
KeepHistory bool `split_words:"true"` // Pass --keep-history to `helm uninstall`
|
KeepHistory bool // Pass --keep-history to `helm uninstall`
|
||||||
Timeout string `` // Argument to pass to --timeout in applicable helm commands
|
Timeout string // Argument to pass to --timeout in applicable helm commands
|
||||||
Chart string `` // Chart argument to use in applicable helm commands
|
Chart string // Chart argument to use in applicable helm commands
|
||||||
Release string `` // Release 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
|
Force bool // Pass --force to applicable helm commands
|
||||||
AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade`
|
AtomicUpgrade bool // Pass --atomic to `helm upgrade`
|
||||||
CleanupOnFail bool `envconfig:"CLEANUP_FAILED_UPGRADE"` // Pass --cleanup-on-fail to `helm upgrade`
|
CleanupOnFail bool // Pass --cleanup-on-fail to `helm upgrade`
|
||||||
LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint`
|
LintStrictly bool // Pass --strict to `helm lint`
|
||||||
|
|
||||||
Stdout io.Writer `ignored:"true"`
|
Stdout io.Writer
|
||||||
Stderr io.Writer `ignored:"true"`
|
Stderr io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig creates a Config and reads environment variables into it, accounting for several possible formats.
|
// NewConfig creates a Config and reads environment variables into it, accounting for several possible formats.
|
||||||
func NewConfig(stdout, stderr io.Writer) (*Config, error) {
|
func NewConfig(stdout, stderr io.Writer, argv ...string) (*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{
|
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,
|
Stdout: stdout,
|
||||||
Stderr: stderr,
|
Stderr: stderr,
|
||||||
}
|
}
|
||||||
if err := envconfig.Process("plugin", &cfg); err != nil {
|
// cli doesn't support Destination for string slices, so we'll use bare
|
||||||
|
// strings as an intermediate value and split them on commas ourselves.
|
||||||
|
var addRepos, valuesFiles string
|
||||||
|
app := &cli.App{
|
||||||
|
Name: "drone-helm3",
|
||||||
|
Action: func(*cli.Context) error { return nil },
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "mode",
|
||||||
|
Destination: &cfg.Command,
|
||||||
|
EnvVars: []string{"MODE", "PLUGIN_MODE", "HELM_COMMAND", "PLUGIN_HELM_COMMAND"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "drone-event",
|
||||||
|
Destination: &cfg.DroneEvent,
|
||||||
|
EnvVars: []string{"DRONE_BUILD_EVENT"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "update-dependencies",
|
||||||
|
Destination: &cfg.UpdateDependencies,
|
||||||
|
EnvVars: []string{"UPDATE_DEPENDENCIES", "PLUGIN_UPDATE_DEPENDENCIES"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "add-repos",
|
||||||
|
Destination: &addRepos,
|
||||||
|
EnvVars: []string{"ADD_REPOS", "PLUGIN_ADD_REPOS", "HELM_REPOS", "PLUGIN_HELM_REPOS"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "debug",
|
||||||
|
Destination: &cfg.Debug,
|
||||||
|
EnvVars: []string{"DEBUG", "PLUGIN_DEBUG"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "values",
|
||||||
|
Destination: &cfg.Values,
|
||||||
|
EnvVars: []string{"VALUES", "PLUGIN_VALUES"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "string-values",
|
||||||
|
Destination: &cfg.StringValues,
|
||||||
|
EnvVars: []string{"STRING_VALUES", "PLUGIN_STRING_VALUES"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "values-files",
|
||||||
|
Destination: &valuesFiles,
|
||||||
|
EnvVars: []string{"VALUES_FILES", "PLUGIN_VALUES_FILES"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "namespace",
|
||||||
|
Destination: &cfg.Namespace,
|
||||||
|
EnvVars: []string{"NAMESPACE", "PLUGIN_NAMESPACE"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "kube-token",
|
||||||
|
Destination: &cfg.KubeToken,
|
||||||
|
EnvVars: []string{"KUBE_TOKEN", "PLUGIN_KUBE_TOKEN", "KUBERNETES_TOKEN", "PLUGIN_KUBERNETES_TOKEN"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify",
|
||||||
|
Destination: &cfg.SkipTLSVerify,
|
||||||
|
EnvVars: []string{"SKIP_TLS_VERIFY", "PLUGIN_SKIP_TLS_VERIFY"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "kube-certificate",
|
||||||
|
Destination: &cfg.Certificate,
|
||||||
|
EnvVars: []string{"KUBE_CERTIFICATE", "PLUGIN_KUBE_CERTIFICATE", "KUBERNETES_CERTIFICATE", "PLUGIN_KUBERNETES_CERTIFICATE"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "kube-api-server",
|
||||||
|
Destination: &cfg.APIServer,
|
||||||
|
EnvVars: []string{"KUBE_API_SERVER", "PLUGIN_KUBE_API_SERVER", "API_SERVER", "PLUGIN_API_SERVER"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "service-account",
|
||||||
|
Destination: &cfg.ServiceAccount,
|
||||||
|
EnvVars: []string{"KUBE_SERVICE_ACCOUNT", "PLUGIN_KUBE_SERVICE_ACCOUNT", "SERVICE_ACCOUNT", "PLUGIN_SERVICE_ACCOUNT"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "chart-version",
|
||||||
|
Destination: &cfg.ChartVersion,
|
||||||
|
EnvVars: []string{"CHART_VERSION", "PLUGIN_CHART_VERSION"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "dry-run",
|
||||||
|
Destination: &cfg.DryRun,
|
||||||
|
EnvVars: []string{"DRY_RUN", "PLUGIN_DRY_RUN"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "wait-for-upgrade",
|
||||||
|
Destination: &cfg.Wait,
|
||||||
|
EnvVars: []string{"WAIT_FOR_UPGRADE", "PLUGIN_WAIT_FOR_UPGRADE", "WAIT", "PLUGIN_WAIT"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "reuse-values",
|
||||||
|
Destination: &cfg.ReuseValues,
|
||||||
|
EnvVars: []string{"REUSE_VALUES", "PLUGIN_REUSE_VALUES"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "keep-history",
|
||||||
|
Destination: &cfg.KeepHistory,
|
||||||
|
EnvVars: []string{"KEEP_HISTORY", "PLUGIN_KEEP_HISTORY"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "timeout",
|
||||||
|
Destination: &cfg.Timeout,
|
||||||
|
EnvVars: []string{"TIMEOUT", "PLUGIN_TIMEOUT"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "chart",
|
||||||
|
Destination: &cfg.Chart,
|
||||||
|
EnvVars: []string{"CHART", "PLUGIN_CHART"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "release",
|
||||||
|
Destination: &cfg.Release,
|
||||||
|
EnvVars: []string{"RELEASE", "PLUGIN_RELEASE"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "force-upgrade",
|
||||||
|
Destination: &cfg.Force,
|
||||||
|
EnvVars: []string{"FORCE_UPGRADE", "PLUGIN_FORCE_UPGRADE", "FORCE", "PLUGIN_FORCE"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "atomic-upgrade",
|
||||||
|
Destination: &cfg.AtomicUpgrade,
|
||||||
|
EnvVars: []string{"ATOMIC_UPGRADE", "PLUGIN_ATOMIC_UPGRADE"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "cleanup-failed-upgrade",
|
||||||
|
Destination: &cfg.CleanupOnFail,
|
||||||
|
EnvVars: []string{"CLEANUP_FAILED_UPGRADE", "PLUGIN_CLEANUP_FAILED_UPGRADE"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "lint-strictly",
|
||||||
|
Destination: &cfg.LintStrictly,
|
||||||
|
EnvVars: []string{"LINT_STRICTLY", "PLUGIN_LINT_STRICTLY"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if err := app.Run(argv); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if addRepos != "" {
|
||||||
if err := envconfig.Process("", &cfg); err != nil {
|
cfg.AddRepos = strings.Split(addRepos, ",")
|
||||||
return nil, err
|
}
|
||||||
|
if valuesFiles != "" {
|
||||||
|
cfg.ValuesFiles = strings.Split(valuesFiles, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
if justNumbers.MatchString(cfg.Timeout) {
|
if justNumbers.MatchString(cfg.Timeout) {
|
||||||
@@ -112,14 +235,3 @@ func (cfg *Config) deprecationWarn() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,44 +20,236 @@ func TestConfigTestSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ConfigTestSuite) TestNewConfigWithPluginPrefix() {
|
func (suite *ConfigTestSuite) TestNewConfigWithPluginPrefix() {
|
||||||
suite.unsetenv("MODE")
|
stdout := strings.Builder{}
|
||||||
suite.unsetenv("UPDATE_DEPENDENCIES")
|
stderr := strings.Builder{}
|
||||||
suite.unsetenv("DEBUG")
|
for _, varname := range []string{
|
||||||
|
"MODE",
|
||||||
|
"DRONE_BUILD_EVENT",
|
||||||
|
"HELM_COMMAND",
|
||||||
|
"PLUGIN_HELM_COMMAND",
|
||||||
|
"UPDATE_DEPENDENCIES",
|
||||||
|
"ADD_REPOS",
|
||||||
|
"HELM_REPOS",
|
||||||
|
"PLUGIN_HELM_REPOS",
|
||||||
|
"DEBUG",
|
||||||
|
"VALUES",
|
||||||
|
"STRING_VALUES",
|
||||||
|
"VALUES_FILES",
|
||||||
|
"NAMESPACE",
|
||||||
|
"KUBE_TOKEN",
|
||||||
|
"KUBERNETES_TOKEN",
|
||||||
|
"PLUGIN_KUBERNETES_TOKEN",
|
||||||
|
"SKIP_TLS_VERIFY",
|
||||||
|
"KUBE_CERTIFICATE",
|
||||||
|
"KUBERNETES_CERTIFICATE",
|
||||||
|
"PLUGIN_KUBERNETES_CERTIFICATE",
|
||||||
|
"KUBE_API_SERVER",
|
||||||
|
"API_SERVER",
|
||||||
|
"PLUGIN_API_SERVER",
|
||||||
|
"KUBE_SERVICE_ACCOUNT",
|
||||||
|
"SERVICE_ACCOUNT",
|
||||||
|
"PLUGIN_SERVICE_ACCOUNT",
|
||||||
|
"CHART_VERSION",
|
||||||
|
"DRY_RUN",
|
||||||
|
"WAIT_FOR_UPGRADE",
|
||||||
|
"WAIT",
|
||||||
|
"PLUGIN_WAIT",
|
||||||
|
"REUSE_VALUES",
|
||||||
|
"KEEP_HISTORY",
|
||||||
|
"TIMEOUT",
|
||||||
|
"CHART",
|
||||||
|
"RELEASE",
|
||||||
|
"FORCE",
|
||||||
|
"FORCE_UPGRADE",
|
||||||
|
"PLUGIN_FORCE_UPGRADE",
|
||||||
|
"ATOMIC_UPGRADE",
|
||||||
|
"CLEANUP_FAILED_UPGRADE",
|
||||||
|
"LINT_STRICTLY",
|
||||||
|
} {
|
||||||
|
suite.unsetenv(varname)
|
||||||
|
}
|
||||||
|
|
||||||
suite.setenv("PLUGIN_MODE", "iambic")
|
suite.setenv("PLUGIN_MODE", "upgrade")
|
||||||
suite.setenv("PLUGIN_UPDATE_DEPENDENCIES", "true")
|
suite.setenv("PLUGIN_UPDATE_DEPENDENCIES", "true")
|
||||||
|
suite.setenv("PLUGIN_ADD_REPOS", "foo=http://bar,goo=http://baz")
|
||||||
suite.setenv("PLUGIN_DEBUG", "true")
|
suite.setenv("PLUGIN_DEBUG", "true")
|
||||||
|
suite.setenv("PLUGIN_VALUES", "dog=husky")
|
||||||
|
suite.setenv("PLUGIN_STRING_VALUES", "version=1.0")
|
||||||
|
suite.setenv("PLUGIN_VALUES_FILES", "underrides.yml,overrides.yml")
|
||||||
|
suite.setenv("PLUGIN_NAMESPACE", "myapp")
|
||||||
|
suite.setenv("PLUGIN_KUBE_TOKEN", "cGxlYXNlIHNpciwgbGV0IG1lIGlu")
|
||||||
|
suite.setenv("PLUGIN_SKIP_TLS_VERIFY", "true")
|
||||||
|
suite.setenv("PLUGIN_KUBE_CERTIFICATE", "SSBhbSB0b3RhbGx5IHRoZSBzZXJ2ZXIgeW91IHdhbnQ=")
|
||||||
|
suite.setenv("PLUGIN_KUBE_API_SERVER", "http://my.kube/cluster")
|
||||||
|
suite.setenv("PLUGIN_KUBE_SERVICE_ACCOUNT", "deploybot")
|
||||||
|
suite.setenv("PLUGIN_CHART_VERSION", "six")
|
||||||
|
suite.setenv("PLUGIN_DRY_RUN", "true")
|
||||||
|
suite.setenv("PLUGIN_WAIT_FOR_UPGRADE", "true")
|
||||||
|
suite.setenv("PLUGIN_REUSE_VALUES", "true")
|
||||||
|
suite.setenv("PLUGIN_KEEP_HISTORY", "true")
|
||||||
|
suite.setenv("PLUGIN_TIMEOUT", "5m20s")
|
||||||
|
suite.setenv("PLUGIN_CHART", "./helm/myapp/")
|
||||||
|
suite.setenv("PLUGIN_RELEASE", "my_app")
|
||||||
|
suite.setenv("PLUGIN_FORCE_UPGRADE", "true")
|
||||||
|
suite.setenv("PLUGIN_ATOMIC_UPGRADE", "true")
|
||||||
|
suite.setenv("PLUGIN_CLEANUP_FAILED_UPGRADE", "true")
|
||||||
|
suite.setenv("PLUGIN_LINT_STRICTLY", "true")
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&stdout, &stderr, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Equal("iambic", cfg.Command)
|
want := Config{
|
||||||
suite.True(cfg.UpdateDependencies)
|
Command: "upgrade",
|
||||||
suite.True(cfg.Debug)
|
DroneEvent: "",
|
||||||
|
UpdateDependencies: true,
|
||||||
|
AddRepos: []string{"foo=http://bar", "goo=http://baz"},
|
||||||
|
Debug: true,
|
||||||
|
Values: "dog=husky",
|
||||||
|
StringValues: "version=1.0",
|
||||||
|
ValuesFiles: []string{"underrides.yml", "overrides.yml"},
|
||||||
|
Namespace: "myapp",
|
||||||
|
KubeToken: "cGxlYXNlIHNpciwgbGV0IG1lIGlu",
|
||||||
|
SkipTLSVerify: true,
|
||||||
|
Certificate: "SSBhbSB0b3RhbGx5IHRoZSBzZXJ2ZXIgeW91IHdhbnQ=",
|
||||||
|
APIServer: "http://my.kube/cluster",
|
||||||
|
ServiceAccount: "deploybot",
|
||||||
|
ChartVersion: "six",
|
||||||
|
DryRun: true,
|
||||||
|
Wait: true,
|
||||||
|
ReuseValues: true,
|
||||||
|
KeepHistory: true,
|
||||||
|
Timeout: "5m20s",
|
||||||
|
Chart: "./helm/myapp/",
|
||||||
|
Release: "my_app",
|
||||||
|
Force: true,
|
||||||
|
AtomicUpgrade: true,
|
||||||
|
CleanupOnFail: true,
|
||||||
|
LintStrictly: true,
|
||||||
|
Stdout: &stdout,
|
||||||
|
Stderr: &stderr,
|
||||||
|
}
|
||||||
|
|
||||||
|
suite.Equal(&want, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ConfigTestSuite) TestNewConfigWithNoPrefix() {
|
func (suite *ConfigTestSuite) TestNewConfigWithNoPrefix() {
|
||||||
suite.unsetenv("PLUGIN_MODE")
|
stdout := strings.Builder{}
|
||||||
suite.unsetenv("PLUGIN_UPDATE_DEPENDENCIES")
|
stderr := strings.Builder{}
|
||||||
suite.unsetenv("PLUGIN_DEBUG")
|
for _, varname := range []string{
|
||||||
|
"PLUGIN_MODE",
|
||||||
|
"PLUGIN_HELM_COMMAND",
|
||||||
|
"HELM_COMMAND",
|
||||||
|
"PLUGIN_UPDATE_DEPENDENCIES",
|
||||||
|
"PLUGIN_ADD_REPOS",
|
||||||
|
"PLUGIN_HELM_REPOS",
|
||||||
|
"HELM_REPOS",
|
||||||
|
"PLUGIN_DEBUG",
|
||||||
|
"PLUGIN_VALUES",
|
||||||
|
"PLUGIN_STRING_VALUES",
|
||||||
|
"PLUGIN_VALUES_FILES",
|
||||||
|
"PLUGIN_NAMESPACE",
|
||||||
|
"PLUGIN_KUBE_TOKEN",
|
||||||
|
"PLUGIN_KUBERNETES_TOKEN",
|
||||||
|
"KUBERNETES_TOKEN",
|
||||||
|
"PLUGIN_SKIP_TLS_VERIFY",
|
||||||
|
"PLUGIN_KUBE_CERTIFICATE",
|
||||||
|
"PLUGIN_KUBERNETES_CERTIFICATE",
|
||||||
|
"KUBERNETES_CERTIFICATE",
|
||||||
|
"PLUGIN_KUBE_API_SERVER",
|
||||||
|
"PLUGIN_API_SERVER",
|
||||||
|
"API_SERVER",
|
||||||
|
"PLUGIN_KUBE_SERVICE_ACCOUNT",
|
||||||
|
"PLUGIN_SERVICE_ACCOUNT",
|
||||||
|
"SERVICE_ACCOUNT",
|
||||||
|
"PLUGIN_CHART_VERSION",
|
||||||
|
"PLUGIN_DRY_RUN",
|
||||||
|
"PLUGIN_WAIT_FOR_UPGRADE",
|
||||||
|
"PLUGIN_WAIT",
|
||||||
|
"WAIT",
|
||||||
|
"PLUGIN_REUSE_VALUES",
|
||||||
|
"PLUGIN_KEEP_HISTORY",
|
||||||
|
"PLUGIN_TIMEOUT",
|
||||||
|
"PLUGIN_CHART",
|
||||||
|
"PLUGIN_RELEASE",
|
||||||
|
"PLUGIN_FORCE",
|
||||||
|
"PLUGIN_FORCE_UPGRADE",
|
||||||
|
"FORCE_UPGRADE",
|
||||||
|
"PLUGIN_ATOMIC_UPGRADE",
|
||||||
|
"PLUGIN_CLEANUP_FAILED_UPGRADE",
|
||||||
|
"PLUGIN_LINT_STRICTLY",
|
||||||
|
} {
|
||||||
|
suite.unsetenv(varname)
|
||||||
|
}
|
||||||
|
|
||||||
suite.setenv("MODE", "iambic")
|
suite.setenv("MODE", "upgrade")
|
||||||
|
suite.setenv("DRONE_BUILD_EVENT", "tag")
|
||||||
suite.setenv("UPDATE_DEPENDENCIES", "true")
|
suite.setenv("UPDATE_DEPENDENCIES", "true")
|
||||||
|
suite.setenv("ADD_REPOS", "foo=http://bar,goo=http://baz")
|
||||||
suite.setenv("DEBUG", "true")
|
suite.setenv("DEBUG", "true")
|
||||||
|
suite.setenv("VALUES", "dog=husky")
|
||||||
|
suite.setenv("STRING_VALUES", "version=1.0")
|
||||||
|
suite.setenv("VALUES_FILES", "underrides.yml,overrides.yml")
|
||||||
|
suite.setenv("NAMESPACE", "myapp")
|
||||||
|
suite.setenv("KUBE_TOKEN", "cGxlYXNlIHNpciwgbGV0IG1lIGlu")
|
||||||
|
suite.setenv("SKIP_TLS_VERIFY", "true")
|
||||||
|
suite.setenv("KUBE_CERTIFICATE", "SSBhbSB0b3RhbGx5IHRoZSBzZXJ2ZXIgeW91IHdhbnQ=")
|
||||||
|
suite.setenv("KUBE_API_SERVER", "http://my.kube/cluster")
|
||||||
|
suite.setenv("KUBE_SERVICE_ACCOUNT", "deploybot")
|
||||||
|
suite.setenv("CHART_VERSION", "six")
|
||||||
|
suite.setenv("DRY_RUN", "true")
|
||||||
|
suite.setenv("WAIT_FOR_UPGRADE", "true")
|
||||||
|
suite.setenv("REUSE_VALUES", "true")
|
||||||
|
suite.setenv("KEEP_HISTORY", "true")
|
||||||
|
suite.setenv("TIMEOUT", "5m20s")
|
||||||
|
suite.setenv("CHART", "./helm/myapp/")
|
||||||
|
suite.setenv("RELEASE", "my_app")
|
||||||
|
suite.setenv("FORCE_UPGRADE", "true")
|
||||||
|
suite.setenv("ATOMIC_UPGRADE", "true")
|
||||||
|
suite.setenv("CLEANUP_FAILED_UPGRADE", "true")
|
||||||
|
suite.setenv("LINT_STRICTLY", "true")
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&stdout, &stderr, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Equal("iambic", cfg.Command)
|
want := Config{
|
||||||
suite.True(cfg.UpdateDependencies)
|
Command: "upgrade",
|
||||||
suite.True(cfg.Debug)
|
DroneEvent: "tag",
|
||||||
|
UpdateDependencies: true,
|
||||||
|
AddRepos: []string{"foo=http://bar", "goo=http://baz"},
|
||||||
|
Debug: true,
|
||||||
|
Values: "dog=husky",
|
||||||
|
StringValues: "version=1.0",
|
||||||
|
ValuesFiles: []string{"underrides.yml", "overrides.yml"},
|
||||||
|
Namespace: "myapp",
|
||||||
|
KubeToken: "cGxlYXNlIHNpciwgbGV0IG1lIGlu",
|
||||||
|
SkipTLSVerify: true,
|
||||||
|
Certificate: "SSBhbSB0b3RhbGx5IHRoZSBzZXJ2ZXIgeW91IHdhbnQ=",
|
||||||
|
APIServer: "http://my.kube/cluster",
|
||||||
|
ServiceAccount: "deploybot",
|
||||||
|
ChartVersion: "six",
|
||||||
|
DryRun: true,
|
||||||
|
Wait: true,
|
||||||
|
ReuseValues: true,
|
||||||
|
KeepHistory: true,
|
||||||
|
Timeout: "5m20s",
|
||||||
|
Chart: "./helm/myapp/",
|
||||||
|
Release: "my_app",
|
||||||
|
Force: true,
|
||||||
|
AtomicUpgrade: true,
|
||||||
|
CleanupOnFail: true,
|
||||||
|
LintStrictly: true,
|
||||||
|
Stdout: &stdout,
|
||||||
|
Stderr: &stderr,
|
||||||
|
}
|
||||||
|
|
||||||
|
suite.Equal(&want, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ConfigTestSuite) TestNewConfigWithConflictingVariables() {
|
func (suite *ConfigTestSuite) TestNewConfigWithConflictingVariables() {
|
||||||
suite.setenv("PLUGIN_MODE", "iambic")
|
suite.setenv("PLUGIN_MODE", "iambic")
|
||||||
suite.setenv("MODE", "haiku") // values from the `environment` block override those from `settings`
|
suite.setenv("MODE", "haiku") // values from the `environment` block override those from `settings`
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Equal("haiku", cfg.Command)
|
suite.Equal("haiku", cfg.Command)
|
||||||
@@ -65,7 +257,7 @@ func (suite *ConfigTestSuite) TestNewConfigWithConflictingVariables() {
|
|||||||
|
|
||||||
func (suite *ConfigTestSuite) TestNewConfigInfersNumbersAreSeconds() {
|
func (suite *ConfigTestSuite) TestNewConfigInfersNumbersAreSeconds() {
|
||||||
suite.setenv("PLUGIN_TIMEOUT", "42")
|
suite.setenv("PLUGIN_TIMEOUT", "42")
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.Equal("42s", cfg.Timeout)
|
suite.Equal("42s", cfg.Timeout)
|
||||||
}
|
}
|
||||||
@@ -93,7 +285,7 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() {
|
|||||||
suite.setenv("PLUGIN_KUBERNETES_TOKEN", "Y29tZSB0byBteSBhcm1z")
|
suite.setenv("PLUGIN_KUBERNETES_TOKEN", "Y29tZSB0byBteSBhcm1z")
|
||||||
suite.setenv("PLUGIN_KUBERNETES_CERTIFICATE", "d2l0aCBpdHMgaGVhZA==")
|
suite.setenv("PLUGIN_KUBERNETES_CERTIFICATE", "d2l0aCBpdHMgaGVhZA==")
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.Equal("beware the jabberwock", cfg.Command)
|
suite.Equal("beware the jabberwock", cfg.Command)
|
||||||
suite.Equal([]string{"chortle=http://calloo.callay/frabjous/day"}, cfg.AddRepos)
|
suite.Equal([]string{"chortle=http://calloo.callay/frabjous/day"}, cfg.AddRepos)
|
||||||
@@ -111,7 +303,7 @@ func (suite *ConfigTestSuite) TestAliasedSettingWithoutPluginPrefix() {
|
|||||||
suite.unsetenv("PLUGIN_FORCE")
|
suite.unsetenv("PLUGIN_FORCE")
|
||||||
suite.setenv("FORCE", "true")
|
suite.setenv("FORCE", "true")
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.True(cfg.Force)
|
suite.True(cfg.Force)
|
||||||
}
|
}
|
||||||
@@ -121,7 +313,7 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliasConflicts() {
|
|||||||
suite.setenv("PLUGIN_FORCE", "true")
|
suite.setenv("PLUGIN_FORCE", "true")
|
||||||
suite.setenv("PLUGIN_FORCE_UPGRADE", "false") // should override even when set to the zero value
|
suite.setenv("PLUGIN_FORCE_UPGRADE", "false") // should override even when set to the zero value
|
||||||
|
|
||||||
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}, "test")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.False(cfg.Force, "official names should override alias names")
|
suite.False(cfg.Force, "official names should override alias names")
|
||||||
}
|
}
|
||||||
@@ -129,7 +321,7 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliasConflicts() {
|
|||||||
func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {
|
func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {
|
||||||
stdout := &strings.Builder{}
|
stdout := &strings.Builder{}
|
||||||
stderr := &strings.Builder{}
|
stderr := &strings.Builder{}
|
||||||
cfg, err := NewConfig(stdout, stderr)
|
cfg, err := NewConfig(stdout, stderr, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Equal(stdout, cfg.Stdout)
|
suite.Equal(stdout, cfg.Stdout)
|
||||||
@@ -146,7 +338,7 @@ func (suite *ConfigTestSuite) TestDeprecatedSettingWarnings() {
|
|||||||
suite.setenv("UPGRADE", "") // entries should cause warnings even when set to empty string
|
suite.setenv("UPGRADE", "") // entries should cause warnings even when set to empty string
|
||||||
|
|
||||||
stderr := &strings.Builder{}
|
stderr := &strings.Builder{}
|
||||||
_, err := NewConfig(&strings.Builder{}, stderr)
|
_, err := NewConfig(&strings.Builder{}, stderr, "test")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
for _, varname := range deprecatedVars {
|
for _, varname := range deprecatedVars {
|
||||||
@@ -160,7 +352,7 @@ func (suite *ConfigTestSuite) TestLogDebug() {
|
|||||||
|
|
||||||
stderr := strings.Builder{}
|
stderr := strings.Builder{}
|
||||||
stdout := strings.Builder{}
|
stdout := strings.Builder{}
|
||||||
_, err := NewConfig(&stdout, &stderr)
|
_, err := NewConfig(&stdout, &stderr, "test")
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Equal("", stdout.String())
|
suite.Equal("", stdout.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user