cli/pkg/cmd/attestation/download/options.go
Fredrik Skogman 1b59ec8ad0
This commit introduces tenancy aware attestation policy building.
This is done by inspecting the current hostname to determine if
tenancy is enabled.

The attestation commands also accepts a --hostname parameter, that
is used to pick the current host, similar to how the GH_HOST variable
can be used.

Signed-off-by: Fredrik Skogman <kommendorkapten@github.com>
2024-09-11 10:49:17 +02:00

37 lines
803 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
Hostname 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
}