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

lsp/server: Cache AllRegoVersions at config load #1325

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

charlieegan3
Copy link
Member

This does not reload when a .manifest file is changed yet.

This does not reload when a .manifest file is changed yet.

Signed-off-by: Charlie Egan <charlie@styra.com>
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

Terrific!

loadedConfigEnabledNonAggregateRules []string
loadedConfigEnabledAggregateRules []string
loadedConfigAllRegoVersions *concurrent.Map[string, ast.RegoVersion]
Copy link
Member

Choose a reason for hiding this comment

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

Neat :)

var versionedDirs []string

// if we have no information, then we can return the default
if l.loadedConfigAllRegoVersions == nil || l.loadedConfigAllRegoVersions.Len() == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should have Len() always return 0 when its parent is nil? It would make the check here a little cleaner.

return fmt.Sprintf("package %s\n\nimport rego.v1\n", pkg), nil
}

return fmt.Sprintf("package %s\n\n", pkg), nil
Copy link
Member

Choose a reason for hiding this comment

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

Very good!

Copy link
Member Author

Choose a reason for hiding this comment

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

a47ab6d
fixed here!

Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 merged commit f0b2ca9 into StyraInc:opa1.0 Jan 9, 2025
5 checks passed
@charlieegan3 charlieegan3 deleted the server-file-versions branch January 9, 2025 14:26
anderseknert pushed a commit that referenced this pull request Jan 9, 2025
* lsp/server: Cache AllRegoVersions at config load

This does not reload when a .manifest file is changed yet.

Signed-off-by: Charlie Egan <charlie@styra.com>

* concurrent/map: Nil map is empty

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
anderseknert pushed a commit that referenced this pull request Jan 13, 2025
* lsp/server: Cache AllRegoVersions at config load

This does not reload when a .manifest file is changed yet.

Signed-off-by: Charlie Egan <charlie@styra.com>

* concurrent/map: Nil map is empty

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
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.

2 participants