Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
require:
- cookstyle

AllCops:
TargetRubyVersion: 3.1
Include:
Expand Down
37 changes: 37 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Project Guidelines

## Overview

kitchen-openstack is a Test Kitchen driver for OpenStack. It provisions and destroys Nova instances using the Fog OpenStack library.

## Code Style

- Ruby 3.1+ required
- All files must start with `# frozen_string_literal: true`
- Follow Cookstyle (Chef's RuboCop) conventions — config in `.rubocop.yml`
- Spec files are excluded from linting

## Architecture

- Driver class: `Kitchen::Driver::Openstack` in `lib/kitchen/driver/openstack.rb` — extends `Kitchen::Driver::Base` (Driver API v2)
- Volume handling: `Kitchen::Driver::Openstack::Volume` in `lib/kitchen/driver/openstack/volume.rb`
- Version constant: `OPENSTACK_VERSION` in `lib/kitchen/driver/openstack_version.rb` — used by gemspec and release automation
- Configuration uses `default_config` declarations; raise `Kitchen::ActionFailed` for driver errors

## Build and Test

```bash
bundle install
bundle exec rake # runs tests + style + stats (default)
bundle exec rake test # unit tests only (RSpec)
bundle exec rake style # Cookstyle lint
bundle exec rake quality # style + stats
```

## Conventions

- Use `Fog::OpenStack::Compute` and `Fog::OpenStack::Network` for cloud interactions
- Thread safety: use `Mutex` for shared resource pools (e.g., floating IP allocation)
- Resource finders (`find_image`, `find_flavor`, `find_network`) support regex matching via `/pattern/` syntax
- Test with RSpec 3 using `let` fixtures, `double` mocks, and `allow_any_instance_of` for Kitchen internals
- Release automation via Release Please — version bumps go in `lib/kitchen/driver/openstack_version.rb`
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in kitchen-openstack.gemspec
gemspec

group :test do
gem "rake"
gem "kitchen-inspec"
gem "rspec", "~> 3.2"
gem "countloc"
gem 'rake'
gem 'kitchen-inspec'
gem 'rspec', '~> 3.2'
gem 'countloc'
end

group :debug do
gem "pry"
gem 'pry'
end

group :cookstyle do
gem "cookstyle"
gem 'cookstyle'
end
28 changes: 14 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:unit)

desc "Run all test suites"
desc 'Run all test suites'
task test: [:unit]

desc "Display LOC stats"
desc 'Display LOC stats'
task :stats do
puts "\n## Production Code Stats"
sh "countloc -r lib"
sh 'countloc -r lib'
puts "\n## Test Code Stats"
sh "countloc -r spec"
sh 'countloc -r spec'
end

begin
require "cookstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--chefstyle", "--display-cop-names", "--no-color"]
require 'cookstyle'
desc 'Run cookstyle with chefstyle rules'
task :style do
sh 'cookstyle --chefstyle --display-cop-names'
end
rescue LoadError
puts "cookstyle is not available. gem install cookstyle to do style checking."
puts 'cookstyle is not available. gem install cookstyle to do style checking.'
end

desc "Run all quality tasks"
task quality: %i{style stats}
desc 'Run all quality tasks'
task quality: %i(style stats)

task default: %i{test quality}
task default: %i(test quality)
28 changes: 14 additions & 14 deletions kitchen-openstack.gemspec
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# frozen_string_literal: true

lib = File.expand_path("lib", __dir__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "kitchen/driver/openstack_version"
require 'kitchen/driver/openstack_version'

Gem::Specification.new do |spec|
spec.name = "kitchen-openstack"
spec.name = 'kitchen-openstack'
spec.version = Kitchen::Driver::OPENSTACK_VERSION
spec.authors = ["Jonathan Hartman", "JJ Asghar"]
spec.email = ["j@p4nt5.com", "jj@chef.io"]
spec.description = "A Test Kitchen OpenStack Nova driver"
spec.authors = ['Jonathan Hartman', 'JJ Asghar']
spec.email = ['j@p4nt5.com', 'jj@chef.io']
spec.description = 'A Test Kitchen OpenStack Nova driver'
spec.summary = spec.description
spec.homepage = "https://github.com/test-kitchen/kitchen-openstack"
spec.license = "Apache-2.0"
spec.homepage = 'https://github.com/test-kitchen/kitchen-openstack'
spec.license = 'Apache-2.0'

spec.files = Dir["LICENSE", "README.md", "lib/**/*"]
spec.require_paths = ["lib"]
spec.files = Dir['LICENSE', 'README.md', 'lib/**/*']
spec.require_paths = ['lib']

spec.required_ruby_version = ">= 3.1"
spec.required_ruby_version = '>= 3.1'

spec.add_dependency "test-kitchen", ">= 1.4.1", "< 5"
spec.add_dependency "fog-openstack", "~> 1.0"
spec.add_dependency "ohai"
spec.add_dependency 'test-kitchen', '>= 1.4.1', '< 5'
spec.add_dependency 'fog-openstack', '~> 1.0'
spec.add_dependency 'ohai'
end
Loading
Loading