Skip to content

Commit

Permalink
Ensuring that there is no error during the parsing of components patt…
Browse files Browse the repository at this point in the history
…erns and classes patterns
  • Loading branch information
MontmirailValentin committed Dec 28, 2023
1 parent 9d3cee1 commit a38c0e8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ func (p Policy) GetApplicableConstraints(pkg string) (constraints []CanonicalCon
func (p Policy) extractComponentsPatterns() (map[string][]pattern, error) {
r := map[string][]pattern{}
for k, v := range p.Components {
patterns, _ := v.(string) // TODO check type
patterns, ok := v.(string)
if !ok {
return r, fmt.Errorf("component pattern is not a string. We have: '%s'", v)
}
var err error
r[k], err = buildPatterns(strings.Split(patterns, patternSeparator))
if err != nil {
Expand All @@ -254,7 +257,10 @@ func (p Policy) extractClassesPatterns(compPatterns map[string][]pattern) (map[s

for _, k := range p.classIds {
v := p.Classes[k]
classDef, _ := v.(string) // TODO check type
classDef, ok := v.(string)
if !ok {
return r, fmt.Errorf("class pattern is not a string. We have: '%s'", v)
}
compRefs := strings.Split(classDef, patternSeparator)

for _, cr := range compRefs {
Expand Down

0 comments on commit a38c0e8

Please sign in to comment.