Class: Fhcap::Tasks::Chef::Cookbook::CheckBumps
- Inherits:
-
Fhcap::Tasks::Chef::ChefTaskBase
- Object
- TaskBase
- Fhcap::Tasks::Chef::ChefTaskBase
- Fhcap::Tasks::Chef::Cookbook::CheckBumps
- Defined in:
- lib/fhcap/tasks/chef/cookbook/check_bumps.rb
Instance Attribute Summary collapse
-
#base_branch ⇒ Object
readonly
Returns the value of attribute base_branch.
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ CheckBumps
constructor
A new instance of CheckBumps.
- #run ⇒ Object
Methods inherited from Fhcap::Tasks::Chef::ChefTaskBase
#knife_config_dir, #knife_config_file_for, #run_chef_client_cmd, #run_knife_cmd, #run_knife_ssh_cmd
Methods inherited from TaskBase
#ask_config, #color_pad, #exit_with_error, #set_color, #suppress_stdout, #table_header, #table_row, #with_progress
Methods included from KnifeHelper
#chef_server_config_for, #chef_server_config_hash_for, #chef_server_names, #delete_chef_object, #knife_config, #knife_config_dir, #knife_config_file_for, #knife_data_bag_delete, #knife_download, #knife_environment_delete, #knife_upload, #local_chef_server?, #with_chef_server, #with_local_chef_server
Methods included from ProvidersHelper
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
Methods included from ReposHelper
#find_cluster, #find_cluster_pwds, #find_cluster_pwds_with_repo, #find_cluster_with_repo, #find_data_bag, #find_data_bag_item, #find_environment, #find_repo_item, #find_role, #get_cookbook_deps, #get_cookbook_meta, #get_cookbook_versions, #get_cookbooks, #get_dirty_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #git_diff, #is_dirty?, #modified?, #repo_cfg, #repo_clusters_dir, #repo_cookbook_paths, #repo_dir, #repo_names, #repo_paths, #repos_config, #repos_dir, #run_inside_repo_dir
Methods included from FhcapHelper
Constructor Details
#initialize(options) ⇒ CheckBumps
Returns a new instance of CheckBumps.
11 12 13 14 |
# File 'lib/fhcap/tasks/chef/cookbook/check_bumps.rb', line 11 def initialize() super @base_branch = [:base_branch] end |
Instance Attribute Details
#base_branch ⇒ Object (readonly)
Returns the value of attribute base_branch.
9 10 11 |
# File 'lib/fhcap/tasks/chef/cookbook/check_bumps.rb', line 9 def base_branch @base_branch end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fhcap/tasks/chef/cookbook/check_bumps.rb', line 16 def run cookbooks = get_cookbooks(, nil, repo_cookbook_paths('-cookbooks')) thor.say("Cookbook Check Bumps for #{cookbooks}", :yellow) errors = [] cookbooks.each do |c| cookbook = cookbook_loader.cookbooks_by_name[c] = cookbook..first if not File.exist?() thor.say("#{cookbook.name} no longer seems to exist", :yellow) next elsif is_new_since?(base_branch, ) thor.say("#{cookbook.name} seems to be a new cookbook, not checking", :yellow) next end version = cookbook.version oldversion = get_old_cookbook_version(base_branch, , version) if base_branch =~ /master$/ min = next_minor_version(oldversion) if minor_bumped_incorrectly?(version, min) errors << "#{cookbook.name} is at version #{version}, but should be at least #{min} and not be incremented at the patch level" end else min = next_patch_version(oldversion) too_high = next_minor_version(oldversion) if patch_bumped_incorrectly?(version, min, too_high) errors << "#{cookbook.name} is at version #{version}, but should be at least #{min} and less than #{too_high}" end end end unless errors.empty? thor.say("Incorrectly bumped cookbooks:", :red) errors.each { |error| puts error } thor.say("If you haven't changed these cookbooks, then your branch might be behind the base branch (#{base_branch}). In this case, rebasing should make these errors disappear.", :yellow) exit 1 end end |