Skip to content

Commit fd1fcf9

Browse files
committed
Add flag --fail-on-error to zypp-plugin-mode
Currently container-suseconnect will fail with exit code 1 if it is not able to obtain the SLE credentials. This is however causing UX issues in the SLE BCI containers, which are perfectly fine without a SLE subscription. Thus a new flag is introduced just for the mode when running as the zypper plugin: `--fail-on-error`. When this flag is set or if the environment variable `CONTAINER_SUSECONNECT_FAIL_ON_ERR` is set, then `container-suseconnect` will fail as it did so far, but the default is now that errors will be silently swallowed so that users of SLE BCI don't get confused by this error message.
1 parent b14a914 commit fd1fcf9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/container-suseconnect/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func main() {
5757
case "container-suseconnect-zypp":
5858
app.Action = runZypperPlugin
5959
defaultUsageAdditionZypp = " (default)"
60+
app.Flags = []cli.Flag{
61+
&cli.BoolFlag{
62+
Name: "fail-on-error",
63+
Usage: "Fail when an error occurs",
64+
EnvVars: []string{"CONTAINER_SUSECONNECT_FAIL_ON_ERR"},
65+
},
66+
}
67+
6068
case "susecloud":
6169
app.Action = runZypperURLResolver
6270
defaultUsageAdditionZypp = " (default)"
@@ -165,11 +173,11 @@ func runZypperURLResolver(_ *cli.Context) error {
165173
// all available repositories for the installed product. Additional modules
166174
// can be specified via the `ADDITIONAL_MODULES` environment variable, which
167175
// reflect the module `identifier`.
168-
func runZypperPlugin(_ *cli.Context) error {
176+
func runZypperPlugin(ctx *cli.Context) error {
169177
log.SetOutput(cs.GetLoggerFile())
170178

171179
products, err := requestProducts()
172-
if err != nil {
180+
if ctx.Bool("fail-on-error") && err != nil {
173181
return err
174182
}
175183

0 commit comments

Comments
 (0)