Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mac1/mac2 instances #594

Merged
merged 1 commit into from
Dec 4, 2022
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
1 change: 1 addition & 0 deletions lib/kitchen/driver/aws/standard_platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Aws
# rhel
# fedora
# freebsd
# macos
# ubuntu
# windows
#
Expand Down
51 changes: 51 additions & 0 deletions lib/kitchen/driver/aws/standard_platform/macos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright:: 2016-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "../standard_platform"

module Kitchen
module Driver
class Aws
class StandardPlatform
class MacOS < StandardPlatform
StandardPlatform.platforms["macos"] = self

# default username for this platform's ami
# @return [String]
def username
"ec2-user"
end

def image_search
search = {
"owner-id" => "100343932686",
"name" => version ? "amzn-ec2-macos-#{version}*" : "amzn2-ec2-macos-*",
}
search["architecture"] = architecture if architecture
search["architecture"] = "arm64_mac" if architecture == "arm64"
search
end

def self.from_image(driver, image)
if /amzn-ec2-macos/i.match?(image.name)
image.name =~ /\b(\d+(\.\d+[\.\d])?)/i
new(driver, "macos", (Regexp.last_match || [])[1], image.architecture)
end
end
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require_relative "aws/standard_platform/rhel"
require_relative "aws/standard_platform/fedora"
require_relative "aws/standard_platform/freebsd"
require_relative "aws/standard_platform/macos"
require_relative "aws/standard_platform/ubuntu"
require_relative "aws/standard_platform/windows"
require "aws-sdk-ec2"
Expand Down
10 changes: 10 additions & 0 deletions spec/kitchen/driver/aws/image_selection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ def new_instance(platform_name: "blarghle")
{ name: "architecture", values: %w{x86_64} },
],

"macos-12.5" => [
{ name: "owner-id", values: %w{100343932686} },
{ name: "name", values: %w{amzn-ec2-macos-12.5*} },
],
"macos-12.6-arm64" => [
{ name: "owner-id", values: %w{100343932686} },
{ name: "name", values: %w{amzn-ec2-macos-12.6*} },
{ name: "architecture", values: %w{arm64_mac} },
],

"ubuntu" => [
{ name: "owner-id", values: %w{099720109477} },
{ name: "name", values: %w{ubuntu/images/*/ubuntu-*-*} },
Expand Down