github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/pkg/oci/compute.go (about) 1 // Copyright (c) 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package oci 5 6 import ( 7 "context" 8 "errors" 9 "github.com/oracle/oci-go-sdk/v53/core" 10 "strings" 11 ) 12 13 // GetOL8ImageID returns the latest OL8 image id for a given compartment 14 func GetOL8ImageID(client core.ComputeClient, compartmentID string) (string, error) { 15 images, err := client.ListImages(context.Background(), core.ListImagesRequest{ 16 CompartmentId: &compartmentID, 17 }) 18 if err != nil { 19 return "", err 20 } 21 var filteredImages []string 22 for _, image := range images.Items { 23 name := *image.DisplayName 24 if !strings.Contains(name, "GPU") && 25 !strings.Contains(name, "Oracle-Linux-6") && 26 !strings.Contains(name, "aarch64") && 27 strings.HasPrefix(name, "Oracle-Linux-8") { 28 filteredImages = append(filteredImages, *image.Id) 29 } 30 } 31 if len(filteredImages) < 1 { 32 return "", errors.New("no OL8 compatible images found") 33 } 34 return filteredImages[0], nil 35 }