From 9cdeb31fc684dcae1caa001b5f4d8110ac365cad Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Thu, 31 Oct 2024 08:32:35 -0600 Subject: [PATCH] reorganize funcs Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/verify/policy.go | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/cmd/attestation/verify/policy.go b/pkg/cmd/attestation/verify/policy.go index d52497664..b79ebacf0 100644 --- a/pkg/cmd/attestation/verify/policy.go +++ b/pkg/cmd/attestation/verify/policy.go @@ -25,25 +25,6 @@ func expandToGitHubURL(tenant, ownerOrRepo string) string { return fmt.Sprintf("(?i)^https://%s.ghe.com/%s/", tenant, ownerOrRepo) } -func validateSignerWorkflow(opts *Options) (string, error) { - // we expect a provided workflow argument be in the format [HOST/]///path/to/workflow.yml - // if the provided workflow does not contain a host, set the host - match, err := regexp.MatchString(hostRegex, opts.SignerWorkflow) - if err != nil { - return "", err - } - - if match { - return fmt.Sprintf("^https://%s", opts.SignerWorkflow), nil - } - - if opts.Hostname == "" { - return "", errors.New("unknown host") - } - - return fmt.Sprintf("^https://%s/%s", opts.Hostname, opts.SignerWorkflow), nil -} - func newEnforcementCriteria(opts *Options, a artifact.DigestedArtifact) (verification.EnforcementCriteria, error) { c := verification.EnforcementCriteria{ Artifact: a, @@ -131,3 +112,22 @@ func SigstorePolicy(c verification.EnforcementCriteria) (verify.PolicyBuilder, e policy := verify.NewPolicy(artifactDigestPolicyOption, certIdOption) return policy, nil } + +func validateSignerWorkflow(opts *Options) (string, error) { + // we expect a provided workflow argument be in the format [HOST/]///path/to/workflow.yml + // if the provided workflow does not contain a host, set the host + match, err := regexp.MatchString(hostRegex, opts.SignerWorkflow) + if err != nil { + return "", err + } + + if match { + return fmt.Sprintf("^https://%s", opts.SignerWorkflow), nil + } + + if opts.Hostname == "" { + return "", errors.New("unknown host") + } + + return fmt.Sprintf("^https://%s/%s", opts.Hostname, opts.SignerWorkflow), nil +}