Skip to content

Commit

Permalink
shared/simplestreams: Replace shared.ValueInSlice with slices.Contains
Browse files Browse the repository at this point in the history
Signed-off-by: Din Music <din.music@canonical.com>
  • Loading branch information
MusicDin committed Nov 5, 2024
1 parent cc38020 commit 3045ddd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shared/simplestreams/products.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package simplestreams

import (
"fmt"
"slices"
"strings"
"time"

"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/api"
"github.com/canonical/lxd/shared/osarch"
)
Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *Products) ToLXD() ([]api.Image, map[string][][]string) {
addImage := func(meta *ProductVersionItem, root *ProductVersionItem) error {
// Look for deltas
deltas := []ProductVersionItem{}
if root != nil && shared.ValueInSlice(root.FileType, []string{"squashfs", "disk-kvm.img"}) {
if root != nil && slices.Contains([]string{"squashfs", "disk-kvm.img"}, root.FileType) {
for _, item := range version.Items {
if item.FileType == fmt.Sprintf("%s.vcdiff", root.FileType) {
deltas = append(deltas, item)
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *Products) ToLXD() ([]api.Image, map[string][][]string) {
// Locate source image fingerprint
var srcFingerprint string
for _, item := range srcImage.Items {
if !shared.ValueInSlice(item.FileType, lxdCompatItems) {
if !slices.Contains(lxdCompatItems, item.FileType) {
continue
}

Expand Down Expand Up @@ -288,15 +288,15 @@ func (s *Products) ToLXD() ([]api.Image, map[string][][]string) {

// Locate a valid LXD image
for _, item := range version.Items {
if shared.ValueInSlice(item.FileType, lxdCompatCombinedItems) {
if slices.Contains(lxdCompatCombinedItems, item.FileType) {
err := addImage(&item, nil)
if err != nil {
continue
}
} else if shared.ValueInSlice(item.FileType, lxdCompatItems) {
} else if slices.Contains(lxdCompatItems, item.FileType) {
// Locate the root files
for _, subItem := range version.Items {
if shared.ValueInSlice(subItem.FileType, []string{"disk1.img", "disk-kvm.img", "uefi1.img", "root.tar.xz", "squashfs"}) {
if slices.Contains([]string{"disk1.img", "disk-kvm.img", "uefi1.img", "root.tar.xz", "squashfs"}, subItem.FileType) {
err := addImage(&item, &subItem)
if err != nil {
continue
Expand Down

0 comments on commit 3045ddd

Please sign in to comment.