berkshelf 5.2.0 → 8.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +19 -47
- data/Rakefile +14 -4
- data/berkshelf.gemspec +61 -40
- data/bin/berks +2 -2
- data/lib/berkshelf/api-client.rb +1 -0
- data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
- data/lib/berkshelf/api_client/connection.rb +57 -0
- data/lib/berkshelf/api_client/errors.rb +10 -0
- data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
- data/lib/berkshelf/api_client/version.rb +5 -0
- data/lib/berkshelf/api_client.rb +24 -0
- data/lib/berkshelf/berksfile.rb +149 -122
- data/lib/berkshelf/cached_cookbook.rb +127 -24
- data/lib/berkshelf/chef_config_compat.rb +51 -0
- data/lib/berkshelf/chef_repo_universe.rb +47 -0
- data/lib/berkshelf/cli.rb +143 -174
- data/lib/berkshelf/commands/shelf.rb +20 -19
- data/lib/berkshelf/community_rest.rb +59 -94
- data/lib/berkshelf/config.rb +97 -127
- data/lib/berkshelf/cookbook_store.rb +7 -6
- data/lib/berkshelf/core_ext/file.rb +1 -1
- data/lib/berkshelf/core_ext/file_utils.rb +4 -4
- data/lib/berkshelf/core_ext.rb +1 -1
- data/lib/berkshelf/dependency.rb +25 -32
- data/lib/berkshelf/downloader.rb +66 -39
- data/lib/berkshelf/errors.rb +23 -17
- data/lib/berkshelf/file_syncer.rb +24 -47
- data/lib/berkshelf/formatters/human.rb +7 -5
- data/lib/berkshelf/formatters/json.rb +6 -6
- data/lib/berkshelf/installer.rb +120 -111
- data/lib/berkshelf/location.rb +14 -14
- data/lib/berkshelf/locations/base.rb +1 -1
- data/lib/berkshelf/locations/git.rb +16 -24
- data/lib/berkshelf/locations/github.rb +2 -2
- data/lib/berkshelf/locations/path.rb +2 -2
- data/lib/berkshelf/lockfile.rb +326 -328
- data/lib/berkshelf/logger.rb +64 -1
- data/lib/berkshelf/mixin/git.rb +6 -5
- data/lib/berkshelf/packager.rb +44 -10
- data/lib/berkshelf/resolver/graph.rb +1 -1
- data/lib/berkshelf/resolver.rb +4 -4
- data/lib/berkshelf/ridley_compat.rb +109 -0
- data/lib/berkshelf/shell.rb +2 -1
- data/lib/berkshelf/shell_out.rb +18 -0
- data/lib/berkshelf/source.rb +77 -33
- data/lib/berkshelf/source_uri.rb +4 -4
- data/lib/berkshelf/ssl_policies.rb +38 -0
- data/lib/berkshelf/thor.rb +1 -1
- data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
- data/lib/berkshelf/thor_ext.rb +1 -1
- data/lib/berkshelf/uploader.rb +106 -70
- data/lib/berkshelf/validator.rb +13 -5
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf/visualizer.rb +16 -11
- data/lib/berkshelf.rb +106 -81
- data/spec/config/knife.rb +4 -4
- data/spec/data/trusted_certs/example.crt +22 -0
- data/spec/fixtures/Berksfile +3 -3
- data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
- data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
- data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
- data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
- data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
- data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
- data/spec/spec_helper.rb +56 -64
- data/spec/support/chef_api.rb +15 -16
- data/spec/support/chef_server.rb +71 -69
- data/spec/support/git.rb +59 -58
- data/spec/support/kitchen.rb +0 -14
- data/spec/support/matchers/file_system_matchers.rb +4 -5
- data/spec/support/matchers/filepath_matchers.rb +2 -2
- data/spec/support/path_helpers.rb +17 -17
- data/spec/support/shared_examples/formatter.rb +1 -1
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
- data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
- data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
- data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
- data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
- data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
- data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
- data/spec/unit/berkshelf/cli_spec.rb +7 -8
- data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
- data/spec/unit/berkshelf/config_spec.rb +51 -22
- data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
- data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
- data/spec/unit/berkshelf/dependency_spec.rb +48 -48
- data/spec/unit/berkshelf/downloader_spec.rb +191 -34
- data/spec/unit/berkshelf/errors_spec.rb +3 -3
- data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
- data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
- data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
- data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
- data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
- data/spec/unit/berkshelf/installer_spec.rb +8 -8
- data/spec/unit/berkshelf/location_spec.rb +11 -11
- data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
- data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
- data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
- data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
- data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
- data/spec/unit/berkshelf/logger_spec.rb +3 -3
- data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
- data/spec/unit/berkshelf/packager_spec.rb +2 -2
- data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
- data/spec/unit/berkshelf/resolver_spec.rb +17 -17
- data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
- data/spec/unit/berkshelf/shell_spec.rb +34 -34
- data/spec/unit/berkshelf/source_spec.rb +186 -20
- data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
- data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
- data/spec/unit/berkshelf/uploader_spec.rb +146 -64
- data/spec/unit/berkshelf/validator_spec.rb +23 -16
- data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
- data/spec/unit/berkshelf_spec.rb +18 -18
- metadata +138 -289
- data/.gitignore +0 -29
- data/.travis.yml +0 -64
- data/CHANGELOG.legacy.md +0 -307
- data/CHANGELOG.md +0 -1358
- data/CONTRIBUTING.md +0 -64
- data/Gemfile.lock +0 -399
- data/Guardfile +0 -23
- data/PLUGINS.md +0 -25
- data/README.md +0 -70
- data/Thorfile +0 -61
- data/appveyor.yml +0 -31
- data/docs/berkshelf_for_newcomers.md +0 -65
- data/features/berksfile.feature +0 -46
- data/features/commands/apply.feature +0 -41
- data/features/commands/contingent.feature +0 -48
- data/features/commands/cookbook.feature +0 -35
- data/features/commands/info.feature +0 -99
- data/features/commands/init.feature +0 -27
- data/features/commands/install.feature +0 -636
- data/features/commands/list.feature +0 -78
- data/features/commands/outdated.feature +0 -130
- data/features/commands/package.feature +0 -17
- data/features/commands/search.feature +0 -17
- data/features/commands/shelf/list.feature +0 -32
- data/features/commands/shelf/show.feature +0 -143
- data/features/commands/shelf/uninstall.feature +0 -96
- data/features/commands/show.feature +0 -83
- data/features/commands/update.feature +0 -142
- data/features/commands/upload.feature +0 -426
- data/features/commands/vendor.feature +0 -111
- data/features/commands/verify.feature +0 -29
- data/features/commands/viz.feature +0 -66
- data/features/community_site.feature +0 -37
- data/features/config.feature +0 -111
- data/features/help.feature +0 -11
- data/features/json_formatter.feature +0 -161
- data/features/lifecycle.feature +0 -378
- data/features/lockfile.feature +0 -378
- data/features/step_definitions/berksfile_steps.rb +0 -39
- data/features/step_definitions/chef/config_steps.rb +0 -12
- data/features/step_definitions/chef_server_steps.rb +0 -60
- data/features/step_definitions/cli_steps.rb +0 -18
- data/features/step_definitions/config_steps.rb +0 -46
- data/features/step_definitions/environment_steps.rb +0 -7
- data/features/step_definitions/filesystem_steps.rb +0 -269
- data/features/step_definitions/gem_steps.rb +0 -13
- data/features/step_definitions/json_steps.rb +0 -23
- data/features/step_definitions/utility_steps.rb +0 -11
- data/features/support/aruba.rb +0 -12
- data/features/support/env.rb +0 -82
- data/generator_files/Berksfile.erb +0 -11
- data/generator_files/CHANGELOG.md.erb +0 -3
- data/generator_files/Gemfile.erb +0 -8
- data/generator_files/README.md.erb +0 -42
- data/generator_files/Thorfile.erb +0 -11
- data/generator_files/Vagrantfile.erb +0 -117
- data/generator_files/chefignore +0 -94
- data/generator_files/default_recipe.erb +0 -6
- data/generator_files/default_test.rb.erb +0 -11
- data/generator_files/gitignore.erb +0 -23
- data/generator_files/helpers.rb.erb +0 -7
- data/generator_files/licenses/apachev2.erb +0 -13
- data/generator_files/licenses/gplv2.erb +0 -15
- data/generator_files/licenses/gplv3.erb +0 -14
- data/generator_files/licenses/mit.erb +0 -20
- data/generator_files/licenses/reserved.erb +0 -3
- data/generator_files/metadata.rb.erb +0 -11
- data/lib/berkshelf/base_generator.rb +0 -43
- data/lib/berkshelf/commands/test_command.rb +0 -13
- data/lib/berkshelf/cookbook_generator.rb +0 -133
- data/lib/berkshelf/init_generator.rb +0 -195
- data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
- data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
- data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
@@ -0,0 +1,51 @@
|
|
1
|
+
require "chef-config/config"
|
2
|
+
require "chef-config/workstation_config_loader"
|
3
|
+
require "socket" unless defined?(Socket) # FIXME: why?
|
4
|
+
|
5
|
+
module Berkshelf
|
6
|
+
class ChefConfigCompat
|
7
|
+
# Create a new Chef Config object.
|
8
|
+
#
|
9
|
+
# @param [#to_s] path
|
10
|
+
# the path to the configuration file
|
11
|
+
# @param [Hash] options
|
12
|
+
def initialize(path, options = {})
|
13
|
+
ChefConfig::WorkstationConfigLoader.new(path).load
|
14
|
+
ChefConfig::Config.merge!(options)
|
15
|
+
ChefConfig::Config.export_proxies # Set proxy settings as environment variables
|
16
|
+
ChefConfig::Config.init_openssl # setup openssl + fips mode
|
17
|
+
end
|
18
|
+
|
19
|
+
# Keep defaults that aren't in ChefConfig::Config
|
20
|
+
def cookbook_copyright(*args, &block)
|
21
|
+
ChefConfig::Config.cookbook_copyright(*args, &block) || "YOUR_NAME"
|
22
|
+
end
|
23
|
+
|
24
|
+
def cookbook_email(*args, &block)
|
25
|
+
ChefConfig::Config.cookbook_email(*args, &block) || "YOUR_EMAIL"
|
26
|
+
end
|
27
|
+
|
28
|
+
def cookbook_license(*args, &block)
|
29
|
+
ChefConfig::Config.cookbook_license(*args, &block) || "reserved"
|
30
|
+
end
|
31
|
+
|
32
|
+
# The configuration as a hash
|
33
|
+
def to_hash
|
34
|
+
ChefConfig::Config.save(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Load from a file
|
38
|
+
def self.from_file(file)
|
39
|
+
new(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Behave just like ChefConfig::Config in general
|
43
|
+
def method_missing(name, *args, &block)
|
44
|
+
ChefConfig::Config.send(name, *args, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def respond_to_missing?(name)
|
48
|
+
ChefConfig::Config.respond_to?(name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative "api_client/remote_cookbook"
|
2
|
+
require_relative "cached_cookbook"
|
3
|
+
|
4
|
+
module Berkshelf
|
5
|
+
# Shim to look like a Berkshelf::APIClient but for a chef repo folder.
|
6
|
+
#
|
7
|
+
# @since 6.1
|
8
|
+
class ChefRepoUniverse
|
9
|
+
def initialize(uri, **options)
|
10
|
+
@uri = uri
|
11
|
+
@path = options[:path]
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def universe
|
16
|
+
Dir.entries(cookbooks_path).sort.each_with_object([]) do |entry, cookbooks|
|
17
|
+
next if entry[0] == "." # Skip hidden folders.
|
18
|
+
|
19
|
+
entry_path = "#{cookbooks_path}/#{entry}"
|
20
|
+
next unless File.directory?(entry_path) # Skip non-dirs.
|
21
|
+
|
22
|
+
cookbook = begin
|
23
|
+
Berkshelf::CachedCookbook.from_path(entry_path)
|
24
|
+
rescue IOError
|
25
|
+
next # It wasn't a cookbook.
|
26
|
+
end
|
27
|
+
cookbooks << Berkshelf::APIClient::RemoteCookbook.new(
|
28
|
+
cookbook.cookbook_name,
|
29
|
+
cookbook.version,
|
30
|
+
location_type: "file_store",
|
31
|
+
location_path: entry_path,
|
32
|
+
dependencies: cookbook.metadata.dependencies
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def cookbooks_path
|
40
|
+
if File.exist?("#{@path}/cookbooks")
|
41
|
+
"#{@path}/cookbooks"
|
42
|
+
else
|
43
|
+
@path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative 'cookbook_generator'
|
5
|
-
require_relative 'commands/shelf'
|
6
|
-
require_relative 'commands/test_command'
|
1
|
+
require_relative "../berkshelf"
|
2
|
+
require_relative "config"
|
3
|
+
require_relative "commands/shelf"
|
7
4
|
|
8
5
|
module Berkshelf
|
9
6
|
class Cli < Thor
|
@@ -19,22 +16,20 @@ module Berkshelf
|
|
19
16
|
end
|
20
17
|
|
21
18
|
def execute!
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@kernel.exit(47)
|
37
|
-
end
|
19
|
+
$stdin = @stdin
|
20
|
+
$stdout = @stdout
|
21
|
+
$stderr = @stderr
|
22
|
+
|
23
|
+
Berkshelf::Cli.start(@argv)
|
24
|
+
@kernel.exit(0)
|
25
|
+
rescue Berkshelf::BerkshelfError => e
|
26
|
+
Berkshelf.ui.error e
|
27
|
+
Berkshelf.ui.error "\t" + e.backtrace.join("\n\t") if ENV["BERKSHELF_DEBUG"]
|
28
|
+
@kernel.exit(e.status_code)
|
29
|
+
rescue => e
|
30
|
+
Berkshelf.ui.error "#{e.class} #{e}"
|
31
|
+
Berkshelf.ui.error "\t" + e.backtrace.join("\n\t") if ENV["BERKSHELF_DEBUG"]
|
32
|
+
@kernel.exit(47)
|
38
33
|
end
|
39
34
|
end
|
40
35
|
|
@@ -43,14 +38,14 @@ module Berkshelf
|
|
43
38
|
if given_args.length > 1 && !(given_args & Thor::HELP_MAPPINGS).empty?
|
44
39
|
command = given_args.first
|
45
40
|
|
46
|
-
if
|
47
|
-
super(meth, [command,
|
41
|
+
if subcommands.include?(command)
|
42
|
+
super(meth, [command, "help"].compact, nil, config)
|
48
43
|
else
|
49
|
-
super(meth, [
|
44
|
+
super(meth, ["help", command].compact, nil, config)
|
50
45
|
end
|
51
46
|
else
|
52
47
|
super
|
53
|
-
Berkshelf.formatter.cleanup_hook unless config[:current_command].name ==
|
48
|
+
Berkshelf.formatter.cleanup_hook unless config[:current_command].name == "help"
|
54
49
|
end
|
55
50
|
end
|
56
51
|
end
|
@@ -79,66 +74,59 @@ module Berkshelf
|
|
79
74
|
@options = options.dup # unfreeze frozen options Hash from Thor
|
80
75
|
end
|
81
76
|
|
82
|
-
namespace
|
77
|
+
namespace "berkshelf"
|
83
78
|
|
84
|
-
map
|
85
|
-
map
|
86
|
-
map
|
87
|
-
map
|
88
|
-
map
|
89
|
-
map [
|
79
|
+
map "in" => :install
|
80
|
+
map "up" => :upload
|
81
|
+
map "ud" => :update
|
82
|
+
map "ls" => :list
|
83
|
+
map "book" => :cookbook
|
84
|
+
map ["ver", "-v", "--version"] => :version
|
90
85
|
|
91
86
|
default_task :install
|
92
87
|
|
93
88
|
class_option :config,
|
94
89
|
type: :string,
|
95
|
-
desc:
|
96
|
-
aliases:
|
97
|
-
banner:
|
90
|
+
desc: "Path to Berkshelf configuration to use.",
|
91
|
+
aliases: "-c",
|
92
|
+
banner: "PATH"
|
98
93
|
class_option :format,
|
99
94
|
type: :string,
|
100
|
-
default:
|
101
|
-
desc:
|
102
|
-
aliases:
|
103
|
-
banner:
|
95
|
+
default: "human",
|
96
|
+
desc: "Output format to use.",
|
97
|
+
aliases: "-F",
|
98
|
+
banner: "FORMAT"
|
104
99
|
class_option :quiet,
|
105
100
|
type: :boolean,
|
106
|
-
desc:
|
107
|
-
aliases:
|
101
|
+
desc: "Silence all informational output.",
|
102
|
+
aliases: "-q",
|
108
103
|
default: false
|
109
104
|
class_option :debug,
|
110
105
|
type: :boolean,
|
111
|
-
desc:
|
112
|
-
aliases:
|
106
|
+
desc: "Output debug information",
|
107
|
+
aliases: "-d",
|
113
108
|
default: false
|
114
109
|
|
115
110
|
method_option :except,
|
116
111
|
type: :array,
|
117
|
-
desc:
|
118
|
-
aliases:
|
112
|
+
desc: "Exclude cookbooks that are in these groups.",
|
113
|
+
aliases: "-e"
|
119
114
|
method_option :only,
|
120
115
|
type: :array,
|
121
|
-
desc:
|
122
|
-
aliases:
|
116
|
+
desc: "Only cookbooks that are in these groups.",
|
117
|
+
aliases: "-o"
|
123
118
|
method_option :berksfile,
|
124
119
|
type: :string,
|
125
120
|
default: nil,
|
126
|
-
desc:
|
127
|
-
aliases:
|
128
|
-
banner:
|
121
|
+
desc: "Path to a Berksfile to operate off of.",
|
122
|
+
aliases: "-b",
|
123
|
+
banner: "PATH"
|
129
124
|
method_option :path,
|
130
125
|
type: :string,
|
131
|
-
aliases:
|
126
|
+
aliases: "-p",
|
132
127
|
hide: true
|
133
|
-
desc
|
128
|
+
desc "install", "Install the cookbooks specified in the Berksfile"
|
134
129
|
def install
|
135
|
-
if options[:path]
|
136
|
-
# TODO: Remove in Berkshelf 4.0
|
137
|
-
Berkshelf.formatter.deprecation "`berks install --path [PATH]` has been replaced by `berks vendor`."
|
138
|
-
Berkshelf.formatter.deprecation "Re-run your command as `berks vendor [PATH]` or see `berks help vendor`."
|
139
|
-
exit(1)
|
140
|
-
end
|
141
|
-
|
142
130
|
berksfile = Berksfile.from_options(options)
|
143
131
|
berksfile.install
|
144
132
|
end
|
@@ -146,18 +134,18 @@ module Berkshelf
|
|
146
134
|
method_option :berksfile,
|
147
135
|
type: :string,
|
148
136
|
default: nil,
|
149
|
-
desc:
|
150
|
-
aliases:
|
151
|
-
banner:
|
137
|
+
desc: "Path to a Berksfile to operate off of.",
|
138
|
+
aliases: "-b",
|
139
|
+
banner: "PATH"
|
152
140
|
method_option :except,
|
153
141
|
type: :array,
|
154
|
-
desc:
|
155
|
-
aliases:
|
142
|
+
desc: "Exclude cookbooks that are in these groups.",
|
143
|
+
aliases: "-e"
|
156
144
|
method_option :only,
|
157
145
|
type: :array,
|
158
|
-
desc:
|
159
|
-
aliases:
|
160
|
-
desc
|
146
|
+
desc: "Only cookbooks that are in these groups.",
|
147
|
+
aliases: "-o"
|
148
|
+
desc "update [COOKBOOKS]", "Update the cookbooks (and dependencies) specified in the Berksfile"
|
161
149
|
def update(*cookbook_names)
|
162
150
|
berksfile = Berksfile.from_options(options)
|
163
151
|
berksfile.update(*cookbook_names)
|
@@ -166,70 +154,69 @@ module Berkshelf
|
|
166
154
|
method_option :berksfile,
|
167
155
|
type: :string,
|
168
156
|
default: nil,
|
169
|
-
desc:
|
170
|
-
aliases:
|
171
|
-
banner:
|
157
|
+
desc: "Path to a Berksfile to operate off of.",
|
158
|
+
aliases: "-b",
|
159
|
+
banner: "PATH"
|
172
160
|
method_option :except,
|
173
161
|
type: :array,
|
174
|
-
desc:
|
175
|
-
aliases:
|
162
|
+
desc: "Exclude cookbooks that are in these groups.",
|
163
|
+
aliases: "-e"
|
176
164
|
method_option :only,
|
177
165
|
type: :array,
|
178
|
-
desc:
|
179
|
-
aliases:
|
166
|
+
desc: "Only cookbooks that are in these groups.",
|
167
|
+
aliases: "-o"
|
180
168
|
method_option :no_freeze,
|
181
169
|
type: :boolean,
|
182
170
|
default: false,
|
183
|
-
desc:
|
171
|
+
desc: "Do not freeze uploaded cookbook(s)."
|
184
172
|
method_option :force,
|
185
173
|
type: :boolean,
|
186
174
|
default: false,
|
187
|
-
desc:
|
175
|
+
desc: "Upload all cookbooks even if a frozen one exists on the Chef Server."
|
188
176
|
method_option :ssl_verify,
|
189
177
|
type: :boolean,
|
190
178
|
default: nil,
|
191
|
-
desc:
|
179
|
+
desc: "Disable/Enable SSL verification when uploading cookbooks."
|
192
180
|
method_option :skip_syntax_check,
|
193
181
|
type: :boolean,
|
194
182
|
default: false,
|
195
|
-
desc:
|
196
|
-
aliases:
|
183
|
+
desc: "Skip Ruby syntax check when uploading cookbooks.",
|
184
|
+
aliases: "-s"
|
197
185
|
method_option :halt_on_frozen,
|
198
186
|
type: :boolean,
|
199
187
|
default: false,
|
200
|
-
desc:
|
201
|
-
desc
|
188
|
+
desc: "Exit with a non zero exit code if the Chef Server already has the version of the cookbook(s)."
|
189
|
+
desc "upload [COOKBOOKS]", "Upload the cookbook specified in the Berksfile to the Chef Server"
|
202
190
|
def upload(*names)
|
203
191
|
berksfile = Berksfile.from_options(options)
|
204
192
|
|
205
193
|
options[:freeze] = !options[:no_freeze]
|
206
194
|
options[:validate] = false if options[:skip_syntax_check]
|
207
|
-
|
208
|
-
berksfile.upload(names, options.symbolize_keys)
|
195
|
+
berksfile.upload(names, options.each_with_object({}) { |(k, v), m| m[k.to_sym] = v })
|
209
196
|
end
|
210
197
|
|
211
198
|
method_option :envfile,
|
212
199
|
type: :string,
|
213
|
-
desc:
|
214
|
-
aliases:
|
200
|
+
desc: "Path to a JSON environment file to update.",
|
201
|
+
aliases: "-f"
|
215
202
|
method_option :lockfile,
|
216
203
|
type: :string,
|
217
204
|
default: Berkshelf::Lockfile::DEFAULT_FILENAME,
|
218
|
-
desc:
|
219
|
-
aliases:
|
220
|
-
banner:
|
205
|
+
desc: "Path to a Berksfile.lock to operate off of.",
|
206
|
+
aliases: "-b",
|
207
|
+
banner: "PATH"
|
221
208
|
method_option :ssl_verify,
|
222
209
|
type: :boolean,
|
223
210
|
default: nil,
|
224
|
-
desc:
|
225
|
-
desc
|
211
|
+
desc: "Disable/Enable SSL verification when locking cookbooks."
|
212
|
+
desc "apply ENVIRONMENT", "Apply version locks from Berksfile.lock to a Chef environment"
|
226
213
|
def apply(environment_name)
|
227
214
|
unless File.exist?(options[:lockfile])
|
228
215
|
raise LockfileNotFound, "No lockfile found at #{options[:lockfile]}"
|
229
216
|
end
|
230
217
|
|
231
218
|
lockfile = Lockfile.from_file(options[:lockfile])
|
232
|
-
lock_options = Hash[options].
|
219
|
+
lock_options = Hash[options].each_with_object({}) { |(k, v), m| m[k.to_sym] = v }
|
233
220
|
|
234
221
|
lockfile.apply(environment_name, lock_options)
|
235
222
|
end
|
@@ -237,66 +224,56 @@ module Berkshelf
|
|
237
224
|
method_option :berksfile,
|
238
225
|
type: :string,
|
239
226
|
default: nil,
|
240
|
-
desc:
|
241
|
-
aliases:
|
242
|
-
banner:
|
227
|
+
desc: "Path to a Berksfile to operate off of.",
|
228
|
+
aliases: "-b",
|
229
|
+
banner: "PATH"
|
243
230
|
method_option :except,
|
244
231
|
type: :array,
|
245
|
-
desc:
|
246
|
-
aliases:
|
232
|
+
desc: "Exclude cookbooks that are in these groups.",
|
233
|
+
aliases: "-e"
|
247
234
|
method_option :only,
|
248
235
|
type: :array,
|
249
|
-
desc:
|
250
|
-
aliases:
|
251
|
-
|
236
|
+
desc: "Only cookbooks that are in these groups.",
|
237
|
+
aliases: "-o"
|
238
|
+
method_option :all,
|
239
|
+
type: :boolean,
|
240
|
+
desc: "Include cookbooks that don't satisfy the version constraints.",
|
241
|
+
aliases: "-a",
|
242
|
+
default: false
|
243
|
+
desc "outdated [COOKBOOKS]", "List dependencies that have new versions available that satisfy their constraints"
|
252
244
|
def outdated(*names)
|
253
245
|
berksfile = Berksfile.from_options(options)
|
254
|
-
outdated = berksfile.outdated(*names)
|
246
|
+
outdated = berksfile.outdated(*names, include_non_satisfying: options[:all])
|
255
247
|
Berkshelf.formatter.outdated(outdated)
|
256
248
|
end
|
257
249
|
|
258
250
|
method_option :source,
|
259
251
|
type: :string,
|
260
252
|
default: Berksfile::DEFAULT_API_URL,
|
261
|
-
desc:
|
262
|
-
banner:
|
263
|
-
desc
|
253
|
+
desc: "URL to search for sources",
|
254
|
+
banner: "URL"
|
255
|
+
desc "search NAME", "Search the remote source for cookbooks matching the partial name"
|
264
256
|
def search(name)
|
265
|
-
source = Source.new(options[:source])
|
257
|
+
source = Source.new(nil, options[:source])
|
266
258
|
cookbooks = source.search(name)
|
267
259
|
Berkshelf.formatter.search(cookbooks)
|
268
260
|
end
|
269
261
|
|
270
|
-
desc 'init [PATH]', 'Initialize Berkshelf in the given directory'
|
271
|
-
def init(path = '.')
|
272
|
-
Berkshelf.formatter.deprecation <<EOF
|
273
|
-
This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
|
274
|
-
Please use `chef generate cookbook` instead of this command.
|
275
|
-
EOF
|
276
|
-
Berkshelf.formatter.deprecation '--git is now the default' if options[:git]
|
277
|
-
Berkshelf.formatter.deprecation '--vagrant is now the default' if options[:vagrant]
|
278
|
-
|
279
|
-
Berkshelf::InitGenerator.new([path], options).invoke_all
|
280
|
-
|
281
|
-
Berkshelf.formatter.msg 'Successfully initialized'
|
282
|
-
end
|
283
|
-
tasks['init'].options = Berkshelf::InitGenerator.class_options
|
284
|
-
|
285
262
|
method_option :berksfile,
|
286
263
|
type: :string,
|
287
264
|
default: nil,
|
288
|
-
desc:
|
289
|
-
aliases:
|
290
|
-
banner:
|
265
|
+
desc: "Path to a Berksfile to operate off of.",
|
266
|
+
aliases: "-b",
|
267
|
+
banner: "PATH"
|
291
268
|
method_option :except,
|
292
269
|
type: :array,
|
293
|
-
desc:
|
294
|
-
aliases:
|
270
|
+
desc: "Exclude cookbooks that are in these groups.",
|
271
|
+
aliases: "-e"
|
295
272
|
method_option :only,
|
296
273
|
type: :array,
|
297
|
-
desc:
|
298
|
-
aliases:
|
299
|
-
desc
|
274
|
+
desc: "Only cookbooks that are in these groups.",
|
275
|
+
aliases: "-o"
|
276
|
+
desc "list", "List cookbooks and their dependencies specified by your Berksfile"
|
300
277
|
def list
|
301
278
|
berksfile = Berksfile.from_options(options)
|
302
279
|
Berkshelf.formatter.list(berksfile.list)
|
@@ -331,10 +308,10 @@ EOF
|
|
331
308
|
method_option :berksfile,
|
332
309
|
type: :string,
|
333
310
|
default: nil,
|
334
|
-
desc:
|
335
|
-
aliases:
|
336
|
-
banner:
|
337
|
-
desc
|
311
|
+
desc: "Path to a Berksfile to operate off of.",
|
312
|
+
aliases: "-b",
|
313
|
+
banner: "PATH"
|
314
|
+
desc "contingent COOKBOOK", "List all cookbooks that depend on the given cookbook in your Berksfile"
|
338
315
|
def contingent(name)
|
339
316
|
berksfile = Berksfile.from_options(options)
|
340
317
|
dependencies = berksfile.cookbooks.select do |cookbook|
|
@@ -352,9 +329,9 @@ EOF
|
|
352
329
|
method_option :berksfile,
|
353
330
|
type: :string,
|
354
331
|
default: nil,
|
355
|
-
desc:
|
356
|
-
aliases:
|
357
|
-
banner:
|
332
|
+
desc: "Path to a Berksfile to operate off of.",
|
333
|
+
aliases: "-b",
|
334
|
+
banner: "PATH"
|
358
335
|
method_option :except,
|
359
336
|
type: :array,
|
360
337
|
desc: "Exclude cookbooks that are in these groups.",
|
@@ -377,22 +354,22 @@ EOF
|
|
377
354
|
|
378
355
|
method_option :except,
|
379
356
|
type: :array,
|
380
|
-
desc:
|
381
|
-
aliases:
|
357
|
+
desc: "Exclude cookbooks that are in these groups.",
|
358
|
+
aliases: "-e"
|
382
359
|
method_option :delete,
|
383
360
|
type: :boolean,
|
384
361
|
desc: "Clean the target directory before vendoring",
|
385
362
|
default: false
|
386
363
|
method_option :only,
|
387
364
|
type: :array,
|
388
|
-
desc:
|
389
|
-
aliases:
|
365
|
+
desc: "Only cookbooks that are in these groups.",
|
366
|
+
aliases: "-o"
|
390
367
|
method_option :berksfile,
|
391
368
|
type: :string,
|
392
369
|
default: nil,
|
393
|
-
desc:
|
394
|
-
aliases:
|
395
|
-
banner:
|
370
|
+
desc: "Path to a Berksfile to operate off of.",
|
371
|
+
aliases: "-b",
|
372
|
+
banner: "PATH"
|
396
373
|
desc "vendor [PATH]", "Vendor the cookbooks specified by the Berksfile into a directory"
|
397
374
|
def vendor(path = File.join(Dir.pwd, "berks-cookbooks"))
|
398
375
|
berksfile = Berkshelf::Berksfile.from_options(options)
|
@@ -412,53 +389,45 @@ EOF
|
|
412
389
|
method_option :berksfile,
|
413
390
|
type: :string,
|
414
391
|
default: nil,
|
415
|
-
desc:
|
416
|
-
aliases:
|
417
|
-
banner:
|
392
|
+
desc: "Path to a Berksfile to operate off of.",
|
393
|
+
aliases: "-b",
|
394
|
+
banner: "PATH"
|
418
395
|
method_option :outfile,
|
419
396
|
type: :string,
|
420
|
-
default:
|
421
|
-
desc:
|
422
|
-
aliases:
|
423
|
-
banner:
|
397
|
+
default: "graph.png",
|
398
|
+
desc: "The name of the output file",
|
399
|
+
aliases: "-o",
|
400
|
+
banner: "NAME"
|
401
|
+
method_option :outfile_format,
|
402
|
+
type: :string,
|
403
|
+
default: "png",
|
404
|
+
desc: "The format of the output file, either png or dot.",
|
405
|
+
aliases: "-f",
|
406
|
+
banner: "FORMAT"
|
424
407
|
desc "viz", "Visualize the dependency graph"
|
425
408
|
def viz
|
426
409
|
berksfile = Berksfile.from_options(options)
|
427
|
-
path = berksfile.viz(options[:outfile])
|
410
|
+
path = berksfile.viz(options[:outfile], options[:outfile_format])
|
428
411
|
|
429
412
|
Berkshelf.ui.info(path)
|
430
413
|
end
|
431
414
|
|
432
|
-
desc
|
415
|
+
desc "version", "Display version"
|
433
416
|
def version
|
434
417
|
Berkshelf.formatter.version
|
435
418
|
end
|
436
419
|
|
437
|
-
desc 'cookbook NAME [PATH]', 'Create a skeleton for a new cookbook'
|
438
|
-
def cookbook(name, path = nil)
|
439
|
-
Berkshelf.formatter.deprecation <<EOF
|
440
|
-
This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
|
441
|
-
Please use `chef generate cookbook` instead of this command.
|
442
|
-
EOF
|
443
|
-
path = File.join(Dir.pwd, name) if path.nil?
|
444
|
-
Berkshelf.formatter.deprecation '--git is now the default' if options[:git]
|
445
|
-
Berkshelf.formatter.deprecation '--vagrant is now the default' if options[:vagrant]
|
446
|
-
|
447
|
-
Berkshelf::CookbookGenerator.new([path, name], options).invoke_all
|
448
|
-
end
|
449
|
-
tasks['cookbook'].options = Berkshelf::CookbookGenerator.class_options
|
450
|
-
|
451
420
|
private
|
452
421
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
end
|
422
|
+
# Print a list of the given cookbooks. This is used by various
|
423
|
+
# methods like {list} and {contingent}.
|
424
|
+
#
|
425
|
+
# @param [Array<CachedCookbook>] cookbooks
|
426
|
+
#
|
427
|
+
def print_list(cookbooks)
|
428
|
+
Array(cookbooks).sort.each do |cookbook|
|
429
|
+
Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
|
462
430
|
end
|
431
|
+
end
|
463
432
|
end
|
464
433
|
end
|