Skip to content

Commit

Permalink
Merge pull request #77 from vsingh-msys/VSingh/default-image-mapping-…
Browse files Browse the repository at this point in the history
…updates

Remove unsupported default image mapping
  • Loading branch information
gregf authored May 16, 2020
2 parents d5ae935 + 008eec5 commit a2fa7a2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 44 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,21 @@ This is a list of abbreviate image names we provide
```
centos-6
centos-7
centos-8
coreos-stable
oreos-beta
coreos-alpha
debian-7
debian-8
debian-9
debian-10
fedora-27
fedora-28
freebsd-11.1
freebsd-11.0
freebsd-10.3
fedora-30
fedora-31
fedora-32
freebsd-11
freebsd-12
ubuntu-14
ubuntu-16
ubuntu-17
ubuntu-18
ubuntu-20
```

# Regions
Expand Down
55 changes: 22 additions & 33 deletions lib/kitchen/driver/digitalocean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ class Digitalocean < Kitchen::Driver::SSHBase
required_config :digitalocean_access_token
required_config :ssh_key_ids

PLATFORM_SLUG_MAP = {
'centos-6' => 'centos-6-x64',
'centos-7' => 'centos-7-x64',
'centos-8' => 'centos-8-x64',
'coreos-stable' => 'coreos-stable',
'coreos-beta' => 'coreos-beta',
'coreos-alpha' => 'coreos-alpha',
'debian-9' => 'debian-9-x64',
'debian-10' => 'debian-10-x64',
'fedora-30' => 'fedora-30-x64',
'fedora-31' => 'fedora-31-x64',
'fedora-32' => 'fedora-32-x64',
'freebsd-11' => 'freebsd-11-x64-zfs',
'freebsd-12' => 'freebsd-12-x64-zfs',
'ubuntu-16' => 'ubuntu-16-04-x64',
'ubuntu-18' => 'ubuntu-18-04-x64',
'ubuntu-19' => 'ubuntu-19-10-x64',
'ubuntu-20' => 'ubuntu-20-04-x64'
}.freeze

def create(state)
server = create_server

Expand Down Expand Up @@ -132,8 +152,8 @@ def destroy(state)
# platform => slug mappings, and falls back to using just the platform as
# provided if it can't find a mapping.
def default_image
platform_to_slug_mapping.fetch(instance.platform.name,
instance.platform.name)
PLATFORM_SLUG_MAP.fetch(instance.platform.name,
instance.platform.name)
end

# Generate what should be a unique server name up to 63 total chars
Expand Down Expand Up @@ -209,37 +229,6 @@ def debug_server_config
def debug_client_config
debug("digitalocean_api_key #{config[:digitalocean_access_token]}")
end

def platform_to_slug_mapping
{
'centos-6' => 'centos-6-x64',
'centos-7' => 'centos-7-x64',
'centos-8' => 'centos-8-x64',
'coreos-stable' => 'coreos-stable-x64',
'coreos-beta' => 'coreos-beta-x64',
'coreos-alpha' => 'coreos-alpha-x64',
'debian-7' => 'debian-7-x64',
'debian-8' => 'debian-8-x64',
'debian-9' => 'debian-9-x64',
'debian-10' => 'debian-10-x64',
'fedora-27' => 'fedora-27-x64',
'fedora-28' => 'fedora-28-x64',
'fedora-29' => 'fedora-29-x64',
'fedora-30' => 'fedora-30-x64',
'fedora-31' => 'fedora-31-x64',
'freebsd-12' => 'freebsd-12-x64-zfs',
'freebsd-11.2' => 'freebsd-11-2-x64-zfs',
'freebsd-11.1' => 'freebsd-11-1-x64-zfs',
'freebsd-11.0' => 'freebsd-11-0-x64-zfs',
'freebsd-10.3' => 'freebsd-10-3-x64-zfs',
'freebsd-10.4' => 'freebsd-10-4-x64-zfs',
'ubuntu-14' => 'ubuntu-14-04-x64',
'ubuntu-16' => 'ubuntu-16-04-x64',
'ubuntu-17' => 'ubuntu-17-10-x64',
'ubuntu-18' => 'ubuntu-18-04-x64',
'ubuntu-19' => 'ubuntu-19-04-x64'
}
end
end
end
end
Expand Down
21 changes: 18 additions & 3 deletions spec/kitchen/driver/digitalocean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,25 @@
end

context 'platform name matches a known platform => slug mapping' do
let(:platform_name) { 'ubuntu-17' }
context 'name is centos-6' do
let(:platform_name) { 'centos-6' }
it 'matches the correct image slug' do
expect(driver[:image]).to eq('centos-6-x64')
end
end

context 'name is ubuntu-19' do
let(:platform_name) { 'ubuntu-19' }
it 'matches the correct image slug' do
expect(driver[:image]).to eq('ubuntu-19-10-x64')
end
end

it 'matches the correct image slug' do
expect(driver[:image]).to eq('ubuntu-17-10-x64')
context 'name is ubuntu-20' do
let(:platform_name) { 'ubuntu-20' }
it 'matches the correct image slug' do
expect(driver[:image]).to eq('ubuntu-20-04-x64')
end
end
end

Expand Down

0 comments on commit a2fa7a2

Please sign in to comment.