-
Notifications
You must be signed in to change notification settings - Fork 130
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
DEVPROD-13370 Validate single task distros during project validation #8624
Conversation
validator/project_validator.go
Outdated
distroWarnings = map[string]string{} | ||
singleTaskDistroIDs = []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not actually necessary to initialize an empty slice here, just append
ing to the nil slice singleTaskDistroIDs
is sufficient. The first append
will allocate capacity for the slice. Only maps need to be initialized explicitly before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious but it's possible that singleTaskDistroIDs is never appended to or touched in the code. would it not error and just pass in nil automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that it's never appended to, but it's also quite rare to find code that makes a distinction between a nil slice vs. an empty slice. A nil slice still evaluates len
to zero like an empty slice, and you can for
loop through it like an empty slice.
The only way you would really tell it's nil and not empty is if you specifically checked if slice == nil
. I find that scenario pretty rare compared to length checking.
validator/project_validator.go
Outdated
Message: fmt.Sprintf("buildvariant '%s' references a single task distro '%s' which is not allowed for buildvariants", buildVariant.Name, name), | ||
Level: Error, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RunOn
can also be specified for a specific build variant task. Does that also need to be validated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't the code already take that into account since its looping over all tasks in a bv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see there's an outermost loop. Never mind!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were very insightful comments thank you
validator/project_validator.go
Outdated
distroWarnings = map[string]string{} | ||
singleTaskDistroIDs = []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious but it's possible that singleTaskDistroIDs is never appended to or touched in the code. would it not error and just pass in nil automatically?
validator/project_validator.go
Outdated
Message: fmt.Sprintf("buildvariant '%s' references a single task distro '%s' which is not allowed for buildvariants", buildVariant.Name, name), | ||
Level: Error, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't the code already take that into account since its looping over all tasks in a bv?
validator/project_validator.go
Outdated
distroWarnings = map[string]string{} | ||
singleTaskDistroIDs = []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that it's never appended to, but it's also quite rare to find code that makes a distinction between a nil slice vs. an empty slice. A nil slice still evaluates len
to zero like an empty slice, and you can for
loop through it like an empty slice.
The only way you would really tell it's nil and not empty is if you specifically checked if slice == nil
. I find that scenario pretty rare compared to length checking.
validator/project_validator.go
Outdated
Message: fmt.Sprintf("buildvariant '%s' references a single task distro '%s' which is not allowed for buildvariants", buildVariant.Name, name), | ||
Level: Error, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see there's an outermost loop. Never mind!
DEVPROD-13370
Description
during project validation, any tasks that specify a single task distro will need to be on an allowed list or it will error
Testing
unit testing
(e2e will be done later)