-
Notifications
You must be signed in to change notification settings - Fork 21
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
(GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource #42
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e198f57
to
6d149e2
Compare
c2b6c91
to
e1fcb4d
Compare
e1fcb4d
to
6dfc4cb
Compare
e28d324
to
e52f2be
Compare
e52f2be
to
f653f3c
Compare
2721ac1
to
8b2366b
Compare
120e0cf
to
1875e56
Compare
61c728c
to
c1e4995
Compare
Previously all of the Puppet helpers ran inside of a single instance of Puppet, however this causes issues because classes and types cannot be unloaded in a running instance. So instead, a sidecar executable is created which will run out of process, in a fresh Puppet configuration, to enable enumerating types, classes and functions etc. This commit creates the basic skeleton of this sidecar process.
This commit marks the puppet-language-sidecar ruby file as executable. This is mainly helpful for linux based developers.
The Language Server and the sidecar need an agreed upon protocol to communicate properly. The agreed upon encoding will be UTF8 JSON strings. This commit adds the required classes which can be used to serialise and deserialise objects to and from the sidecar process. This commit also includes tests to validate the serialisation process.
…tions and types This commit adds the ability for the sidecar process to enumerate classes, functions and types, either in the default configuration (i.e. like a real puppet agent) or only within the confines of a workspace directory (e.g. when editing a module or control-repo). Currently this only supports querying a puppet module workspace. This commit also adds the ability to pass in puppet options (e.g. --vardir) into the puppet configuration for the sidecar. This commit also uses a filesystem based caching mechanism to speed up the default enumerations. The majority of this code was extracted from the existing PuppetHelper in the Language Server and Puppet Monkey Patches.
…unctions and types This commit adds implementation and behavioural tests for the language sidecar process enumerating classes, functions and types.
This commit adds the ability for the Sidecar to fetch the resources for a given typename and title via the Action Parameters command line argument. This is similar to a `puppet resource` call. This commit also adds the required sidecar protocol additions and tests for the behaviour.
This commit adds the ability for the sidecar to generate a node graph for a manifest file on disk. The path the manifest is passed via the source Action Parameter. This commit also adds the required sidecar protocol additions and tests for the behaviour.
Previously if there was an error while parsing classes, it would cascade the error and crash the sidecar. This commit catches the error and gracefully continues.
c1e4995
to
5f0d0cb
Compare
jpogran
approved these changes
Oct 11, 2018
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Builds on #53
The language server is only able to load the default puppet modules that are outside of the thing being edited. This is due to Puppet not really being able to unload classes/types/facts etc. on the fly. So instead we need to call out to an external process to parse that information and then return it to the language server, thus the sidecar.
Note - This Pull Request only adds the sidecar, but does not plumb it into the language server proper.
To enumerate all of the Puppet custom types in a working directory;
Language server starts a sidecar process, instructing it to enumerate all classes/types/functions in the working directory; and return that in a structured data file (e.g. JSON)
Sidecar runs, and exports the relevant information to a file or STDIO
The sidecar would also be used for node graph generation, puppet strings
The sidecar would also be used to enumerate the default types/classes/functions and facts
The sidecar wouldn't be needed for linting as that doesn't require loading of puppet code (AFAIK)
This PR also includes tests.