From d0ab71bb68b203beb7a2ed4775325e6c7cfcf606 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Mon, 18 May 2020 05:16:06 -0400 Subject: [PATCH] Add support for VPCS, closes #75 --- CHANGELOG.md | 4 ++++ README.md | 19 +++++++++++++++++++ kitchen-digitalocean.gemspec | 2 +- lib/kitchen/driver/digitalocean.rb | 3 +++ lib/kitchen/driver/digitalocean_version.rb | 2 +- spec/kitchen/driver/digitalocean_spec.rb | 3 ++- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 834951a..8d65129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.11.0 / 2020-05-18 + +- Add support for VPC, closes issue #75 + # 0.10.7 / 2020-05-18 - [@vsingh-msys] [PR #77] Remove unsupported default image mapping diff --git a/README.md b/README.md index 6c2c546..a293e9f 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,25 @@ ocean API: curl -X GET https://api.digitalocean.com/v2/firewalls -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" ``` +# VPCS + +To create the droplet with a VPC (Virtual Private Cloud), provide a pre-existing VPC ID as a +string. + +``` ruby +driver: + vpcs: + - 3a92ae2d-f1b7-4589-81b8-8ef144374453 +``` + +Note that your 'vpc_uuid' must be the numeric ids of your vpc. To get the +numeric ID, use something like the following command to get them from the digital +ocean API: + +``` bash +curl -X GET https://api.digitalocean.com/v2/vpcs -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" +``` + # Development diff --git a/kitchen-digitalocean.gemspec b/kitchen-digitalocean.gemspec index b233567..123d749 100644 --- a/kitchen-digitalocean.gemspec +++ b/kitchen-digitalocean.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).grep(/LICENSE|^lib/) spec.require_paths = ['lib'] - spec.add_dependency 'droplet_kit', '>= 2.8', '< 4.0' + spec.add_dependency 'droplet_kit', '>= 3.7', '< 4.0' spec.add_dependency 'test-kitchen', '>= 1.17', '< 3' spec.add_development_dependency 'bundler' diff --git a/lib/kitchen/driver/digitalocean.rb b/lib/kitchen/driver/digitalocean.rb index 16e7e33..eeedf2b 100644 --- a/lib/kitchen/driver/digitalocean.rb +++ b/lib/kitchen/driver/digitalocean.rb @@ -41,6 +41,8 @@ class Digitalocean < Kitchen::Driver::SSHBase default_config :user_data, nil default_config :tags, nil default_config :firewalls, nil + default_config :vpcs, nil + default_config :region do ENV['DIGITALOCEAN_REGION'] || 'nyc1' @@ -194,6 +196,7 @@ def create_server private_networking: config[:private_networking], ipv6: config[:ipv6], user_data: config[:user_data], + vpc_uuid: config[:vpcs], tags: if config[:tags].is_a?(String) config[:tags].split(/\s+|,\s+|,+/) else diff --git a/lib/kitchen/driver/digitalocean_version.rb b/lib/kitchen/driver/digitalocean_version.rb index dd70aae..518cf8d 100644 --- a/lib/kitchen/driver/digitalocean_version.rb +++ b/lib/kitchen/driver/digitalocean_version.rb @@ -20,7 +20,7 @@ module Kitchen module Driver # Version string for Digital Ocean Kitchen driver - DIGITALOCEAN_VERSION = '0.10.7' + DIGITALOCEAN_VERSION = '0.11.0' end end diff --git a/spec/kitchen/driver/digitalocean_spec.rb b/spec/kitchen/driver/digitalocean_spec.rb index ada9b7b..15f3da5 100644 --- a/spec/kitchen/driver/digitalocean_spec.rb +++ b/spec/kitchen/driver/digitalocean_spec.rb @@ -126,7 +126,8 @@ username: 'admin', port: '2222', server_name: 'puppy', - region: 'ams1' + region: 'ams1', + vpcs: '3a92ae2d-f1b7-4589-81b8-8ef144374453' } let(:config) { config }