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

fix: prevent duplicate configs, secrets, databases within module #1336

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

deniseli
Copy link
Contributor

Fixes #1121

This adds backend schema validation preventing duplicate configs, secrets, and databases within a module. This also adds go-runtime validation preventing duplicate databases. Go-runtime validation for duplicate configs/secrets was added in PR #1328

simple test for config

add secrets and databases

add go-runtime check for databases
@deniseli deniseli requested a review from a team as a code owner April 26, 2024 01:01
@deniseli deniseli requested review from wesbillman and removed request for a team April 26, 2024 01:01
@alecthomas alecthomas mentioned this pull request Apr 26, 2024
@deniseli deniseli merged commit 64b2f21 into main Apr 26, 2024
12 checks passed
@deniseli deniseli deleted the dli/be-dupl-config branch April 26, 2024 01:15
dbs := make(map[string]int)

for i, d := range decls {
c, ok := d.(*Config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use a type switch here instead of these separate individual type conversions:

switch d := d.(type) {
case *Config:
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops thank you!

configs[c.Name] = []int{i}
continue
}
matchIdx, foundMatch := ftlslices.Find(configs[c.Name], func(j int) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of this? Can't the maps just be map[string]*Config, and if one already exists you report it as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my, I somehow forgot pointers existed. Fixing this now whoops

@deniseli
Copy link
Contributor Author

fw fix in #1337

deniseli added a commit that referenced this pull request Apr 26, 2024
Fixes #1121

* Addresses comments in PR #1336
* Adds additional duplication error case for configs/secrets with the
same name but different types, which also simplifies the overall
validation logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple usages of config usages show up in schema
2 participants