<commit_before>package brightbox

import (
	"fmt"
	"sort"
	"strings"

	"github.com/brightbox/gobrightbox"
)

const (
	DefaultArch     = "x86_64"
	DefaultImageTag = "ubuntu" //Looked for in Image Name
)

/*
Pass in a list of Images obtained from the API receive a reference to
the default image from that list selected according to the constants in
this file.  If no Image matches the default you will get an error.
*/
func GetdefaultImage(images []brightbox.Image) (*brightbox.Image, error) {
	filteredImages := filterImages(images, DefaultImage)
	switch len(filteredImages) {
	case 0:
		return nil, fmt.Errorf("Unable to find a default Image")
	}
	sort.Sort(imagesByAgeDescending(filteredImages))
	return filteredImages[0], nil
}

func filterImages(images []brightbox.Image, selector func(*brightbox.Image) bool) []*brightbox.Image {
	result := make([]*brightbox.Image, 0)
	for index := range images {
		if selector(&images[index]) {<commit_msg>Fix GetDefaultImage name<commit_after>package brightbox

import (
	"fmt"
	"sort"
	"strings"

	"github.com/brightbox/gobrightbox"
)

const (
	DefaultArch     = "x86_64"
	DefaultImageTag = "ubuntu" //Looked for in Image Name
)

/*
Pass in a list of Images obtained from the API receive a reference to
the default image from that list selected according to the constants in
this file.  If no Image matches the default you will get an error.
*/
func GetDefaultImage(images []brightbox.Image) (*brightbox.Image, error) {
	filteredImages := filterImages(images, defaultImage)
	switch len(filteredImages) {
	case 0:
		return nil, fmt.Errorf("Unable to find a default Image")
	}
	sort.Sort(imagesByAgeDescending(filteredImages))
	return filteredImages[0], nil
}

func filterImages(images []brightbox.Image, selector func(*brightbox.Image) bool) []*brightbox.Image {
	result := make([]*brightbox.Image, 0)
	for index := range images {
		if selector(&images[index]) {
{'fraction_non_alphanumeric': 0.10614818707304256, 'fraction_numerical': 0.007356805044666317, 'mean_word_length': 4.968652037617555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '866936', 'n_tokens_mistral': 619, 'n_tokens_neox': 578, 'n_words': 194}