Skip to content

Commit

Permalink
Merge pull request #13 from chef/kitchen_init_change
Browse files Browse the repository at this point in the history
Kitchen init change
  • Loading branch information
sanghinitin authored Nov 11, 2024
2 parents a9b0f8e + ec59b06 commit c6aa6c8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Test Kitchen Change Log

<!-- usage documentation: https://expeditor.chef.io/docs/reference/changelog/#common-changelog -->
<!-- latest_release 1.0.0 -->
## [v1.0.0](https://github.com/chef/chef-test-kitchen-enterprise/tree/v1.0.0) (2024-11-11)

#### Merged Pull Requests
### Merged Pull Requests

- Rebranding Change and the new version and change.log file [#11](https://github.com/chef/chef-test-kitchen-enterprise/pull/11) ([sanghinitin](https://github.com/sanghinitin))

<!-- latest_release -->

<!-- release_rollup -->

### Changes not yet released to rubygems.org

#### Merged Pull Requests
### Merged Pull Requests

- Rebranding Change and the new version and change.log file [#11](https://github.com/chef/chef-test-kitchen-enterprise/pull/11) ([sanghinitin](https://github.com/sanghinitin)) <!-- 1.0.0 -->

<!-- release_rollup -->

<!-- latest_stable_release -->
Expand Down
39 changes: 24 additions & 15 deletions features/kitchen_init_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: Add Test Kitchen support to an existing project
And the file "kitchen.yml" should contain:
"""
driver:
name: vagrant
name: dokken
"""
And a file named "Gemfile" should not exist
And a file named "Rakefile" should not exist
Expand All @@ -40,7 +40,7 @@ Feature: Add Test Kitchen support to an existing project
Then the file "Gemfile" should contain "https://rubygems.org"
And the file "Gemfile" should contain:
"""
gem "test-kitchen"
gem "chef-test-kitchen-enterprise"
"""
And the output should contain "You must run `bundle install'"

Expand All @@ -56,7 +56,7 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem "test-kitchen"
gem "chef-test-kitchen-enterprise"
"""
And the output should contain "You must run `bundle install'"
Expand All @@ -67,15 +67,15 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem "chef-test-kitchen-enterprise"
"""
When I successfully run `kitchen init`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem "chef-test-kitchen-enterprise"
"""

Expand All @@ -85,7 +85,7 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem "chef-test-kitchen-enterprise"
gem 'kitchen-ec2'
"""
Expand All @@ -94,7 +94,7 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem "chef-test-kitchen-enterprise"
gem 'kitchen-ec2'
"""
Expand Down Expand Up @@ -122,13 +122,13 @@ Feature: Add Test Kitchen support to an existing project
"""

Scenario: Running init without a provisioner sets the default provisioner
to chef_solo in kitchen.yml
to dokken in kitchen.yml
Given an empty file named "Gemfile"
When I successfully run `kitchen init --no-driver`
Then the file "kitchen.yml" should contain:
"""
provisioner:
name: chef_solo
name: dokken
"""

Scenario: Running init with a provisioner sets the provisioner in kitchen.yml
Expand Down Expand Up @@ -190,10 +190,13 @@ Feature: Add Test Kitchen support to an existing project
"""
---
driver:
name: vagrant
name: dokken
provisioner:
name: chef_solo
name: dokken
transport:
name: dokken
platforms:
- name: ubuntu-20.04
Expand All @@ -214,10 +217,13 @@ Feature: Add Test Kitchen support to an existing project
"""
---
driver:
name: vagrant
name: dokken
provisioner:
name: chef_solo
name: dokken
transport:
name: dokken
platforms:
- name: ubuntu-20.04
Expand All @@ -237,10 +243,13 @@ Feature: Add Test Kitchen support to an existing project
"""
---
driver:
name: vagrant
name: dokken
provisioner:
name: chef_solo
name: dokken
transport:
name: dokken
platforms:
- name: ubuntu-20.04
Expand Down
16 changes: 12 additions & 4 deletions lib/kitchen/generator/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Init < Thor::Group
class_option :driver,
type: :array,
aliases: "-D",
default: %w{kitchen-vagrant},
default: %w{kitchen-dokken},
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
One or more Kitchen Driver gems to be installed or added to a
Gemfile
Expand All @@ -39,11 +39,18 @@ class Init < Thor::Group
class_option :provisioner,
type: :string,
aliases: "-P",
default: "chef_solo",
default: "dokken",
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
The default Kitchen Provisioner to use
D

class_option :transport,
type: :string,
aliases: "-T",
default: "dokken",
desc: <<-D.gsub(/^\s+/, "").tr("\n", " ")
The default Kitchen Transport to use
D
class_option :create_gemfile,
type: :boolean,
default: false,
Expand Down Expand Up @@ -81,6 +88,7 @@ def create_kitchen_yaml
template("kitchen.yml.erb", "kitchen.yml",
driver_plugin: driver_plugin.sub(/^kitchen-/, ""),
provisioner: options[:provisioner],
transport: options[:transport],
run_list: Array(run_list))
end

Expand Down Expand Up @@ -213,8 +221,8 @@ def create_gemfile_if_missing
#
# @api private
def add_gem_to_gemfile
if not_in_file?("Gemfile", /gem ('|")test-kitchen('|")/)
append_to_file("Gemfile", %{gem "test-kitchen"\n})
if not_in_file?("Gemfile", /gem ('|")chef-test-kitchen-enterprise('|")/)
append_to_file("Gemfile", %{gem "chef-test-kitchen-enterprise"\n})
@display_bundle_msg = true
end
end
Expand Down
2 changes: 1 addition & 1 deletion templates/driver/gemspec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'test-kitchen', '~> 1.0.0'
spec.add_dependency 'chef-test-kitchen-enterprise', '~> 1.0.0'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
Expand Down
3 changes: 3 additions & 0 deletions templates/init/kitchen.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ driver:
provisioner:
name: <%= config[:provisioner] %>

transport:
name: <%= config[:transport] %>

platforms:
- name: ubuntu-20.04
- name: centos-8
Expand Down

0 comments on commit c6aa6c8

Please sign in to comment.