Skip to content

Commit

Permalink
Add missing use-csub flag to oci collector (#2424)
Browse files Browse the repository at this point in the history
Signed-off-by: robert-cronin <robert.owen.cronin@gmail.com>
  • Loading branch information
robert-cronin authored Jan 9, 2025
1 parent 6ea8c8c commit 2d684f0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/guacone/cmd/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type ociRegistryOptions struct {
var ociCmd = &cobra.Command{
Use: "image [flags] image_path1 image_path2...",
Short: "takes images to download sbom and attestation stored in OCI to add to GUAC graph, this command talks directly to the graphQL endpoint",
Args: cobra.MinimumNArgs(1),
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
opts, csubClient, err := validateOCIFlags(
viper.GetString("gql-addr"),
Expand Down Expand Up @@ -331,6 +331,23 @@ func validateOCIRegistryFlags(gqlEndpoint, headerFile, csubAddr string, csubTls,
}

func init() {
set, err := cli.BuildFlags([]string{"use-csub"})
if err != nil {
fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err)
os.Exit(1)
}

ociCmd.PersistentFlags().AddFlagSet(set)
if err := viper.BindPFlags(ociCmd.PersistentFlags()); err != nil {
fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err)
os.Exit(1)
}
collectCmd.AddCommand(ociCmd)

ociRegistryCmd.PersistentFlags().AddFlagSet(set)
if err := viper.BindPFlags(ociRegistryCmd.PersistentFlags()); err != nil {
fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err)
os.Exit(1)
}
collectCmd.AddCommand(ociRegistryCmd)
}

0 comments on commit 2d684f0

Please # to comment.