Skip to content

Commit

Permalink
build(registry): ignore "reserved" and "archived" rulesfiles
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
  • Loading branch information
leogr authored and poiana committed Sep 6, 2023
1 parent 6ed73fe commit a9376d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build/registry/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func doUploadToS3(registryFilename, gitTag string) error {

rulesfileInfo := reg.RulesfileByName(pt.Name)
if rulesfileInfo == nil {
return fmt.Errorf("could not find rulesfile %s in registry", pt.Name)
return fmt.Errorf("could not find rulesfile %s in the registry (reserved or archived are ignored)", pt.Name)
}

tmpDir, err := os.MkdirTemp("", "falco-artifacts-to-upload")
Expand Down Expand Up @@ -149,7 +149,7 @@ func doPushToOCI(registryFilename, gitTag string) (*string, error) {

rulesfileInfo := reg.RulesfileByName(pt.Name)
if rulesfileInfo == nil {
return nil, fmt.Errorf("could not find rulesfile %s in registry", pt.Name)
return nil, fmt.Errorf("could not find rulesfile %s in the registry (reserved or archived are ignored)", pt.Name)
}

// Create the repository object for the ref.
Expand Down
4 changes: 4 additions & 0 deletions build/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Rulesfile struct {
URL string `yaml:"url"`
License string `yaml:"license"`
Reserved bool `yaml:"reserved"`
Archived bool `yaml:"archived"`
}

type Registry struct {
Expand All @@ -67,6 +68,9 @@ func (r *Registry) Validate() error {
// RulesfileByName returns the rulesfile in the index with the specified name, or nil if not found
func (r *Registry) RulesfileByName(name string) *Rulesfile {
for _, rf := range r.Rulesfiles {
if rf.Reserved || rf.Archived {
continue
}
if rf.Name == name {
return &rf
}
Expand Down

0 comments on commit a9376d6

Please sign in to comment.