Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 3518f0e

Browse files
authored
Merge pull request #615 from rumpl/remove-strict-flag
Remove the strict flag
2 parents 621d08b + cef9f76 commit 3518f0e

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

internal/commands/cnab.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
369369
if err := mergeBundleParameters(installation,
370370
withFileParameters(paramsOpts.parametersFiles),
371371
withCommandLineParameters(paramsOpts.overrides),
372-
withStrictMode(paramsOpts.strictMode),
373372
); err != nil {
374373
return nil, nil, nil, err
375374
}

internal/commands/install.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func runInstall(dockerCli command.Cli, appname string, opts installOptions) erro
118118
withCommandLineParameters(opts.overrides),
119119
withOrchestratorParameters(opts.orchestrator, opts.kubeNamespace),
120120
withSendRegistryAuth(opts.sendRegistryAuth),
121-
withStrictMode(opts.strictMode),
122121
); err != nil {
123122
return err
124123
}

internal/commands/parameters.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import (
1515
)
1616

1717
type mergeBundleConfig struct {
18-
bundle *bundle.Bundle
19-
params map[string]string
20-
strictMode bool
21-
stderr io.Writer
18+
bundle *bundle.Bundle
19+
params map[string]string
20+
stderr io.Writer
2221
}
2322

2423
type mergeBundleOpt func(c *mergeBundleConfig) error
@@ -78,12 +77,6 @@ func withErrorWriter(w io.Writer) mergeBundleOpt {
7877
}
7978
}
8079

81-
func withStrictMode(strict bool) mergeBundleOpt {
82-
return func(c *mergeBundleConfig) error {
83-
c.strictMode = strict
84-
return nil
85-
}
86-
}
8780
func mergeBundleParameters(installation *store.Installation, ops ...mergeBundleOpt) error {
8881
bndl := installation.Bundle
8982
if installation.Parameters == nil {
@@ -116,9 +109,6 @@ func matchAndMergeParametersDefinition(currentValues map[string]interface{}, cfg
116109
for k, v := range cfg.params {
117110
param, ok := cfg.bundle.Parameters[k]
118111
if !ok {
119-
if cfg.strictMode {
120-
return nil, fmt.Errorf("parameter %q is not defined in the bundle", k)
121-
}
122112
fmt.Fprintf(cfg.stderr, "Warning: parameter %q is not defined in the bundle\n", k)
123113
continue
124114
}

internal/commands/parameters_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,21 @@ func TestMergeBundleParameters(t *testing.T) {
225225
assert.Assert(t, strings.Contains(buf.String(), "is not defined in the bundle"))
226226
})
227227

228-
t.Run("Undefined parameter with strict mode is rejected", func(t *testing.T) {
228+
t.Run("Warn on undefined parameter", func(t *testing.T) {
229229
withUndefined := func(c *mergeBundleConfig) error {
230230
c.params["param"] = "1"
231231
return nil
232232
}
233+
w := bytes.NewBuffer(nil)
234+
withStdErr := func(c *mergeBundleConfig) error {
235+
c.stderr = w
236+
return nil
237+
}
233238
bundle := prepareBundle()
234239
i := &store.Installation{Claim: claim.Claim{Bundle: bundle}}
235-
err := mergeBundleParameters(i, withUndefined, withStrictMode(true))
236-
assert.ErrorContains(t, err, "is not defined in the bundle")
240+
err := mergeBundleParameters(i, withUndefined, withStdErr)
241+
assert.NilError(t, err)
242+
assert.Equal(t, w.String(), "Warning: parameter \"param\" is not defined in the bundle\n")
237243
})
238244

239245
t.Run("Invalid type is rejected", func(t *testing.T) {

internal/commands/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ func prepareBundleStore() (store.BundleStore, error) {
117117
type parametersOptions struct {
118118
parametersFiles []string
119119
overrides []string
120-
strictMode bool
121120
}
122121

123122
func (o *parametersOptions) addFlags(flags *pflag.FlagSet) {
124123
flags.StringArrayVar(&o.parametersFiles, "parameters-file", []string{}, "Override parameters file")
125124
flags.StringArrayVarP(&o.overrides, "set", "s", []string{}, "Override parameter value")
126-
flags.BoolVar(&o.strictMode, "strict", false, "Fail when a paramater is undefined instead of displaying a warning")
127125
}
128126

129127
type credentialOptions struct {

internal/commands/upgrade.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func runUpgrade(dockerCli command.Cli, installationName string, opts upgradeOpti
6767
withFileParameters(opts.parametersFiles),
6868
withCommandLineParameters(opts.overrides),
6969
withSendRegistryAuth(opts.sendRegistryAuth),
70-
withStrictMode(opts.strictMode),
7170
); err != nil {
7271
return err
7372
}

0 commit comments

Comments
 (0)