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-1007) implement enough to support purge=>true #95

Merged
merged 8 commits into from
Jun 11, 2018

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented Jun 8, 2018

No description provided.

@DavidS DavidS force-pushed the pdk-1007-fix-purge branch 2 times, most recently from 6492278 to bf7c185 Compare June 11, 2018 08:53
@DavidS
Copy link
Contributor Author

DavidS commented Jun 11, 2018

The code coverage failure seems to be only empty lines.

@DavidS
Copy link
Contributor Author

DavidS commented Jun 11, 2018

rebased to master

Copy link

@da-ar da-ar left a comment

Choose a reason for hiding this comment

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

Looks great :)

expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
expect(status).to eq 0
end
# it 'returns the match if title matches a namevar value' do
Copy link

Choose a reason for hiding this comment

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

perhaps a comment to say why this is commented out rather than removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

re-activated them

expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
expect(status).to eq 0
end
# it 'returns the match if title matches a namevar value' do
Copy link

Choose a reason for hiding this comment

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

same here

@@ -1,7 +1,7 @@
# Puppet::ResourceApi [![TravisCI Build Status](https://travis-ci.org/puppetlabs/puppet-resource_api.svg?branch=master)](https://travis-ci.org/puppetlabs/puppet-resource_api) [![Appveyor Build status](https://ci.appveyor.com/api/projects/status/8o9s1ax0hs8lm5fd/branch/master?svg=true)](https://ci.appveyor.com/project/puppetlabs/puppet-resource-api/branch/master)
[![codecov](https://codecov.io/gh/puppetlabs/puppet-resource_api/branch/master/graph/badge.svg)](https://codecov.io/gh/puppetlabs/puppet-resource_api)

This is an implementation of the [Resource API](https://github.com/DavidS/puppet-specifications/blob/resourceapi/language/resource-api/README.md) proposal. Find a working example of a new-style provider in the [experimental puppetlabs-apt branch](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/provider/apt_key2/apt_key2.rb). There is also the corresponding [type](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/type/apt_key2.rb), [provider](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/provider/apt_key2/apt_key2.rb), and [new unit tests](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/spec/unit/puppet/provider/apt_key2/apt_key2_spec.rb) for 100% coverage.
This is an implementation of the [Resource API](https://github.com/puppetlabs/puppet-specifications/blob/master/language/resource-api/README.md) proposal. Find a working example of a new-style provider in the [experimental puppetlabs-apt branch](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/provider/apt_key2/apt_key2.rb). There is also the corresponding [type](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/type/apt_key2.rb), [provider](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/provider/apt_key2/apt_key2.rb), and [new unit tests](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/spec/unit/puppet/provider/apt_key2/apt_key2_spec.rb) for 100% coverage.
Copy link

Choose a reason for hiding this comment

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

Looks like another reference on line 179 that requires updating as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed!

This commit adds a property to make sure that what we get output is
what we asked for in the first place.
To allow the `resources` type to purge resource instances, the
`instances` method needs to return full `Puppet::Type` object
instances. This commit changes the Resource API's definition
of the `instances` method to do so, and fix up all adjacent
issues.

As of yet, this code still fails tests because it is not passing
on the "current" values to the `Puppet::Type` instances returned.
Instead `get` gets called through retrieve for each individual
instance, causing both performance issues and test failures.
With `--strict=error`, `puppet resource` would not work.
The fix of PDK-1007 now uncovered this. Therefore this commit
only checks that `puppet resource` succeeds on `--strict=off`.
With the last few changes the rsapi would call into get multiple times
for a type during a single run. This commit now pulls the retrieval of
the current state into `refresh_current_state` and leaves the caching
vs calling decision up to the caller.

As a side-effect the strict get-returns-canonical-values check now runs
at a time when puppet is not aborting the transaction for errors, and
the "exercising a device provider using `puppet resource` with strict
checking at error level deals with canonicalized resources correctly"
test case does not produce a non-zero exit code anymore.

Since now the state of the resource is correctly cached, the "exercising
simple_get_filter" test needed to be adjusted to use noop to display the
test result value.
Since `instances` now returns full `Puppet::Type` instances, this can
be removed. `ResourceShim`s are still used in `to_resource` to work
around the various manifest rendering bugs of the base implementation.
@DavidS
Copy link
Contributor Author

DavidS commented Jun 11, 2018

Addressed comments and rebased

@da-ar da-ar merged commit 59319aa into puppetlabs:master Jun 11, 2018
@DavidS DavidS deleted the pdk-1007-fix-purge branch March 13, 2019 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants