Skip to content

Commit 3acd4fc

Browse files
LucaGuerrapoiana
authored andcommitted
new(cmd): add artifact type to search
Signed-off-by: Luca Guerra <[email protected]>
1 parent f1005d0 commit 3acd4fc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/artifact/search/artifact_search.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/falcosecurity/falcoctl/internal/config"
2424
"github.com/falcosecurity/falcoctl/internal/utils"
2525
"github.com/falcosecurity/falcoctl/pkg/index"
26+
"github.com/falcosecurity/falcoctl/pkg/oci"
2627
"github.com/falcosecurity/falcoctl/pkg/options"
2728
"github.com/falcosecurity/falcoctl/pkg/output"
2829
)
@@ -33,7 +34,8 @@ const (
3334

3435
type artifactSearchOptions struct {
3536
*options.CommonOptions
36-
minScore float64
37+
minScore float64
38+
artifactType oci.ArtifactType
3739
}
3840

3941
func (o *artifactSearchOptions) Validate() error {
@@ -67,6 +69,8 @@ func NewArtifactSearchCmd(ctx context.Context, opt *options.CommonOptions) *cobr
6769
cmd.Flags().Float64VarP(&o.minScore, "min-score", "", defaultMinScore,
6870
"the minimum score used to match artifact names with search keywords")
6971

72+
cmd.Flags().Var(&o.artifactType, "type", `Only search artifacts with a specific type. Allowed values: "rulesfile", "plugin""`)
73+
7074
return cmd
7175
}
7276

@@ -85,6 +89,9 @@ func (o *artifactSearchOptions) RunArtifactSearch(ctx context.Context, args []st
8589

8690
var data [][]string
8791
for _, entry := range resultEntries {
92+
if o.artifactType != "" && o.artifactType != oci.ArtifactType(entry.Type) {
93+
continue
94+
}
8895
indexName := mergedIndexes.IndexByEntry(entry).Name
8996
row := []string{indexName, entry.Name, entry.Type, entry.Registry, entry.Repository}
9097
data = append(data, row)

0 commit comments

Comments
 (0)