Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update --preflight command line option #894

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Mar 4, 2024

Fix #893

The --preflight command line options now only specifies those preflight checks that are to be enables.

What this PR does / why we need it:

This simplifies the command line --preflight option; we're looking to have additional configuration located in a configuration file, rather than on the command line.

Which issue(s) this PR fixes:

Fixes #893

Does this PR introduce a user-facing change?

Update --preflight flag to be a simple list of preflight validators to enable.

Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


// Returns an error if there is a problem
// parsing the preflight checks
func (c *Registry) Set(s string) error {
if c.known == nil {
return nil
}

enabled := map[string]struct{}{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non blocking, but using the sets package would make it so this can be a new sets.Set instead of doing this map[string]struct{}{} setup. Then you can do things like sets.Insert(enabled, "key") and enabled.Has("key")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case it was a temporary storage, avoid disabling everything, then enabling only things we cared about. We don't actually care about the the value, just which one's have been enabled.
I suppose, if a Set were used, we could set the Set to disabled, then run through the passed in commands, and go through the Set and enable/disable...

There are so many ways to do this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sets.Set is used exactly for the purpose of only caring about a key without the value. It's a generic map to an empty struct:

type Set[T comparable] map[T]Empty

Again, non-blocking because like you said there are many ways to do this but this is a nice helper for this that is in the kube apimachinery package :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[thought] Would have been our first use of generics 😆 , but nothing to add on here. Sounds good to me either way!

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a non-blocking nit this looks good to me. Probably will need to also update the e2e tests

@tmshort
Copy link
Contributor Author

tmshort commented Mar 4, 2024

Other than a non-blocking nit this looks good to me. Probably will need to also update the e2e tests

I was looking at your original PR, and somehow missed you had updated e2e... I thought my local e2e failures were due to my environment... will update.

Fix carvel-dev#893

The `--preflight` command line options now only specifies those preflight
checks that are to be enables.

Signed-off-by: Todd Short <[email protected]>
@tmshort
Copy link
Contributor Author

tmshort commented Mar 4, 2024

Doc PR: carvel-dev/carvel#733

Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me!

I am a bit worried that we might end up in a weird spot if we do want some of these to be enabled by default in the future. But it is something we can revisit when that is the case 🙌🏼

@100mik
Copy link
Contributor

100mik commented Mar 5, 2024

@everettraven I am curious about how the flag would affect the proposed way of configuring preflights here, but we can discuss that further in the proposal itself

@tmshort
Copy link
Contributor Author

tmshort commented Mar 5, 2024

@everettraven I am curious about how the flag would affect the proposed way of configuring preflights here, but we can discuss that further in the proposal itself

We decided to move preflight configuration into the configuration file (rather than be part of the command line flags). That PR should be updated now to reflect that.

@tmshort
Copy link
Contributor Author

tmshort commented Mar 6, 2024

ping for approval?

Copy link
Contributor

@rashmigottipati rashmigottipati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall, the changes look good to me!

@100mik
Copy link
Contributor

100mik commented Mar 6, 2024

@praveenrewar merge away if this looks good to you, I am good with these changes. Let's explore where we are headed further in the proposal 🙌🏼

Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you so much!

@praveenrewar praveenrewar merged commit ff35d20 into carvel-dev:develop Mar 7, 2024
5 checks passed
@tmshort tmshort deleted the cmdline branch March 7, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Update --preflight flag to no longer follow the Check=true format
5 participants