Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

CLI: Required Flags are not validated before PreRunE is called. #2729

@agrimmer

Description

@agrimmer

The CLI framework Cobra does not validate flags that are marked as required before the function PreRunE is called.
This is a known issue spf13/cobra#655 and this behavior change has not been merged since 2018 spf13/cobra#700.

However, the Keptn CLI assumes in some commands that the flags are already validated when PreRunE is called.

For example, keptn onboard service has --project and --chart as required flags. Furthermore, in the PreRunE function of the onboard service command checks are executed for validating the provided chart.
If now a user executes keptn onboard service carts without specifying a chart, the user gets the error message Error: Provided Helm chart does not exist.
The correct error message would however be Error: required flag(s) "project", "chart" not set.

Tasks:

  • Investigate all CLI commands whether PreRunE uses a required flag. If so and if possible, move the functionality of PreRunE into RunE

Metadata

Metadata

Assignees

Labels

area:clitype:bugSomething is not working as intended/documented

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions