✨ cmd: Allow new scorecard to be instantiated with options #1703
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
(Is it a bug fix, feature, docs update, something else?)
One part feature, one part bug fix?
PR title follows the guidelines defined in our pull request documentation
cmd: Allow new scorecard commands to be instantiated with options
options: Default flags to struct field values
options: Use constants for flag names
options: Simplify SARIF check
Signed-off-by: Stephen Augustus [email protected]
What is the current behavior?
With #1696, we enabled the ability to import the scorecard cobra command to support use cases like ossf/scorecard-action#122.
Unfortunately, because of the way we're currently handling defaulting for the flags, it means any initialization of the scorecard options gets discarded in favor of the flag defaults.
Where this comes up is when we attempt to build an options set via environment variables.
What is the new behavior (if this is a feature change)?**
First off, we allow the scorecard command to be initialized with options, which means a downstream consumer can now choose the way they build the options (ideally with
o := options.New()
+ additional logic).After that, we change how the flags default.
Instead of defaulting to empty values, we now use whatever value was initially set within
Options
.BEFORE:
AFTER:
Which issue(s) this PR fixes
Special notes for your reviewer
h/t to @n3wscott for rubber-ducking with me!
Does this PR introduce a user-facing change?
For user-facing changes, please add a concise, human-readable release note to
the
release-note
(In particular, describe what changes users might need to make in their
application as a result of this pull request.)