cli/pkg/cmd/attestation/download/options.go
Meredith Lancaster 65071223d8 pass oci client to commands directly
Signed-off-by: Meredith Lancaster <malancas@github.com>
2024-03-05 14:39:28 -07:00

44 lines
1.1 KiB
Go

package download
import (
"fmt"
"github.com/cli/cli/v2/pkg/cmd/attestation/api"
"github.com/cli/cli/v2/pkg/cmd/attestation/artifact/digest"
"github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci"
"github.com/cli/cli/v2/pkg/cmd/attestation/logging"
)
type Options struct {
ArtifactPath string
DigestAlgorithm string
APIClient api.Client
Logger *logging.Logger
Limit int
OCIClient oci.Client
OutputPath string
Owner string
Verbose bool
}
func (opts *Options) AreFlagsValid() error {
if opts.Owner == "" {
return fmt.Errorf("owner must be provided")
}
// DigestAlgorithm must not be empty
if opts.DigestAlgorithm == "" {
return fmt.Errorf("digest-alg cannot be empty")
}
if !digest.IsValidDigestAlgorithm(opts.DigestAlgorithm) {
return fmt.Errorf("invalid digest algorithm '%s' provided in digest-alg", opts.DigestAlgorithm)
}
// Check that limit is between 1 and 1000
if opts.Limit < 1 || opts.Limit > 1000 {
return fmt.Errorf("limit %d not allowed, must be between 1 and 1000", opts.Limit)
}
return nil
}