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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# kitchen-oci CHANGELOG

# 1.25.0
- feat: allow `image_name` to function the same for ARM as it does for Linux

# 1.24.0
- feat: change pessimistic lock on oci gem to just `~> 2.18`

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ OR
Image ocids and display names can be found on the public [OCI Documentation / Images](https://docs.oracle.com/en-us/iaas/images/) page. The `image_name` property allows you to specify the display
name of the image rather than the ocid. There are two ways to do this:

- specify the entire image name. For example, `Oracle-Linux-8.9-2024.02.26-0`
- specify the un-dated, un-versioned portion of the display name. For example, `Oracle-Linux-8.9`\
- Specify the entire image name. For example, `Oracle-Linux-8.9-2024.02.26-0`
- Specify the un-dated, un-versioned portion of the display name. For example, `Oracle-Linux-8.9`\
Note: for aesthetics, the dashes can be replaced with spaces `Oracle Linux 8.9`. Both ways work, one way is prettier.
- Regular Expressions are also supported. For example, `Oracle Linux 8.\d+` will give the latest `Oracle Linux 8.x`\
Note: be careful here. If the regular expression is too broad, the newest image id of the matching set will be returned and might not be of the desired operating system.
- For an ARM specific `shape` you can add in `-aarch64` to the `image_name`. For example, `Oracle-Linux-8.9-aarch64-2024.02.26-0` or `Oracle Linux 8.\d+-aarch64`\
But you don't have to as if a `shape` matches `VM.Standard.A<##>.Flex` then `-aarch64` gets added automatically and `Oracle Linux 8.\d+` will work the same.\
[ARM Documentation Here](https://docs.oracle.com/en-us/iaas/Content/Compute/References/arm.htm)
- **Caution:** Platform images are refreshed regularly. When new images are released, older versions are replaced. The image OCIDs remain available, but when the platform image is replaced, the image OCIDs are no longer returned as part of the platform image list.\
[OCI Documentation Here](https://docs.oracle.com/en-us/iaas/tools/ruby/2.21.0/OCI/Core/ComputeClient.html#list_images-instance_method)

If the second option is chosen (providing a portion of the display name), the behavior is to search all display names that match the string provided plus anything that looks like
a date, then sort by time created and return the ocid for the newest one. This allows you to always get the latest version of a given image without having to continually update your kitchen.yml files.
Expand Down
10 changes: 9 additions & 1 deletion lib/kitchen/driver/oci/models/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def image_id
end

def image_id_by_name
image_name = config[:image_name].gsub(" ", "-")
image_name = image_name_conversion
image_list = images.select { |i| i.display_name.match(/#{image_name}/) }
raise "unable to find image_id" if image_list.empty?

Expand All @@ -77,6 +77,14 @@ def image_id_by_name
latest_image_id(image_list)
end

def image_name_conversion
image_name = config[:image_name].gsub(" ", "-")
if config[:shape] =~ /^VM\.Standard\.A\d+\.Flex$/ && !config[:image_name].include?("aarch64")
image_name = "#{image_name}-aarch64"
end
image_name
end

def filter_image_list(image_list, image_name)
image_list.select { |i| i.display_name.match(/#{image_name}-[0-9]{4}\.[0-9]{2}\.[0-9]{2}/) }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/driver/oci_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
module Kitchen
module Driver
# Version string for Oracle OCI Kitchen driver
OCI_VERSION = "1.24.0"
OCI_VERSION = "1.25.0"
end
end
36 changes: 36 additions & 0 deletions spec/kitchen/driver/image_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,39 @@
it_behaves_like "image_name provided", images
end
end

describe Kitchen::Driver::Oci::Models::Compute do
include_context "compute"
include_context "create"

context "append aarch64 for ARM shapes" do
subject { Kitchen::Driver::Oci::Models::Compute.new(driver_config, state, oci_config, api, :create) }
let(:state) { {} }
let(:api) { Kitchen::Driver::Oci::Api.new(oci, driver_config) }
let(:driver_config) do
base_driver_config.merge!(
{
image_id: nil,
image_name: "Oracle-Linux-9.3", # test with an image name that does not include aarch64
shape: "VM.Standard.A1.Flex", # Arm shape
}
)
end

before do
allow(compute_client).to receive(:list_images).and_return(list_images_response)
allow(list_images_response).to receive(:next_page).and_return(nil)
end

it "adjusts the image name to include -aarch64" do
expected_image_name = "Oracle-Linux-9.3-aarch64"
expect(subject.send(:image_name_conversion)).to eq(expected_image_name)
end

it "selects the right image ocid for Oracle-Linux-9.3" do
expected_image_ocid = "ocid1.image.oc1.fake.aaaaaaaaaabcdefghijklmnopqrstuvwxyz147852"
selected_image_id = subject.send(:image_id)
expect(selected_image_id).to eq(expected_image_ocid)
end
end
end
Loading