Skip to content

Commit

Permalink
Merge pull request #209 from kaovilai/futureproofValidChecksumAlg
Browse files Browse the repository at this point in the history
Futureproof validChecksumAlg()
  • Loading branch information
reasonerjt committed Jul 26, 2024
2 parents 26bf625 + 6fbe6dc commit dedaacf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions velero-plugin-for-aws/object_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"io"
"os"
"slices"
"sort"
"strconv"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -216,8 +218,8 @@ func (o *ObjectStore) Init(config map[string]string) error {
}

func validChecksumAlg(alg string) bool {
return alg == string(types.ChecksumAlgorithmCrc32) || alg == string(types.ChecksumAlgorithmCrc32c) ||
alg == string(types.ChecksumAlgorithmSha1) || alg == string(types.ChecksumAlgorithmSha256) || alg == ""
typedAlg := types.ChecksumAlgorithm(alg)
return alg == "" || slices.Contains(typedAlg.Values(), typedAlg)
}

func readCustomerKey(customerKeyEncryptionFile string) (string, error) {
Expand Down

0 comments on commit dedaacf

Please sign in to comment.