-
Notifications
You must be signed in to change notification settings - Fork 58
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
Fail On Duplicate Config Names #1372
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,3 @@ | |||
package: | |||
name: foo |
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.
I think we might also want to fail if .package.name
is not the same as the filename.
These are potentially different/separate issues, but it does I think violate some assumptions we've made, and is worth avoiding.
If we have that check, we also get uniqueness "for free" since there can't be two foo.yaml
s
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.
If the .package.name field must match the filename, couldn't you make an argument that the field is redundant and should be removed?
// check that the package config name is unique | ||
_, exists := p[name] | ||
if exists { | ||
return p, fmt.Errorf("Package config names must be unique. Found duplicate '%s'", name) |
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 might be helpful to include the file names for the duplicate packages in the error message so it's easier to fix
Fixes #1599
wolfictl lint
to fail if a duplicate package config name is encountered.melange_test.go
for duplicate package config namesSteps to test:
lint
succeeds on a valid repo:The check happens in
pkg/melange
as this is where the duplicates were ignored as pointed out in #1599. An alternative but more complex solution would be to add a new lint rule. I didn't go that route because it would require a notable ABI change.#first-golang-pr (let's go)
@priyawadhwa