@@ -1762,6 +1762,59 @@ func CreateResultMap(_ *testConfig.TestConfig, c dynclient.Client, suiteName str
17621762 return resultMap , nil
17631763}
17641764
1765+ // CheckRulesForInstructions checks that all compliance check results have instructions.
1766+ // Compliance check results in the exception list are skipped from the instruction check.
1767+ func CheckRulesForInstructions (tc * testConfig.TestConfig , c dynclient.Client , suiteName string ) error {
1768+ exceptionList := map [string ]bool {
1769+ rhcos - node - master - bios - disable - usb - boot : true ,
1770+ rhcos - node - master - wireless - disable - in - bios : true ,
1771+ rhcos - node - worker - bios - disable - usb - boot : true ,
1772+ rhcos - node - worker - wireless - disable - in - bios : true
1773+ }
1774+
1775+ labelSelector , err := labels .Parse (cmpv1alpha1 .SuiteLabel + "=" + suiteName )
1776+ if err != nil {
1777+ return fmt .Errorf ("failed to parse label selector: %w" , err )
1778+ }
1779+
1780+ resultList := & cmpv1alpha1.ComplianceCheckResultList {}
1781+ opts := & dynclient.ListOptions {
1782+ LabelSelector : labelSelector ,
1783+ Namespace : tc .OperatorNamespace .Namespace ,
1784+ }
1785+ err = c .List (goctx .TODO (), resultList , opts )
1786+ if err != nil {
1787+ return fmt .Errorf ("failed to get compliance check results for suite %s: %w" , suiteName , err )
1788+ }
1789+
1790+ if len (resultList .Items ) == 0 {
1791+ log .Printf ("No compliance check results found for suite %s" , suiteName )
1792+ return nil
1793+ }
1794+
1795+ // Check each result for instructions
1796+ var missingInstructions []string
1797+ for i := range resultList .Items {
1798+ result := & resultList .Items [i ]
1799+
1800+ if exceptionList [result .Name ] {
1801+ continue
1802+ }
1803+
1804+ if result .Instructions == "" {
1805+ missingInstructions = append (missingInstructions , result .Name )
1806+ log .Printf ("Compliance check result '%s' does not have instructions" , result .Name )
1807+ }
1808+ }
1809+
1810+ if len (missingInstructions ) > 0 {
1811+ return fmt .Errorf ("found %d compliance check result(s) without instructions for suite %s: %v" ,
1812+ len (missingInstructions ), suiteName , missingInstructions )
1813+ }
1814+
1815+ return nil
1816+ }
1817+
17651818// SaveResultAsYAML saves YAML data about the scan results to a file in the configured log directory.
17661819func SaveResultAsYAML (tc * testConfig.TestConfig , results map [string ]string , filename string ) error {
17671820 p := path .Join (tc .LogDir , filename )
0 commit comments