Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Big Refactor
* Remove vault client caching for now 
	* (TODO: check with original contributor to reimplement in a testable way)
* Update docs
* Move to k/v v2 
* Remove references to generic 
* More test coverage
* Update travis.yml build and get it green
* Rubocop fixes
* Add warning to README
  • Loading branch information
petems committed Dec 17, 2018
1 parent 343d3e8 commit 55eaa97
Show file tree
Hide file tree
Showing 9 changed files with 511 additions and 232 deletions.
106 changes: 106 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,106 @@
---
AllCops:
DisplayCopNames: true
TargetRubyVersion: '2.3'
Include:
- "lib/**/*.rb"
- "spec/**/*.rb"
Exclude:
- bin/*
- "spec/spec_helper.rb"
- ".vendor/**/*"
- "**/Gemfile"
- "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
- spec/support/vault_server.rb
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Style/EmptyElse:
Description: Enforce against empty else clauses, but allow `nil` for clarity.
EnforcedStyle: empty
Style/FormatString:
Description: Following the main puppet project's style, prefer the % format format.
EnforcedStyle: percent
Style/FormatStringToken:
Description: Following the main puppet project's style, prefer the simpler template
tokens over annotated ones.
EnforcedStyle: template
Style/Lambda:
Description: Prefer the keyword for easier discoverability.
EnforcedStyle: literal
Style/RegexpLiteral:
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
EnforcedStyle: percent_r
Style/TernaryParentheses:
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
on complex expressions for better readability, but seriously consider breaking
it up.
EnforcedStyle: require_parentheses_when_complex
Style/TrailingCommaInArguments:
Description: Prefer always trailing comma on multiline argument lists. This makes
diffs, and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
Description: Prefer always trailing comma on multiline literals. This makes diffs,
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
Description: Prefer always trailing comma on multiline literals. This makes diffs,
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
Style/Documentation:
Exclude:
- lib/puppet/parser/functions/**/*
- spec/**/*
Style/WordArray:
EnforcedStyle: brackets
Style/CollectionMethods:
Enabled: true
Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/StringMethods:
Enabled: true
Layout/EndOfLine:
Enabled: false
Layout/IndentHeredoc:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Style/AsciiComments:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/SymbolProc:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
28 changes: 25 additions & 3 deletions .travis.yml
@@ -1,6 +1,28 @@
dist: trusty
sudo: false
language: ruby
script: "bundle exec rake spec"
cache: bundler

env:
- PUPPET_VERSION="~> 5" VAULT_VERSION=1.0.1
- PUPPET_VERSION="~> 5" VAULT_VERSION=0.11.6
- PUPPET_VERSION="~> 5" VAULT_VERSION=0.10.4
- PUPPET_VERSION="~> 6" VAULT_VERSION=1.0.1
- PUPPET_VERSION="~> 6" VAULT_VERSION=0.11.6
- PUPPET_VERSION="~> 6" VAULT_VERSION=0.10.4

before_install:
- curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
- unzip vault.zip
- mkdir -p ~/bin
- mv vault ~/bin
- export PATH="~/bin:$PATH"
- rm Gemfile.lock

branches:
only:
- master

rvm:
- 2.1.9
- 2.4.1
- 2.4
- 2.5
73 changes: 73 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,73 @@
This module has grown over time based on a range of contributions from
people using it. If you follow these contributing guidelines your patch
will likely make it into a release a little quicker.

## Contributing

1. Fork the repo.

1. Create a separate branch for your change.

1. Run the tests. We only take pull requests with passing tests, and
documentation.

1. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
or fixing a bug, please add a test.

1. Squash your commits down into logical components. Make sure to rebase
against the current master.

1. Push the branch to your fork and submit a pull request.

Please be prepared to repeat some of these steps as our contributors review
your code.

## Dependencies

The testing and development tools have a bunch of dependencies,
all managed by [bundler](http://bundler.io/).

By default the tests use a baseline version of Puppet.

Install the dependencies like so...

bundle install

## Syntax and style

Run `rubocop` to detect style issues and perform fixes:

bundle exec rubocop -a .

## Running the unit tests

The unit test suite covers most of the code, as mentioned above please
add tests if you're adding new functionality.

The unit tests currently run against a real vault instance running in `server -dev` mode.
This can be seen in [./spec/support/vault_server.rb](vault_server.rb)).

