mirror of
https://github.com/inspec/inspec
synced 2024-09-20 06:21:56 +00:00
initial template for resource packs
This commit is contained in:
parent
7924290714
commit
df772fc9dc
15 changed files with 550 additions and 0 deletions
|
@ -69,6 +69,14 @@ module InspecPlugins
|
|||
File.join("docs", "resource-doc.erb") => File.join("docs-chef-io", "content", "inspec", "resources", vars[:resource_name] + ".md"),
|
||||
File.join("test", "unit", "inspec-resource-test-template.erb") => File.join("test", "unit", "resources", vars[:resource_name] + "_test.rb"),
|
||||
}
|
||||
elsif vars["layout"] == "resource-pack-project"
|
||||
{
|
||||
File.join("lib", "inspec-resource-template.erb") => File.join("lib", vars[:resource_name], "resources", vars[:resource_name] + ".rb"),
|
||||
File.join("lib", "plugin.erb") => File.join("lib", vars[:resource_name], "plugin.rb"),
|
||||
File.join("gemspec.erb") => File.join(vars[:resource_name] + ".gemspec"),
|
||||
File.join("ci", "config.erb") => File.join(".expeditor", "config.yml"),
|
||||
File.join("ci", "update_version.erb") => File.join(".expeditor", "update_version.sh"),
|
||||
}
|
||||
else
|
||||
ui.error("Unrecognized value for 'layout' - please enter either 'resource-pack' or 'core'")
|
||||
ui.exit(:usage_error)
|
||||
|
@ -95,6 +103,7 @@ module InspecPlugins
|
|||
choices: [
|
||||
{ name: "Resource Pack", value: "resource-pack", default: true },
|
||||
{ name: "InSpec Core", value: "core" },
|
||||
{ name: "Resource Pack Project", value: "resource-pack-project" },
|
||||
],
|
||||
},
|
||||
template: {
|
||||
|
@ -102,6 +111,7 @@ module InspecPlugins
|
|||
choices: [
|
||||
{ name: "Basic", value: "basic", default: true },
|
||||
{ name: "Plural", value: "plural" },
|
||||
{ name: "Project", value: "project" },
|
||||
],
|
||||
},
|
||||
supports_platform: {},
|
||||
|
|
56
lib/plugins/inspec-init/templates/resources/project/.gitignore
vendored
Normal file
56
lib/plugins/inspec-init/templates/resources/project/.gitignore
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
# Used by dotenv library to load environment variables.
|
||||
# .env
|
||||
|
||||
# Ignore Byebug command history file.
|
||||
.byebug_history
|
||||
|
||||
## Specific to RubyMotion:
|
||||
.dat*
|
||||
.repl_history
|
||||
build/
|
||||
*.bridgesupport
|
||||
build-iPhoneOS/
|
||||
build-iPhoneSimulator/
|
||||
|
||||
## Specific to RubyMotion (use of CocoaPods):
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# vendor/Pods/
|
||||
|
||||
## Documentation cache and generated files:
|
||||
/.yardoc/
|
||||
/_yardoc/
|
||||
/doc/
|
||||
/rdoc/
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# Gemfile.lock
|
||||
# .ruby-version
|
||||
# .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
|
||||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||
# .rubocop-https?--*
|
|
@ -0,0 +1,23 @@
|
|||
# Changelog
|
||||
|
||||
<!-- latest_release 0.3.1 -->
|
||||
## [0.3.1](https://github.com/inspec/inspec-docker-resources/tree/0.3.1) (2024-08-21)
|
||||
|
||||
#### Merged Pull Requests
|
||||
- Part of CHEF-15119 - Resolves the inspec-docker-resources resource pack loading issue [#7](https://github.com/inspec/inspec-docker-resources/pull/7) ([Vasu1105](https://github.com/Vasu1105))
|
||||
<!-- latest_release -->
|
||||
|
||||
<!-- release_rollup -->
|
||||
### Changes since latest stable release
|
||||
|
||||
#### Merged Pull Requests
|
||||
- Part of CHEF-15119 - Resolves the inspec-docker-resources resource pack loading issue [#7](https://github.com/inspec/inspec-docker-resources/pull/7) ([Vasu1105](https://github.com/Vasu1105)) <!-- 0.3.1 -->
|
||||
- empty commit [#6](https://github.com/inspec/inspec-docker-resources/pull/6) ([sean-simmons-progress](https://github.com/sean-simmons-progress)) <!-- 0.3.0 -->
|
||||
<!-- release_rollup -->
|
||||
|
||||
<!-- latest_stable_release -->
|
||||
<!-- latest_stable_release -->
|
||||
|
||||
## Previous Release
|
||||
|
||||
Initial release, forked from InSpec 7.0.0
|
|
@ -0,0 +1,3 @@
|
|||
source "https://rubygems.org"
|
||||
gem "inspec-bin", git: "https://github.com/inspec/inspec", branch: "team/gem-based-resource-packs"
|
||||
gem "inspec", git: "https://github.com/inspec/inspec", branch: "team/gem-based-resource-packs"
|
201
lib/plugins/inspec-init/templates/resources/project/LICENSE
Normal file
201
lib/plugins/inspec-init/templates/resources/project/LICENSE
Normal file
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,16 @@
|
|||
# inspec-docker-resources
|
||||
|
||||
Docker InSpec Resources in a Gem
|
||||
|
||||
This repository contains the InSpec Docker resources, formerly contained in InSpec Core. In InSpec 7+, these resources are available in a gem, `inspec-docker-resources`.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this resource pack, add this dependency to your inspec.yml :
|
||||
|
||||
```yaml
|
||||
depends:
|
||||
- name: inspec-docker-resources
|
||||
gem: inspec-docker-resources
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
0.3.1
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
slack:
|
||||
notify_channel:
|
||||
- inspec-notify
|
||||
|
||||
github:
|
||||
delete_branch_on_merge: true
|
||||
minor_bump_labels:
|
||||
- "Expeditor: Bump Minor Version"
|
||||
major_bump_labels:
|
||||
- "Expeditor: Bump Major Version"
|
||||
|
||||
subscriptions:
|
||||
- workload: pull_request_merged:{{github_repo}}:{{release_branch}}:*
|
||||
actions:
|
||||
- built_in:bump_version:
|
||||
ignore_labels:
|
||||
- "Expeditor: Skip Version Bump"
|
||||
- "Expeditor: Skip All"
|
||||
- bash:.expeditor/update_version.sh:
|
||||
only_if: built_in:bump_version
|
||||
- built_in:update_changelog:
|
||||
ignore_labels:
|
||||
- "Expeditor: Skip All"
|
||||
- "Expeditor: Skip Changelog"
|
10
lib/plugins/inspec-init/templates/resources/project/ci/update_version.erb
Executable file
10
lib/plugins/inspec-init/templates/resources/project/ci/update_version.erb
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file.
|
||||
# It then executes this file to update any other files/components with that new version.
|
||||
#
|
||||
|
||||
set -evx
|
||||
|
||||
sed -i -r "s/VERSION = \".*\"/VERSION = \"$(cat VERSION)\"/" lib/<%= resource_name %>/version.rb
|
||||
sed -i -r "s/version: .*/version: $(cat VERSION)/" inspec.yml
|
|
@ -0,0 +1,42 @@
|
|||
# As plugins are usually packaged and distributed as a RubyGem,
|
||||
# we have to provide a .gemspec file, which controls the gembuild
|
||||
# and publish process. This is a fairly generic gemspec.
|
||||
|
||||
# It is traditional in a gemspec to dynamically load the current version
|
||||
# from a file in the source tree. The next three lines make that happen.
|
||||
lib = File.expand_path("lib", __dir__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require "<%= resource_name %>/version"
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
# Importantly, all InSpec plugins must be prefixed with `inspec-` (most
|
||||
# plugins) or `train-` (plugins which add new connectivity features).
|
||||
spec.name = "<%= resource_name %>"
|
||||
|
||||
# It is polite to namespace your plugin under InspecPlugins::YourPluginInCamelCase
|
||||
spec.version = InspecPlugins::<%= resource_name.split('-')[1..].map(&:capitalize).join %>::VERSION
|
||||
spec.authors = ["InSpec Core Maintainers"]
|
||||
spec.email = ["inspec@progress.com"]
|
||||
spec.summary = "Docker InSpec Resources in a Gem"
|
||||
spec.description = "Contains InSpec 7.0+ resources fo interacting with Docker Desktop."
|
||||
spec.homepage = "https://github.com/inspec/<%= resource_name %>"
|
||||
spec.license = "Apache-2.0"
|
||||
|
||||
# Though complicated-looking, this is pretty standard for a gemspec.
|
||||
# It just filters what will actually be packaged in the gem (leaving
|
||||
# out tests, etc)
|
||||
spec.files = %w{
|
||||
README.md "<%= resource_name %>".gemspec Gemfile inspec.yml
|
||||
} + Dir.glob(
|
||||
"lib/**/*", File::FNM_DOTMATCH
|
||||
).reject { |f| File.directory?(f) }
|
||||
spec.require_paths = ["lib"]
|
||||
|
||||
# If you rely on any other gems, list them here with any constraints.
|
||||
# This is how `inspec plugin install` is able to manage your dependencies.
|
||||
# For example, perhaps you are writing a thing that talks to AWS, and you
|
||||
# want to ensure you have `aws-sdk` in a certain version.
|
||||
|
||||
# This plugin uses InSpec 7 Resource Pack Plugins
|
||||
spec.add_dependency "inspec-core", ">= 7.0"
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
name: inspec-docker-resources
|
||||
title: InSpec Docker Resources
|
||||
maintainer: InSpec Core Maintainers
|
||||
copyright: Progress Software Corporation
|
||||
copyright_email: inspec@progress.com
|
||||
license: Apache-2.0
|
||||
summary: Docker InSpec Resources in a Gem
|
||||
version: 0.3.1
|
||||
supports:
|
||||
platform: os
|
|
@ -0,0 +1,94 @@
|
|||
# Uncomment the below lines to add gems and files required by the resource
|
||||
# require ""
|
||||
# require_relative ""
|
||||
|
||||
# Change module if required
|
||||
module Inspec::Resources
|
||||
# Most custom InSpec resource inherit from a dynamic class, InSpec.resource(1).
|
||||
# If you wish to inherit from a core resource, you need to follow special instructions -
|
||||
# see https://www.chef.io/blog/extending-inspec-resources-core-resource-inheritance
|
||||
class <%= class_name %> < Inspec.resource(1)
|
||||
# Every resource requires an internal name.
|
||||
name "<%= resource_name %>"
|
||||
|
||||
# Restrict to only run on the below platforms (if none were given,
|
||||
# all OS's and cloud API's supported)
|
||||
supports platform: "<%= supports_platform %>"
|
||||
|
||||
desc "<%= description %>"
|
||||
|
||||
example <<~EXAMPLE
|
||||
describe "<%= resource_name %>" do
|
||||
its("shoe_size") { should cmp 10 }
|
||||
end
|
||||
describe "<%= resource_name %>" do
|
||||
it { should be_purple }
|
||||
end
|
||||
EXAMPLE
|
||||
|
||||
# Resource initialization. Add any arguments you want to pass to the contructor here.
|
||||
# Anything you pass here will be passed to the "describe" call:
|
||||
# describe <%= resource_name %>(YOUR_PARAMETERS_HERE) do
|
||||
# its("shoe_size") { should cmp 10 }
|
||||
# end
|
||||
def initialize
|
||||
skip_resource "The `<%= resource_name %>` resource is not yet available on your OS." unless inspec.os.<%= supports_platform %>?
|
||||
# Initialize required path/params/configs
|
||||
end
|
||||
|
||||
# Define a resource ID. This is used in reporting engines to uniquely identify the individual resource.
|
||||
# This might be a file path, or a process ID, or a cloud instance ID. Only meaningful to the implementation.
|
||||
# Must be a string. Defaults to the empty string if not implemented.
|
||||
def resource_id
|
||||
# replace value specific unique to this individual resource instance
|
||||
"something special"
|
||||
end
|
||||
|
||||
# Define how you want your resource to appear in test reports. Commonly, this is just the resource name and the resource ID.
|
||||
def to_s
|
||||
"<%= resource_name %> #{resource_id}"
|
||||
end
|
||||
|
||||
# Define matchers. Matchers are predicates - they return true or false.
|
||||
# Matchers also have their names transformed: the question mark is dropped, and
|
||||
# the "is_" prefix becomes "be_". A similar transformation happens for "has_" (see below)
|
||||
# So this will be called as:
|
||||
# describe "<%= resource_name %>" do
|
||||
# it { should be_purple }
|
||||
# end
|
||||
def is_purple?
|
||||
# positive or negative expectations specific to this resource instance
|
||||
true # Purple is the best color
|
||||
end
|
||||
|
||||
# Define matchers. Matchers are predicates - they return true or false.
|
||||
# Matchers also have their names transformed: the question mark is dropped, and
|
||||
# the "has_" prefix becomes "have_".
|
||||
# So this will be called as:
|
||||
# describe "<%= resource_name %>" do
|
||||
# it { should have_bells }
|
||||
# end
|
||||
def has_bells?
|
||||
# positive or negative expectations specific to this resource instance
|
||||
true # Jingle all the way
|
||||
end
|
||||
|
||||
# Define properties. Properties return values for evaluation against operators.
|
||||
# No name transformation occurs. This is called using the "its" facility.
|
||||
# So this will be called as:
|
||||
# describe "<%= resource_name %>" do
|
||||
# its('shoe_size') { should cmp 42 }
|
||||
# end
|
||||
def shoe_size
|
||||
# Implementation of a property specific to this resource
|
||||
42
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Methods to help the resource's public methods
|
||||
def helper_method
|
||||
# Add anything you need here
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
# Plugin Definition file
|
||||
# The purpose of this file is to declare to InSpec what plugin_types (capabilities)
|
||||
# are included in this plugin, and provide activator that will load them as needed.
|
||||
|
||||
# It is important that this file load successfully and *quickly*.
|
||||
# Your plugin's functionality may never be used on this InSpec run; so we keep things
|
||||
# fast and light by only loading heavy things when they are needed.
|
||||
|
||||
# Presumably this is light
|
||||
require "<%= resource_name %>/version"
|
||||
|
||||
# The InspecPlugins namespace is where all plugins should declare themselves.
|
||||
# The "Inspec" capitalization is used throughout the InSpec source code; yes, it's
|
||||
# strange.
|
||||
module InspecPlugins
|
||||
# Pick a reasonable namespace here for your plugin. A reasonable choice
|
||||
# would be the CamelCase version of your plugin gem name.
|
||||
# inspec-test-resources => TestResources
|
||||
module <%= resource_name.split('-')[1..].map(&:capitalize).join %>
|
||||
# This simple class handles the plugin definition, so calling it simply Plugin is OK.
|
||||
# Inspec.plugin returns various Classes, intended to be superclasses for various
|
||||
# plugin components. Here, the one-arg form gives you the Plugin Definition superclass,
|
||||
# which mainly gives you access to the activator / plugin_type DSL.
|
||||
# The number '2' says you are asking for version 2 of the plugin API. If there are
|
||||
# future versions, InSpec promises plugin API v2 will work for at least two more InSpec
|
||||
# major versions.
|
||||
class Plugin < ::Inspec.plugin(2)
|
||||
# Internal machine name of the plugin. InSpec will use this in errors, etc.
|
||||
plugin_name :"<%= resource_name %>"
|
||||
|
||||
|
||||
# Define a new Resource Pack.
|
||||
resource_pack :"<%= resource_name %>" do
|
||||
# This file will load the resources implicitly via the superclass
|
||||
require "<%= resource_name %>/resource_pack"
|
||||
|
||||
# Having loaded our functionality, return a class that represents the plugin.
|
||||
# Reserved for future use.
|
||||
InspecPlugins::<%= resource_name.split('-')[1..].map(&:capitalize).join %>::ResourcePack
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# This file simply makes it easier for CI engines to update
|
||||
# the version stamp, and provide a clean way for the gemspec
|
||||
# to learn the current version.
|
||||
module InspecPlugins
|
||||
module <%= resource_name.split('-')[1..].map(&:capitalize).join %>
|
||||
VERSION = "0.3.1".freeze
|
||||
end
|
||||
end
|
8
temp/generate.sh
Executable file
8
temp/generate.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
|
||||
# iterate based on input
|
||||
for RESOURCE_NAME in "$@"; do
|
||||
CLASS_NAME=$(echo "$RESOURCE_NAME" | awk -F'-' '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1' OFS='')
|
||||
bundle exec inspec init resource "$RESOURCE_NAME" --overwrite true --path "/Users/balasubs/ProgressChef/resource-packs/$RESOURCE_NAME" --layout resource-pack-project --template project --class_name $CLASS_NAME --no-prompt
|
||||
echo "Generated $CLASS_NAME packs"
|
||||
done
|
||||
|
Loading…
Reference in a new issue