diff options
author | Salim Alam <salam@chef.io> | 2016-02-05 15:09:17 -0800 |
---|---|---|
committer | Salim Alam <salam@chef.io> | 2016-02-09 15:05:05 -0800 |
commit | b4a0661e75108b641621e687d083dad1793334a0 (patch) | |
tree | 4e514cff6debd103035069acc5b21f64c6ad52d7 /acceptance/.shared/kitchen_acceptance | |
parent | 7755b93c72ef33d5041b6a9c4b53bcf29814579d (diff) | |
download | chef-b4a0661e75108b641621e687d083dad1793334a0.tar.gz |
WIP: Make cookbooks infra more generic
Diffstat (limited to 'acceptance/.shared/kitchen_acceptance')
-rw-r--r-- | acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb index 5380b7002c..e0f860851c 100644 --- a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb +++ b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb @@ -1,43 +1,45 @@ -class Kitchen < Chef::Resource - resource_name :kitchen +module KitchenAcceptance + class Kitchen < Chef::Resource + resource_name :kitchen - property :command, String, name_property: true - property :driver, %w(ec2 vagrant), coerce: proc { |v| v.to_s }, default: lazy { ENV["KITCHEN_DRIVER"] || :ec2 } - property :instances, String, default: lazy { ENV["KITCHEN_INSTANCES"] } - property :kitchen_dir, String, default: Chef.node['chef-acceptance']['suite-dir'] - property :chef_product, String, default: lazy { - ENV["KITCHEN_CHEF_PRODUCT"] || - # If we're running the chef or chefdk projects in jenkins, pick up the project name. - (%w(chef chefdk).include?(ENV["PROJECT_NAME"]) ? ENV["PROJECT_NAME"] : "chef") - } - property :chef_channel, String, default: lazy { - ENV["KITCHEN_CHEF_CHANNEL"] || - # Pick up current if we can't connect to artifactory - (ENV["ARTIFACTORY_USERNAME"] ? "unstable" : "current") - } - property :chef_version, String, default: lazy { - ENV["KITCHEN_CHEF_VERSION"] || - # If we're running the chef or chefdk projects in jenkins, pick up the project name. - (ENV["PROJECT_NAME"] == chef_product ? ENV["OMNIBUS_BUILD_VERSION"] : nil) || - "latest" - } - property :artifactory_username, String, default: lazy { ENV["ARTIFACTORY_USERNAME"] } - property :artifactory_password, String, default: lazy { ENV["ARTIFACTORY_PASSWORD"] } - property :env, Hash, default: {} + property :command, String, name_property: true + property :driver, %w(ec2 vagrant), coerce: proc { |v| v.to_s }, default: lazy { ENV["KITCHEN_DRIVER"] || :ec2 } + property :instances, String, default: lazy { ENV["KITCHEN_INSTANCES"] } + property :kitchen_dir, String, default: Chef.node['chef-acceptance']['suite-dir'] + property :chef_product, String, default: lazy { + ENV["KITCHEN_CHEF_PRODUCT"] || + # If we're running the chef or chefdk projects in jenkins, pick up the project name. + (%w(chef chefdk).include?(ENV["PROJECT_NAME"]) ? ENV["PROJECT_NAME"] : "chef") + } + property :chef_channel, String, default: lazy { + ENV["KITCHEN_CHEF_CHANNEL"] || + # Pick up current if we can't connect to artifactory + (ENV["ARTIFACTORY_USERNAME"] ? "unstable" : "current") + } + property :chef_version, String, default: lazy { + ENV["KITCHEN_CHEF_VERSION"] || + # If we're running the chef or chefdk projects in jenkins, pick up the project name. + (ENV["PROJECT_NAME"] == chef_product ? ENV["OMNIBUS_BUILD_VERSION"] : nil) || + "latest" + } + property :artifactory_username, String, default: lazy { ENV["ARTIFACTORY_USERNAME"] } + property :artifactory_password, String, default: lazy { ENV["ARTIFACTORY_PASSWORD"] } + property :env, Hash, default: {} - action :run do - execute "bundle exec kitchen #{command}#{instances ? " #{instances}" : ""}" do - cwd kitchen_dir - env({ - "KITCHEN_DRIVER" => driver, - "KITCHEN_INSTANCES" => instances, - "KITCHEN_LOCAL_YAML" => ::File.expand_path("../../.kitchen.#{driver}.yml", __FILE__), - "KITCHEN_CHEF_PRODUCT" => chef_product, - "KITCHEN_CHEF_CHANNEL" => chef_channel, - "KITCHEN_CHEF_VERSION" => chef_version, - "ARTIFACTORY_USERNAME" => artifactory_username, - "ARTIFACTORY_PASSWORD" => artifactory_password - }.merge(new_resource.env)) + action :run do + execute "bundle exec kitchen #{command}#{instances ? " #{instances}" : ""}" do + cwd kitchen_dir + env({ + "KITCHEN_DRIVER" => driver, + "KITCHEN_INSTANCES" => instances, + "KITCHEN_LOCAL_YAML" => ::File.expand_path("../../.kitchen.#{driver}.yml", __FILE__), + "KITCHEN_CHEF_PRODUCT" => chef_product, + "KITCHEN_CHEF_CHANNEL" => chef_channel, + "KITCHEN_CHEF_VERSION" => chef_version, + "ARTIFACTORY_USERNAME" => artifactory_username, + "ARTIFACTORY_PASSWORD" => artifactory_password + }.merge(new_resource.env)) + end end end end |