You will need Vault in your path for this to work.

To run your all the unit tests

bundle exec rake spec SPEC_OPTS='--format documentation'

To run a specific spec test set the `SPEC` variable:

bundle exec rake spec SPEC=spec/foo_spec.rb:123



## Integration tests

The unit tests just check the code runs, not that it does exactly what
we want on a real machine. For that we're using
[beaker](https://github.com/puppetlabs/beaker).

This fires up a simple Docker cluster and runs a series of
simple tests against it after applying the module. You can run this
with:

bundle exec rake acceptance
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -26,5 +26,7 @@ group :test do
gem 'simplecov-console'

gem 'puppet-blacksmith'

gem 'pry'
end

80 changes: 48 additions & 32 deletions Gemfile.lock
Expand Up @@ -5,91 +5,106 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0)
ast (2.4.0)
aws-sigv4 (1.0.2)
aws-sigv4 (1.0.3)
coderay (1.1.2)
debouncer (0.2.2)
diff-lcs (1.3)
docile (1.3.0)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
facter (2.5.1)
fast_gettext (1.1.2)
hiera (3.4.2)
hiera (3.4.5)
hirb (0.7.3)
hocon (1.2.5)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
jaro_winkler (1.5.1)
json (2.1.0)
json-schema (2.8.0)
json-schema (2.8.1)
addressable (>= 2.4)
locale (2.1.2)
metaclass (0.0.4)
metadata-json-lint (2.1.0)
metadata-json-lint (2.2.0)
json-schema (~> 2.8)
spdx-licenses (~> 1.0)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mocha (1.4.0)
mocha (1.7.0)
metaclass (~> 0.0.1)
multi_json (1.13.1)
netrc (0.11.0)
parallel (1.12.1)
parser (2.5.0.5)
parser (2.5.3.0)
ast (~> 2.4.0)
powerpack (0.1.1)
public_suffix (3.0.2)
puppet (5.5.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.3)
puppet (6.0.4)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
hiera (>= 3.2.1, < 4)
httpclient (~> 2.8)
locale (~> 2.1)
multi_json (~> 1.10)
puppet-resource_api (~> 1.5)
semantic_puppet (~> 1.0)
puppet-blacksmith (4.1.2)
rest-client (~> 2.0)
puppet-lint (2.3.3)
puppet-lint (2.3.6)
puppet-resource_api (1.6.2)
hocon (>= 1.0)
puppet-syntax (2.4.1)
rake
puppetlabs_spec_helper (2.6.2)
puppetlabs_spec_helper (2.12.0)
mocha (~> 1.0)
puppet-lint (~> 2.0)
puppet-syntax (~> 2.0)
rspec-puppet (~> 2.0)
rainbow (3.0.0)
rake (12.3.1)
rake (12.3.2)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-puppet (2.6.11)
rspec-support (~> 3.8.0)
rspec-puppet (2.7.2)
rspec
rspec-puppet-utils (3.4.0)
mocha
puppet
puppetlabs_spec_helper
rspec
rspec-puppet
rspec-support (3.7.1)
rubocop (0.54.0)
rspec-support (3.8.0)
rubocop (0.61.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
unicode-display_width (~> 1.4.0)
ruby-debug-ide (0.6.1)
rake (>= 0.8.1)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.0)
semantic_puppet (1.0.2)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand All @@ -99,12 +114,12 @@ GEM
hirb
simplecov
simplecov-html (0.10.2)
spdx-licenses (1.1.0)
spdx-licenses (1.2.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.3.0)
vault (0.11.0)
unicode-display_width (1.4.0)
vault (0.12.0)
aws-sigv4

PLATFORMS
Expand All @@ -114,6 +129,7 @@ DEPENDENCIES
debouncer
facter (>= 1.7.0)
metadata-json-lint
pry
puppet (>= 3.3)
puppet-blacksmith
puppet-lint (>= 1.0.0)
Expand Down

0 comments on commit 55eaa97

Please sign in to comment.