cli/pkg/cmd/attestation/download/options.go
Zach Steindler 643f4031b2 Add support to attestation command for more predicate types.
Before, we required all attestations have predicateType
https://slsa.dev/provenance/v1. This allows you to use other predicate
types, and adds the ability to filter responses from the API for a
particular predicate type.

Signed-off-by: Zach Steindler <steiza@github.com>
2024-04-09 17:26:32 -04:00

36 lines
779 B
Go

package download
import (
"fmt"
"github.com/cli/cli/v2/pkg/cmd/attestation/api"
"github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci"
"github.com/cli/cli/v2/pkg/cmd/attestation/io"
)
const (
minLimit = 1
maxLimit = 1000
)
type Options struct {
APIClient api.Client
ArtifactPath string
DigestAlgorithm string
Logger *io.Handler
Limit int
Store MetadataStore
OCIClient oci.Client
Owner string
PredicateType string
Repo string
}
func (opts *Options) AreFlagsValid() error {
// Check that limit is between 1 and 1000
if opts.Limit < minLimit || opts.Limit > maxLimit {
return fmt.Errorf("limit %d not allowed, must be between %d and %d", opts.Limit, minLimit, maxLimit)
}
return nil
}