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

(GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource #42

Merged
merged 8 commits into from
Oct 11, 2018

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Jul 2, 2018

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.

@glennsarti glennsarti force-pushed the create-sidecar branch 8 times, most recently from e198f57 to 6d149e2 Compare July 11, 2018 05:35
@glennsarti glennsarti force-pushed the create-sidecar branch 12 times, most recently from c2b6c91 to e1fcb4d Compare July 16, 2018 12:47
@glennsarti glennsarti added this to the 0.14.0 milestone Jul 19, 2018
@glennsarti glennsarti force-pushed the create-sidecar branch 3 times, most recently from e28d324 to e52f2be Compare July 31, 2018 08:08
@glennsarti glennsarti changed the title {WIP} (GH-40) Create sidecar (GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource Jul 31, 2018
@glennsarti glennsarti force-pushed the create-sidecar branch 2 times, most recently from 2721ac1 to 8b2366b Compare August 31, 2018 07:31
@glennsarti glennsarti force-pushed the create-sidecar branch 2 times, most recently from 120e0cf to 1875e56 Compare September 27, 2018 07:39
@glennsarti glennsarti changed the title (GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource {WIP}(GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource Sep 27, 2018
@glennsarti glennsarti force-pushed the create-sidecar branch 2 times, most recently from 61c728c to c1e4995 Compare October 3, 2018 02:00
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.
@glennsarti glennsarti changed the title {WIP}(GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource (GH-40) Create sidecar process to enumerate puppet types, classes, functions, node graph and puppet resource Oct 3, 2018
@jpogran jpogran added the enhancement New feature or request label Oct 11, 2018
Copy link
Contributor

@jpogran jpogran left a comment

Choose a reason for hiding this comment

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

wicked

@jpogran jpogran merged commit ae083c3 into puppetlabs:master Oct 11, 2018
@glennsarti glennsarti deleted the create-sidecar branch October 12, 2018 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants