2017-02-22 13:36:42 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
# author: Adam Leff
|
|
|
|
|
|
|
|
require 'thor'
|
Plugins API v2: Loader, Base API, and Test Harness (#3278)
* Functional tests for userdir option
* Accepts --config-dir CLI option
* Actually loads a config file from the config dir, more cases to test
* Able to load config and verify contents from config-dir
* Functional tests to ensure precedence for config options
* Enable setting config dir via env var
* .inspec, not .inspec.d
* Begin converting PluginCtl to PluginLoader/Registry
* Able to load and partially validate the plugins.json file
* More work on the plugin loader
* Break the world, move next gen stuff to plugin/
* Be sure to require base cli in bundled plugins
* Move test file
* Revert changes to v1 plugin, so we can have a separate one
* Checkpoint commit
* Move v2 plugin work to v2 area
* Move plugins v1 code into an isolated directory
* rubocop fixes
* Rip out the stuff about a user-dir config file, just use a plugin file
* Two psuedocode test file
* Working base API, moock plugin type, and loader.
* Adjust load path to be more welcoming
* Silence circular depencency warning, which was breaking a unit test
* Linting
* Fix plugin type registry, add tests to cover
* Feedback from Jerry
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2018-08-16 22:16:32 +00:00
|
|
|
require 'inspec/base_cli'
|
2017-02-22 13:36:42 +00:00
|
|
|
|
|
|
|
module Habitat
|
|
|
|
class HabitatProfileCLI < Thor
|
|
|
|
namespace 'habitat profile'
|
|
|
|
|
2017-10-17 12:53:41 +00:00
|
|
|
desc 'create PATH', 'Create a one-time Habitat artifact for the profile found at PATH'
|
2017-02-22 13:36:42 +00:00
|
|
|
option :output_dir, type: :string, required: false,
|
|
|
|
desc: 'Directory in which to save the generated Habitat artifact. Default: current directory'
|
|
|
|
def create(path)
|
|
|
|
Habitat::Profile.create(path, options)
|
|
|
|
end
|
|
|
|
|
2017-10-17 12:53:41 +00:00
|
|
|
desc 'setup PATH', 'Configure the profile at PATH for Habitat, including a plan and hooks'
|
|
|
|
def setup(path)
|
|
|
|
Habitat::Profile.setup(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'upload PATH', 'Create a one-time Habitat artifact for the profile found at PATH, and upload it to a Habitat Depot'
|
2017-02-22 13:36:42 +00:00
|
|
|
def upload(path)
|
|
|
|
Habitat::Profile.upload(path, options)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class HabitatCLI < Inspec::BaseCLI
|
|
|
|
namespace 'habitat'
|
|
|
|
|
|
|
|
desc 'profile', 'Manage InSpec profiles as Habitat artifacts'
|
|
|
|
subcommand 'profile', HabitatProfileCLI
|
|
|
|
end
|
|
|
|
|
|
|
|
Inspec::Plugins::CLI.add_subcommand(HabitatCLI, 'habitat', 'habitat SUBCOMMAND ...', 'Commands for InSpec + Habitat Integration', {})
|
|
|
|
end
|