Skip to content

Commit

Permalink
still need to finish off flags
Browse files Browse the repository at this point in the history
Signed-off-by: chaosinthecrd <[email protected]>
  • Loading branch information
ChaosInTheCRD committed Mar 27, 2024
1 parent 241c5b9 commit 70ca139
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 0 additions & 4 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ const (
// todo: this logic should be broken out and moved to pkg/
// we need to abstract where keys are coming from, etc
func runVerify(ctx context.Context, vo options.VerifyOptions, verifiers ...cryptoutil.Verifier) error {
if vo.KeyPath == "" && len(vo.CAPaths) == 0 && len(verifiers) == 0 {
return fmt.Errorf("must supply either a public key, CA certificates or a verifier")
}

if vo.KeyPath != "" {
keyFile, err := os.Open(vo.KeyPath)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion options/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type SignOptions struct {
var RequiredSignFlags = []string{
"infile",
"outfile",
"datatype",
}

func (so *SignOptions) AddFlags(cmd *cobra.Command) {
Expand Down
14 changes: 14 additions & 0 deletions options/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ var RequiredVerifyFlags = []string{
"policy",
}

var OneRequiredPKFlags = []string{
"publickey",
"policy-ca",
"verifier-kms-ref",
}

var OneRequiredSubjectFlags = []string{
"artifactfile",
"subjects",
}

func (vo *VerifyOptions) AddFlags(cmd *cobra.Command) {
vo.VerifierOptions.AddFlags(cmd)
vo.ArchivistaOptions.AddFlags(cmd)
Expand All @@ -44,4 +55,7 @@ func (vo *VerifyOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&vo.ArtifactFilePath, "artifactfile", "f", "", "Path to the artifact to verify")
cmd.Flags().StringSliceVarP(&vo.AdditionalSubjects, "subjects", "s", []string{}, "Additional subjects to lookup attestations")
cmd.Flags().StringSliceVarP(&vo.CAPaths, "policy-ca", "", []string{}, "Paths to CA certificates to use for verifying the policy")

cmd.MarkFlagsRequiredTogether(RequiredVerifyFlags...)
cmd.MarkFlagsOneRequired(OneRequiredPKFlags...)
}

0 comments on commit 70ca139

Please sign in to comment.