IsLabelOnlyEvent checks if an event configuration only contains labeled/unlabeled types This is exported for use in the compiler to validate command trigger combinations
(eventValue any)
| 71 | // IsLabelOnlyEvent checks if an event configuration only contains labeled/unlabeled types |
| 72 | // This is exported for use in the compiler to validate command trigger combinations |
| 73 | func IsLabelOnlyEvent(eventValue any) bool { |
| 74 | // Event can be a map with types field |
| 75 | eventMap, isMap := eventValue.(map[string]any) |
| 76 | if !isMap { |
| 77 | schemaTriggersLog.Print("IsLabelOnlyEvent: event value is not a map, returning false") |
| 78 | return false |
| 79 | } |
| 80 | |
| 81 | // Get the types field |
| 82 | typesValue, hasTypes := eventMap["types"] |
| 83 | if !hasTypes { |
| 84 | schemaTriggersLog.Print("IsLabelOnlyEvent: no types field found, returning false") |
| 85 | return false |
| 86 | } |
| 87 | |
| 88 | // Types should be an array |
| 89 | typesArray, isArray := typesValue.([]any) |
| 90 | if !isArray { |
| 91 | return false |
| 92 | } |
| 93 | |
| 94 | // Check if all types are labeled or unlabeled |
| 95 | if len(typesArray) == 0 { |
| 96 | return false |
| 97 | } |
| 98 | |
| 99 | for _, typeValue := range typesArray { |
| 100 | typeStr, isString := typeValue.(string) |
| 101 | if !isString { |
| 102 | return false |
| 103 | } |
| 104 | if typeStr != "labeled" && typeStr != "unlabeled" { |
| 105 | schemaTriggersLog.Printf("IsLabelOnlyEvent: type %q is not labeled/unlabeled, returning false", typeStr) |
| 106 | return false |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | schemaTriggersLog.Print("IsLabelOnlyEvent: all types are labeled/unlabeled, returning true") |
| 111 | return true |
| 112 | } |
| 113 | |
| 114 | // IsNonConflictingCommandEvent checks if a pull_request/issues event configuration |
| 115 | // only contains types that do not conflict with command (slash_command/command) triggers. |
no test coverage detected