Skip to content
Open
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
11 changes: 0 additions & 11 deletions internal/protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,3 @@ type RpcApiTranslator[RpcType any, ApiType comparable] interface {
// Validate checks that user-domain API fields meet requirements and expectations.
Validate(map[ApiType]string, cosiapi.BucketAccessAuthenticationType) error
}

// contains is a helper that returns true if the given `list` contains the item `key`.
// Useful for a variety of Validate() implementations.
func contains[T comparable](list []T, key T) bool {
for _, i := range list {
if i == key {
return true
}
}
return false
}
3 changes: 2 additions & 1 deletion internal/protocol/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package protocol

import (
"fmt"
"slices"

cosiapi "sigs.k8s.io/container-object-storage-interface/client/apis/objectstorage/v1alpha2"
cosiproto "sigs.k8s.io/container-object-storage-interface/proto"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (S3BucketInfoTranslator) Validate(
}

as := vars[cosiapi.BucketInfoVar_S3_AddressingStyle]
if !contains(validS3AddressingStyles, as) {
if !slices.Contains(validS3AddressingStyles, as) {
errs = append(errs, fmt.Sprintf("S3 addressing style %q must be one of %v", as, validS3AddressingStyles))
}

Expand Down
13 changes: 2 additions & 11 deletions sidecar/internal/reconciler/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package reconciler
import (
"context"
"fmt"
"slices"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -366,7 +367,7 @@ func validateDriverSupportsProtocols(driver DriverInfo, required []*cosiproto.Ob
func validateBucketSupportsProtocols(supported, required []cosiapi.ObjectProtocol) error {
unsupported := []string{}
for _, req := range required {
if !contains(supported, req) {
if !slices.Contains(supported, req) {
unsupported = append(unsupported, string(req))
}
}
Expand All @@ -386,13 +387,3 @@ func mergeApiInfoIntoStringMap[T cosiapi.BucketInfoVar | cosiapi.CredentialVar](
target[string(k)] = v
}
}

// contains returns true if the given `list` contains the item `key`.
func contains[T comparable](list []T, key T) bool {
for _, i := range list {
if i == key {
return true
}
}
return false
}