Class: Kitchen::Driver::Aws::StandardPlatform::MacOS

Inherits:
StandardPlatform
  • Object
show all
Defined in:
lib/kitchen/driver/aws/standard_platform/macos.rb

Overview

Amazon's macOS images, which run only on dedicated Mac hosts.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_image(driver, image) ⇒ MacOS?

Detect this platform from an EC2 image.

Matching is done on the image name, which is the only reliable signal EC2 exposes about what an AMI actually contains.

Parameters:

  • driver (Kitchen::Driver::Ec2)

    the driver requesting detection

  • image (Aws::EC2::Image)

    the image to inspect

Returns:

  • (MacOS, nil)

    a platform when the image is macOS, otherwise nil



63
64
65
66
67
68
69
70
71
72
# File 'lib/kitchen/driver/aws/standard_platform/macos.rb', line 63

def self.from_image(driver, image)
  return unless /amzn-ec2-macos/i.match?(image.name)

  # `(\.\d+)?`, not `(\.\d+[\.\d])?`: the character class matched the
  # separator that follows the minor version, capturing it into the
  # version string ("2018.03.") and failing outright when the minor
  # version was followed by anything but a dot or digit.
  image.name =~ /\b(\d+(\.\d+)?)/i
  new(driver, "macos", (Regexp.last_match || [])[1], image.architecture)
end

Instance Method Details

#image_searchHash{String => String, Array<String>}

EC2 image filters that select Amazon's macOS AMIs, which run only on dedicated Mac hosts.

A filter is added for Kitchen::Driver::Aws::StandardPlatform#architecture only when one was requested, so that an unspecified architecture matches any of them.

Returns:

  • (Hash{String => String, Array<String>})

    filter name to the value or values it must match

See Also:



45
46
47
48
49
50
51
52
53
# File 'lib/kitchen/driver/aws/standard_platform/macos.rb', line 45

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

#usernameString

The account EC2 creates on this platform's official AMIs.

Used as the SSH username when the transport does not specify one.

Returns:

  • (String)

    the default SSH username



33
34
35
# File 'lib/kitchen/driver/aws/standard_platform/macos.rb', line 33

def username
  "ec2-user"
end