Skip to content

Flag logic does prevents marking flags as mutually exclusive #728

@Doom4535

Description

@Doom4535

The current usage of the cobra library prevents the proper marking of flags; currently most of this sort of logic is duplicated inside of the pkg/cli/flagValues.go code implementing flagHelper (instead of using the methods provided by cobra). This is most noticeable when trying to set mutually exclusive flags, as the bundled flagHelper doesn't provide a method of implementing this.

For example:

./otdfctl --host https://platform.opentdf.local:8443 --tls-no-verify --log-level debug --with-client-creds '{"clientId":"opentdf","clientSecret":"secret"}' --json policy obligations get --id=3c51a593-cbf8-419d-b7dc-b656d0bedfbb --fqn=https://namespace.com/obl/drm

Currently returns:

   ERROR    Failed to find obligation (id: 3c51a593-cbf8-419d-b7dc-b656d0bedfbb): not_found: resource not found

Instead of throwing triggering a cobra error for an invalid flag combination (triggered/configured by the code here):

cmd.MarkFlagsOneRequired("id", "fqn")
cmd.MarkFlagsMutuallyExclusive("id", "fqn")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions