From 4ae4474734eb9f043e4d905d27a798a0d480edfa Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 5 Feb 2024 21:50:41 +0100 Subject: [PATCH] fix duplicate flag name --- cmd/wp-opentofu/flags.go | 6 +++--- plugin/impl.go | 12 ++++++------ plugin/plugin.go | 2 +- plugin/utils.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/wp-opentofu/flags.go b/cmd/wp-opentofu/flags.go index 1dc6ce8..2ed8012 100644 --- a/cmd/wp-opentofu/flags.go +++ b/cmd/wp-opentofu/flags.go @@ -58,10 +58,10 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Category: category, }, &cli.StringFlag{ - Name: "version", + Name: "tofu-version", Usage: "tofu version to use", - EnvVars: []string{"PLUGIN_VERSION"}, - Destination: &settings.Version, + EnvVars: []string{"PLUGIN_TOFU_VERSION"}, + Destination: &settings.TofuVersion, Category: category, }, &cli.BoolFlag{ diff --git a/plugin/impl.go b/plugin/impl.go index fac0175..5766bae 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -11,10 +11,10 @@ import ( ) var ( - ErrTaintedPath = errors.New("filepath is tainted") - ErrMaxSizeSizeLimit = errors.New("max size limit of decoded data exceeded") - ErrActionUnknown = errors.New("action not found") - ErrInvalidVersion = errors.New("invalid version string") + ErrTaintedPath = errors.New("filepath is tainted") + ErrMaxSizeSizeLimit = errors.New("max size limit of decoded data exceeded") + ErrActionUnknown = errors.New("action not found") + ErrInvalidTofuVersion = errors.New("invalid version string") ) const ( @@ -47,8 +47,8 @@ func (p *Plugin) Validate() error { p.Settings.OutFile = fmt.Sprintf("%s.plan.tfout", p.Settings.DataDir) } - if p.Settings.Version != "" { - err := installPackage(p.Plugin.Network.Context, p.Plugin.Network.Client, p.Settings.Version, maxDecompressionSize) + if p.Settings.TofuVersion != "" { + err := installPackage(p.Plugin.Network.Context, p.Plugin.Network.Client, p.Settings.TofuVersion, maxDecompressionSize) if err != nil { return err } diff --git a/plugin/plugin.go b/plugin/plugin.go index d1b5a09..7ffca69 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -15,7 +15,7 @@ type Plugin struct { type Settings struct { Action cli.StringSlice - Version string + TofuVersion string InitOptions InitOptions FmtOptions FmtOptions diff --git a/plugin/utils.go b/plugin/utils.go index 8e8773c..7252562 100644 --- a/plugin/utils.go +++ b/plugin/utils.go @@ -16,7 +16,7 @@ import ( func installPackage(ctx context.Context, client *http.Client, version string, maxSize int64) error { // Sanitize user input if _, err := semver.NewVersion(version); err != nil { - return fmt.Errorf("%w: %v", ErrInvalidVersion, version) + return fmt.Errorf("%w: %v", ErrInvalidTofuVersion, version) } err := downloadPackage(