-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from philips-labs/discover
- Loading branch information
Showing
18 changed files
with
3,726 additions
and
1,641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package options | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// OCIOptions commandline options to fetch from oci registry | ||
type OCIOptions struct { | ||
KeyRef string | ||
} | ||
|
||
var _ CommandFlagger = (*OCIOptions)(nil) | ||
|
||
// AddFlags implements CommandFlagger to add the RootOptions as flags to the given command | ||
func (o *OCIOptions) AddFlags(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVarP(&o.KeyRef, "key", "", "", "path to the public key file, URL, or KMS URI") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,21 @@ | ||
package options | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/philips-labs/fatt/pkg/attestation" | ||
"github.com/philips-labs/fatt/pkg/attestation/resolvers/packagejson" | ||
"github.com/philips-labs/fatt/pkg/attestation/resolvers/txt" | ||
) | ||
|
||
// RootOptions commandline options for the root command | ||
type RootOptions struct { | ||
FilePath string | ||
Resolver string | ||
} | ||
|
||
// NewRootOptions initializes the RootOptions object | ||
func NewRootOptions() *RootOptions { | ||
return &RootOptions{} | ||
} | ||
|
||
var _ CommandFlagger = (*RootOptions)(nil) | ||
|
||
// AddFlags implements CommandFlagger to add the RootOptions as flags to the given command | ||
func (o *RootOptions) AddFlags(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVarP(&o.FilePath, "file-path", "p", "", "the filepath to find attestation purls (defaults to current working dir)") | ||
cmd.PersistentFlags().StringVarP(&o.Resolver, "resolver", "r", "multi", "the resolver to use for finding attestations") | ||
} | ||
|
||
// GetResolver returns the resolver based on the resolver commmandline options | ||
func (o *RootOptions) GetResolver() (attestation.Resolver, error) { | ||
var r attestation.Resolver | ||
|
||
switch strings.ToLower(o.Resolver) { | ||
case "txt": | ||
r = &txt.Resolver{} | ||
case "packagejson": | ||
r = &packagejson.Resolver{} | ||
case "multi": | ||
r = attestation.NewMultiResolver( | ||
&txt.Resolver{}, | ||
&packagejson.Resolver{}, | ||
) | ||
default: | ||
return nil, fmt.Errorf("unsupported resolver, supported resolvers are `txt`, `packagejson`, `multi`") | ||
} | ||
|
||
return r, nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.