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-506) pdk new provider #409

Merged
merged 2 commits into from
Jan 30, 2018
Merged

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented Jan 19, 2018

No description provided.

@DavidS
Copy link
Contributor Author

DavidS commented Jan 19, 2018

This requires puppetlabs/pdk-templates#13 to work.

@DavidS DavidS force-pushed the pdk-506-provider branch 3 times, most recently from 03f186e to ce58c5e Compare January 22, 2018 13:31
@puppetlabs puppetlabs deleted a comment from coveralls Jan 22, 2018
@puppetlabs puppetlabs deleted a comment from coveralls Jan 22, 2018
@puppetlabs puppetlabs deleted a comment from coveralls Jan 22, 2018
@DavidS
Copy link
Contributor Author

DavidS commented Jan 22, 2018

Currently this still needs two manual interventions to work:

The configuration in .sync.yml will remain for the forseeable future. The gem/git fix will vanish as soon as I release a new version of the gem (immanent). This can be merged if the code passes muster.

david@davids:~/git$ ~/git/pdk/bin/pdk new module example --skip-interview --template-url=/home/david/git/pdk-templates 
pdk (INFO): Creating new module: example
pdk (INFO): Module 'example' generated at path '/home/david/git/example', from template '/home/david/git/pdk-templates'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
david@davids:~/git$ cd example/
david@davids:~/git/example$ cp ../archive/example/.sync.yml .
david@davids:~/git/example$ cat .sync.yml 
---
Gemfile:
  optional:
    ':development':
      - gem: 'puppet-resource_api'
spec/spec_helper.rb:
  mock_with: ':rspec'
(failed reverse-i-search)`conver': git push origin HEAD:unit-test-^Cnversions
david@davids:~/git/example$ ^C
david@davids:~/git/example$ ~/git/pdk/bin/pdk convert --template-url=/home/david/git/pdk-templates --force

----------Files to be modified----------
Gemfile
spec/spec_helper.rb

----------------------------------------

You can find a report of differences in convert_report.txt.

[✔] Resolving Gemfile dependencies.

------------Convert completed-----------

2 files modified.

david@davids:~/git/example$ vi Gemfile
david@davids:~/git/example$ ~/git/pdk/bin/pdk convert --template-url=/home/david/git/pdk-templates --force^C
david@davids:~/git/example$ ~/git/pdk/bin/pdk validate ruby
[✔] Installing missing Gemfile dependencies.
[✔] Checking Ruby code style (**/**.rb).
david@davids:~/git/example$ ~/git/pdk/bin/pdk test unit
[✔] Preparing to run the unit tests.
[✔] Running unit tests.
No examples found.
  Evaluated 0 tests in 0.000324065 seconds: 0 failures, 0 pending.
[✔] Cleaning up after running unit tests.
david@davids:~/git/example$ rm -Rf lib/puppet/ spec/unit/ && ~/git/pdk/bin/pdk new provider foo --template-url=/home/david/git/pdk-templates && ~/git/pdk/bin/pdk validate
pdk (INFO): Creating '/home/david/git/example/lib/puppet/type/foo.rb' from template.
pdk (INFO): Creating '/home/david/git/example/lib/puppet/provider/foo/foo.rb' from template.
pdk (INFO): Creating '/home/david/git/example/spec/unit/puppet/provider/foo/foo_spec.rb' from template.
pdk (INFO): Running all available validators...
[✔] Checking metadata syntax (metadata.json tasks/*.json).
[✔] Checking module metadata style (metadata.json).
[✔] Checking Ruby code style (**/**.rb).
info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json).
info: puppet-syntax: ./: Target does not contain any files to validate (**/**.pp).
info: puppet-lint: ./: Target does not contain any files to validate (**/*.pp).
david@davids:~/git/example$ ~/git/pdk/bin/pdk validate ruby
[✔] Checking Ruby code style (**/**.rb).
david@davids:~/git/example$ ~/git/pdk/bin/pdk test unit
[✔] Preparing to run the unit tests.
[✔] Running unit tests.
  Evaluated 5 tests in 0.014163803 seconds: 0 failures, 0 pending.
[✔] Cleaning up after running unit tests.
david@davids:~/git/example$ 

@bmjen
Copy link
Contributor

bmjen commented Jan 22, 2018

X-Post from the pdk-templates PR review.
puppetlabs/pdk-templates#13 (review)

Also, is there a reason why we don't just put those .sync.yml lines into the module skeleton?

@DavidS
Copy link
Contributor Author

DavidS commented Jan 23, 2018

I don't think that the gem is ready yet for wide spread release. At one point in the next few months, I expect that to change, but until then, it's something folks will have to carry locally.

Changing the default mock type is something I wanted to do for a long time, but it'll require more work than appropriate for this PR set.

This is required for generators to have guard clauses if they cannot be
applied in a specific situation.
This implements `pdk new provider` command to support use of the
Resource API in modules.

This requires the template changes from puppetlabs/pdk-templates#13

See the README on https://github.com/puppetlabs/puppet-resource_api for details
@DavidS
Copy link
Contributor Author

DavidS commented Jan 25, 2018

The new version now checks for some preconditions in the .sync.yml file. If they are not met, the pdk new provider command will point towards the resource api's docs where the necessary changes are described.

Copy link
Contributor

@bmjen bmjen left a comment

Choose a reason for hiding this comment

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

@DavidS I'm going to merge this to get this in. I see the dip in coverage as acceptable, b/c most of it is a large if/else block that checks for the pre-conditions, this will likely go away when we make the feature official.

@bmjen bmjen merged commit de93bf5 into puppetlabs:master Jan 30, 2018
@DavidS DavidS deleted the pdk-506-provider branch January 30, 2018 10:10
@bmjen bmjen added the feature label Feb 16, 2018
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.

2 participants