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

(PDK-1333) command_spec rake task #644

Merged
merged 1 commit into from
Jul 3, 2019

Conversation

rodjek
Copy link
Contributor

@rodjek rodjek commented Mar 26, 2019

Initial stab at introspecting Cri to generate a JSON spec of the PDK command structure.

/cc @glennsarti @jpogran

@coveralls
Copy link

coveralls commented Mar 26, 2019

Coverage Status

Coverage remained the same at 93.09% when pulling c990891 on rodjek:pdk_command_spec into 7c63ef4 on puppetlabs:master.

@rodjek rodjek force-pushed the pdk_command_spec branch from 933f6ee to 423eaea Compare March 26, 2019 04:03
@rodjek rodjek changed the title (maint) command_spec rake task (PDK-1333) command_spec rake task Mar 26, 2019
@rodjek rodjek force-pushed the pdk_command_spec branch from 423eaea to 619673f Compare March 26, 2019 23:26
@glennsarti
Copy link
Contributor

Hrmmm small issue and I'm not sure how you'd solve it

e.g. pdk new class

As per https://github.com/puppetlabs/pdk/blob/master/lib/pdk/cli/new/class.rb#L15 it requires a class name however this is not expressed in the spec output

        {
          "name": "class",
          "aliases": [

          ],
          "description": null,
          "hidden": null,
          "summary": "Create a new class named <class_name> using given options",
          "usage": "Create a new class named <class_name> using given options",
          "options": [

          ],
          "subcommands": [

          ]
        },

Apart from string interpolating for <xxxxxx> but that seems fragile.

@rodjek
Copy link
Contributor Author

rodjek commented Apr 3, 2019

cri 2.12.x introduced explicitly defined parameters, so we can make use of that to define the parameters and then pull them out when introspecting. As we still currently have to support Ruby 2.1.9 which is limited to cri 2.10.x, we'll need to guard these definitions.

Something like this should work:

param :class_name if respond_to?(:param)

We'd also need to change how we access the parameters as they'd change from an array to a hash (maybe args = args.values if args.is_a?(Hash))

@scotje
Copy link
Contributor

scotje commented Apr 3, 2019

I wonder if we could conditionally monkey patch basic param support into Cri < 2.12.x so that the actual PDK command definitions and argument handling code doesn't get littered with new conditionals?

@glennsarti
Copy link
Contributor

Maybe... This is just metadata at the end of the day,....

@glennsarti
Copy link
Contributor

I think if we cleaned up the commit message, this is ready for merge. As it's purely for development of (PDK) and not user facing, this won't require the same rigour or have the same blast radius if it's wrong.

Introspects the populated Cri data structure to generate a JSON
specification of the PDK command structure for use in generating the
PowerShell cmdlets.
@rodjek rodjek force-pushed the pdk_command_spec branch from 619673f to c990891 Compare July 2, 2019 23:38
@rodjek rodjek merged commit f1cdfcb into puppetlabs:master Jul 3, 2019
@rodjek rodjek deleted the pdk_command_spec branch July 3, 2019 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants