diff --git a/README.md b/README.md index 5457226..25df950 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # certsuite-claim ![build](https://github.com/redhat-best-practices-for-k8s/certsuite-claim/actions/workflows/merge.yml/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/redhat-best-practices-for-k8s/certsuite-claim)](https://goreportcard.com/report/github.com/redhat-best-practices-for-k8s/certsuite-claim) `certsuite-claim` provides the definition for a -[redhat-best-practices-for-k8s](https://github.com/redhat-best-practices-for-k8s/redhat-best-practices-for-k8s) claim. +[redhat-best-practices-for-k8s](https://github.com/redhat-best-practices-for-k8s/certsuite) claim. A claim contains: * The `redhat-best-practices-for-k8s` version used for testing. *Note*: The claim keeps track of only the diff --git a/pkg/claim/schema.go b/pkg/claim/schema.go index 29ae39f..ad58daf 100644 --- a/pkg/claim/schema.go +++ b/pkg/claim/schema.go @@ -11,7 +11,7 @@ // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // -// Code generated by `certsuite-claim/cmd/generate/generate.go` on: 2024-07-26 10:31:19.664412 -0500 CDT m=+0.001070334 +// Code generated by `certsuite-claim/cmd/generate/generate.go` on: 2024-08-29 15:09:39.128084 +0200 CEST m=+0.001916043 // // `https://github.com/a-h/generate` provides a generic set of interfaces to convert JSON schema into // workable GoLang struct implementations. However, the code generator is limited and does not allow @@ -28,203 +28,203 @@ package claim import ( - "errors" - "bytes" - "encoding/json" - "fmt" + "bytes" + "encoding/json" + "errors" + "fmt" ) // CatalogInfo test specific information from the catalog type CatalogInfo struct { - // Link to the best practice document supporting this test case - BestPracticeReference string `json:"bestPracticeReference"` + // Link to the best practice document supporting this test case + BestPracticeReference string `json:"bestPracticeReference"` - // The test description. - Description string `json:"description"` + // The test description. + Description string `json:"description"` - // Indicates the exception process if defined - ExceptionProcess string `json:"exceptionProcess"` + // Indicates the exception process if defined + ExceptionProcess string `json:"exceptionProcess"` - // steps required to fix a failing test case - Remediation string `json:"remediation"` + // steps required to fix a failing test case + Remediation string `json:"remediation"` } // CategoryClassification categoryClassification is the classification for a single test case. type CategoryClassification struct { - // indicates whether this test case is mandatory or optional in the Extended scenario - Extended string `json:"Extended,omitempty"` + // indicates whether this test case is mandatory or optional in the Extended scenario + Extended string `json:"Extended,omitempty"` - // indicates whether this test case is mandatory or optional in the FarEdge scenario - FarEdge string `json:"FarEdge,omitempty"` + // indicates whether this test case is mandatory or optional in the FarEdge scenario + FarEdge string `json:"FarEdge,omitempty"` - // indicates whether this test case is mandatory or optional in the NonTelco scenario - NonTelco string `json:"NonTelco,omitempty"` + // indicates whether this test case is mandatory or optional in the NonTelco scenario + NonTelco string `json:"NonTelco,omitempty"` - // indicates whether this test case is mandatory or optional in the Telco scenario - Telco string `json:"Telco,omitempty"` + // indicates whether this test case is mandatory or optional in the Telco scenario + Telco string `json:"Telco,omitempty"` } -// Claim +// Claim type Claim struct { - // Tests within redhat-best-practices-for-k8s often require configuration. For example, the generic test suite requires listing all CNF containers. This information is used to derive per-container IP address information, which is then used as input to the connectivity test suite. Test suites within redhat-best-practices-for-k8s may use multiple configurations, but each with a unique name. - Configurations map[string]interface{} `json:"configurations"` - Metadata *Metadata `json:"metadata"` + // Tests within redhat-best-practices-for-k8s often require configuration. For example, the generic test suite requires listing all CNF containers. This information is used to derive per-container IP address information, which is then used as input to the connectivity test suite. Test suites within redhat-best-practices-for-k8s may use multiple configurations, but each with a unique name. + Configurations map[string]interface{} `json:"configurations"` + Metadata *Metadata `json:"metadata"` - // An OpenShift cluster is composed of an arbitrary number of Nodes used for platform and application services. Since a claim must be reproducible, a variety of per-Node information must be collected and stored in the claim. Node names are unique within a given OpenShift cluster. - Nodes map[string]interface{} `json:"nodes"` + // An OpenShift cluster is composed of an arbitrary number of Nodes used for platform and application services. Since a claim must be reproducible, a variety of per-Node information must be collected and stored in the claim. Node names are unique within a given OpenShift cluster. + Nodes map[string]interface{} `json:"nodes"` - // The results for each unique test case. - Results map[string]Result `json:"results,omitempty"` - Versions *Versions `json:"versions"` + // The results for each unique test case. + Results map[string]Result `json:"results,omitempty"` + Versions *Versions `json:"versions"` } // Identifier identifier is a per testcase unique identifier. type Identifier struct { - // id stores a unique id for the testcase. - Id string `json:"id"` + // id stores a unique id for the testcase. + Id string `json:"id"` - // suite stores the test suite name for the testcase. - Suite string `json:"suite"` + // suite stores the test suite name for the testcase. + Suite string `json:"suite"` - // tags stores the different tags applied to a test. - Tags string `json:"tags,omitempty"` + // tags stores the different tags applied to a test. + Tags string `json:"tags,omitempty"` } -// Metadata +// Metadata type Metadata struct { - // The UTC end time of a claim evaluation. This is recorded when the redhat-best-practices-for-k8s test suite completes. - EndTime string `json:"endTime"` + // The UTC end time of a claim evaluation. This is recorded when the redhat-best-practices-for-k8s test suite completes. + EndTime string `json:"endTime"` - // The UTC start time of a claim evaluation. This is recorded when the redhat-best-practices-for-k8s test suite is invoked. - StartTime string `json:"startTime"` + // The UTC start time of a claim evaluation. This is recorded when the redhat-best-practices-for-k8s test suite is invoked. + StartTime string `json:"startTime"` } // Result result is the result of running a testcase. type Result struct { - // Ginkgo writer output during the test run. - CapturedTestOutput string `json:"capturedTestOutput"` + // Ginkgo writer output during the test run. + CapturedTestOutput string `json:"capturedTestOutput"` - // Test detailed information from catalog - CatalogInfo *CatalogInfo `json:"catalogInfo"` + // Test detailed information from catalog + CatalogInfo *CatalogInfo `json:"catalogInfo"` - // Category classification for the test - CategoryClassification *CategoryClassification `json:"categoryClassification"` + // Category classification for the test + CategoryClassification *CategoryClassification `json:"categoryClassification"` - // Described the reasons for passing or failing a test - CheckDetails string `json:"checkDetails"` + // Described the reasons for passing or failing a test + CheckDetails string `json:"checkDetails"` - // The duration of the test in nanoseconds. - Duration int `json:"duration"` + // The duration of the test in nanoseconds. + Duration int `json:"duration"` - // The end time of the test. - EndTime string `json:"endTime,omitempty"` + // The end time of the test. + EndTime string `json:"endTime,omitempty"` - // The content of the line where the failure happened - FailureLineContent string `json:"failureLineContent"` + // The content of the line where the failure happened + FailureLineContent string `json:"failureLineContent"` - // The Filename and line number where the failure happened - FailureLocation string `json:"failureLocation"` + // The Filename and line number where the failure happened + FailureLocation string `json:"failureLocation"` - // Describes the reasons for not running a test (skipped, aborted, panicked, interrupted) - SkipReason string `json:"skipReason"` + // Describes the reasons for not running a test (skipped, aborted, panicked, interrupted) + SkipReason string `json:"skipReason"` - // The start time of the test. - StartTime string `json:"startTime"` + // The start time of the test. + StartTime string `json:"startTime"` - // The test result state: INVALID SPEC STATE, pending,skipped,passed,failed,aborted,panicked,interrupted - State string `json:"state"` + // The test result state: INVALID SPEC STATE, pending,skipped,passed,failed,aborted,panicked,interrupted + State string `json:"state"` - // The test identifier - TestID *Identifier `json:"testID"` + // The test identifier + TestID *Identifier `json:"testID"` } // Root A redhat-best-practices-for-k8s claim is an attestation of the tests performed, the results and the various configurations. Since a claim must be reproducible, it also includes an overview of the systems under test and their physical configurations. type Root struct { - Claim *Claim `json:"claim"` + Claim *Claim `json:"claim"` } -// Versions +// Versions type Versions struct { - // The claim file format version. - ClaimFormat string `json:"claimFormat"` + // The redhat-best-practices-for-k8s (certSuite) release version. + CertSuite string `json:"certSuite"` - // The Kubernetes release version. - K8s string `json:"k8s,omitempty"` + // The redhat-best-practices-for-k8s (certSuite) Git Commit. + CertSuiteGitCommit string `json:"certSuiteGitCommit,omitempty"` - // The oc client release version. - OcClient string `json:"ocClient,omitempty"` + // The claim file format version. + ClaimFormat string `json:"claimFormat"` - // OCP cluster release version. - Ocp string `json:"ocp,omitempty"` + // The Kubernetes release version. + K8s string `json:"k8s,omitempty"` - // The redhat-best-practices-for-k8s (tnf) release version. - Tnf string `json:"tnf"` + // The oc client release version. + OcClient string `json:"ocClient,omitempty"` - // The redhat-best-practices-for-k8s (tnf) Git Commit. - TnfGitCommit string `json:"tnfGitCommit,omitempty"` + // OCP cluster release version. + Ocp string `json:"ocp,omitempty"` } func (strct *CatalogInfo) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "BestPracticeReference" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "bestPracticeReference" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"bestPracticeReference\": ") + comma := false + // "BestPracticeReference" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "bestPracticeReference" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"bestPracticeReference\": ") if tmp, err := json.Marshal(strct.BestPracticeReference); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Description" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "description" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"description\": ") + // "Description" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "description" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"description\": ") if tmp, err := json.Marshal(strct.Description); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "ExceptionProcess" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "exceptionProcess" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"exceptionProcess\": ") + // "ExceptionProcess" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "exceptionProcess" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"exceptionProcess\": ") if tmp, err := json.Marshal(strct.ExceptionProcess); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Remediation" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "remediation" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"remediation\": ") + // "Remediation" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "remediation" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"remediation\": ") if tmp, err := json.Marshal(strct.Remediation); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -234,106 +234,106 @@ func (strct *CatalogInfo) MarshalJSON() ([]byte, error) { } func (strct *CatalogInfo) UnmarshalJSON(b []byte) error { - bestPracticeReferenceReceived := false - descriptionReceived := false - exceptionProcessReceived := false - remediationReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "bestPracticeReference": - if err := json.Unmarshal([]byte(v), &strct.BestPracticeReference); err != nil { - return err - } - bestPracticeReferenceReceived = true - case "description": - if err := json.Unmarshal([]byte(v), &strct.Description); err != nil { - return err - } - descriptionReceived = true - case "exceptionProcess": - if err := json.Unmarshal([]byte(v), &strct.ExceptionProcess); err != nil { - return err - } - exceptionProcessReceived = true - case "remediation": - if err := json.Unmarshal([]byte(v), &strct.Remediation); err != nil { - return err - } - remediationReceived = true - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if bestPracticeReference (a required property) was received - if !bestPracticeReferenceReceived { - return errors.New("\"bestPracticeReference\" is required but was not present") - } - // check if description (a required property) was received - if !descriptionReceived { - return errors.New("\"description\" is required but was not present") - } - // check if exceptionProcess (a required property) was received - if !exceptionProcessReceived { - return errors.New("\"exceptionProcess\" is required but was not present") - } - // check if remediation (a required property) was received - if !remediationReceived { - return errors.New("\"remediation\" is required but was not present") - } - return nil + bestPracticeReferenceReceived := false + descriptionReceived := false + exceptionProcessReceived := false + remediationReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "bestPracticeReference": + if err := json.Unmarshal([]byte(v), &strct.BestPracticeReference); err != nil { + return err + } + bestPracticeReferenceReceived = true + case "description": + if err := json.Unmarshal([]byte(v), &strct.Description); err != nil { + return err + } + descriptionReceived = true + case "exceptionProcess": + if err := json.Unmarshal([]byte(v), &strct.ExceptionProcess); err != nil { + return err + } + exceptionProcessReceived = true + case "remediation": + if err := json.Unmarshal([]byte(v), &strct.Remediation); err != nil { + return err + } + remediationReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if bestPracticeReference (a required property) was received + if !bestPracticeReferenceReceived { + return errors.New("\"bestPracticeReference\" is required but was not present") + } + // check if description (a required property) was received + if !descriptionReceived { + return errors.New("\"description\" is required but was not present") + } + // check if exceptionProcess (a required property) was received + if !exceptionProcessReceived { + return errors.New("\"exceptionProcess\" is required but was not present") + } + // check if remediation (a required property) was received + if !remediationReceived { + return errors.New("\"remediation\" is required but was not present") + } + return nil } func (strct *CategoryClassification) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // Marshal the "Extended" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"Extended\": ") + comma := false + // Marshal the "Extended" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"Extended\": ") if tmp, err := json.Marshal(strct.Extended); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "FarEdge" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"FarEdge\": ") + // Marshal the "FarEdge" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"FarEdge\": ") if tmp, err := json.Marshal(strct.FarEdge); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "NonTelco" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"NonTelco\": ") + // Marshal the "NonTelco" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"NonTelco\": ") if tmp, err := json.Marshal(strct.NonTelco); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "Telco" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"Telco\": ") + // Marshal the "Telco" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"Telco\": ") if tmp, err := json.Marshal(strct.Telco); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -343,105 +343,105 @@ func (strct *CategoryClassification) MarshalJSON() ([]byte, error) { } func (strct *CategoryClassification) UnmarshalJSON(b []byte) error { - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "Extended": - if err := json.Unmarshal([]byte(v), &strct.Extended); err != nil { - return err - } - case "FarEdge": - if err := json.Unmarshal([]byte(v), &strct.FarEdge); err != nil { - return err - } - case "NonTelco": - if err := json.Unmarshal([]byte(v), &strct.NonTelco); err != nil { - return err - } - case "Telco": - if err := json.Unmarshal([]byte(v), &strct.Telco); err != nil { - return err - } - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - return nil + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "Extended": + if err := json.Unmarshal([]byte(v), &strct.Extended); err != nil { + return err + } + case "FarEdge": + if err := json.Unmarshal([]byte(v), &strct.FarEdge); err != nil { + return err + } + case "NonTelco": + if err := json.Unmarshal([]byte(v), &strct.NonTelco); err != nil { + return err + } + case "Telco": + if err := json.Unmarshal([]byte(v), &strct.Telco); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil } func (strct *Claim) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "Configurations" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "configurations" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"configurations\": ") + comma := false + // "Configurations" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "configurations" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"configurations\": ") if tmp, err := json.Marshal(strct.Configurations); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Metadata" field is required - if strct.Metadata == nil { - return nil, errors.New("metadata is a required field") - } - // Marshal the "metadata" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"metadata\": ") + // "Metadata" field is required + if strct.Metadata == nil { + return nil, errors.New("metadata is a required field") + } + // Marshal the "metadata" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"metadata\": ") if tmp, err := json.Marshal(strct.Metadata); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Nodes" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "nodes" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"nodes\": ") + // "Nodes" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "nodes" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"nodes\": ") if tmp, err := json.Marshal(strct.Nodes); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "results" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"results\": ") + // Marshal the "results" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"results\": ") if tmp, err := json.Marshal(strct.Results); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Versions" field is required - if strct.Versions == nil { - return nil, errors.New("versions is a required field") - } - // Marshal the "versions" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"versions\": ") + // "Versions" field is required + if strct.Versions == nil { + return nil, errors.New("versions is a required field") + } + // Marshal the "versions" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"versions\": ") if tmp, err := json.Marshal(strct.Versions); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -451,103 +451,103 @@ func (strct *Claim) MarshalJSON() ([]byte, error) { } func (strct *Claim) UnmarshalJSON(b []byte) error { - configurationsReceived := false - metadataReceived := false - nodesReceived := false - versionsReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "configurations": - if err := json.Unmarshal([]byte(v), &strct.Configurations); err != nil { - return err - } - configurationsReceived = true - case "metadata": - if err := json.Unmarshal([]byte(v), &strct.Metadata); err != nil { - return err - } - metadataReceived = true - case "nodes": - if err := json.Unmarshal([]byte(v), &strct.Nodes); err != nil { - return err - } - nodesReceived = true - case "results": - if err := json.Unmarshal([]byte(v), &strct.Results); err != nil { - return err - } - case "versions": - if err := json.Unmarshal([]byte(v), &strct.Versions); err != nil { - return err - } - versionsReceived = true - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if configurations (a required property) was received - if !configurationsReceived { - return errors.New("\"configurations\" is required but was not present") - } - // check if metadata (a required property) was received - if !metadataReceived { - return errors.New("\"metadata\" is required but was not present") - } - // check if nodes (a required property) was received - if !nodesReceived { - return errors.New("\"nodes\" is required but was not present") - } - // check if versions (a required property) was received - if !versionsReceived { - return errors.New("\"versions\" is required but was not present") - } - return nil + configurationsReceived := false + metadataReceived := false + nodesReceived := false + versionsReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "configurations": + if err := json.Unmarshal([]byte(v), &strct.Configurations); err != nil { + return err + } + configurationsReceived = true + case "metadata": + if err := json.Unmarshal([]byte(v), &strct.Metadata); err != nil { + return err + } + metadataReceived = true + case "nodes": + if err := json.Unmarshal([]byte(v), &strct.Nodes); err != nil { + return err + } + nodesReceived = true + case "results": + if err := json.Unmarshal([]byte(v), &strct.Results); err != nil { + return err + } + case "versions": + if err := json.Unmarshal([]byte(v), &strct.Versions); err != nil { + return err + } + versionsReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if configurations (a required property) was received + if !configurationsReceived { + return errors.New("\"configurations\" is required but was not present") + } + // check if metadata (a required property) was received + if !metadataReceived { + return errors.New("\"metadata\" is required but was not present") + } + // check if nodes (a required property) was received + if !nodesReceived { + return errors.New("\"nodes\" is required but was not present") + } + // check if versions (a required property) was received + if !versionsReceived { + return errors.New("\"versions\" is required but was not present") + } + return nil } func (strct *Identifier) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "Id" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "id" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"id\": ") + comma := false + // "Id" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "id" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"id\": ") if tmp, err := json.Marshal(strct.Id); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Suite" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "suite" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"suite\": ") + // "Suite" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "suite" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"suite\": ") if tmp, err := json.Marshal(strct.Suite); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "tags" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"tags\": ") + // Marshal the "tags" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"tags\": ") if tmp, err := json.Marshal(strct.Tags); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -557,72 +557,72 @@ func (strct *Identifier) MarshalJSON() ([]byte, error) { } func (strct *Identifier) UnmarshalJSON(b []byte) error { - idReceived := false - suiteReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "id": - if err := json.Unmarshal([]byte(v), &strct.Id); err != nil { - return err - } - idReceived = true - case "suite": - if err := json.Unmarshal([]byte(v), &strct.Suite); err != nil { - return err - } - suiteReceived = true - case "tags": - if err := json.Unmarshal([]byte(v), &strct.Tags); err != nil { - return err - } - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if id (a required property) was received - if !idReceived { - return errors.New("\"id\" is required but was not present") - } - // check if suite (a required property) was received - if !suiteReceived { - return errors.New("\"suite\" is required but was not present") - } - return nil + idReceived := false + suiteReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "id": + if err := json.Unmarshal([]byte(v), &strct.Id); err != nil { + return err + } + idReceived = true + case "suite": + if err := json.Unmarshal([]byte(v), &strct.Suite); err != nil { + return err + } + suiteReceived = true + case "tags": + if err := json.Unmarshal([]byte(v), &strct.Tags); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if id (a required property) was received + if !idReceived { + return errors.New("\"id\" is required but was not present") + } + // check if suite (a required property) was received + if !suiteReceived { + return errors.New("\"suite\" is required but was not present") + } + return nil } func (strct *Metadata) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "EndTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "endTime" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"endTime\": ") + comma := false + // "EndTime" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "endTime" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"endTime\": ") if tmp, err := json.Marshal(strct.EndTime); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "StartTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "startTime" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"startTime\": ") + // "StartTime" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "startTime" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"startTime\": ") if tmp, err := json.Marshal(strct.StartTime); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -632,202 +632,202 @@ func (strct *Metadata) MarshalJSON() ([]byte, error) { } func (strct *Metadata) UnmarshalJSON(b []byte) error { - endTimeReceived := false - startTimeReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "endTime": - if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { - return err - } - endTimeReceived = true - case "startTime": - if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { - return err - } - startTimeReceived = true - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if endTime (a required property) was received - if !endTimeReceived { - return errors.New("\"endTime\" is required but was not present") - } - // check if startTime (a required property) was received - if !startTimeReceived { - return errors.New("\"startTime\" is required but was not present") - } - return nil + endTimeReceived := false + startTimeReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "endTime": + if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { + return err + } + endTimeReceived = true + case "startTime": + if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { + return err + } + startTimeReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if endTime (a required property) was received + if !endTimeReceived { + return errors.New("\"endTime\" is required but was not present") + } + // check if startTime (a required property) was received + if !startTimeReceived { + return errors.New("\"startTime\" is required but was not present") + } + return nil } func (strct *Result) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "CapturedTestOutput" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "capturedTestOutput" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"capturedTestOutput\": ") + comma := false + // "CapturedTestOutput" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "capturedTestOutput" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"capturedTestOutput\": ") if tmp, err := json.Marshal(strct.CapturedTestOutput); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "CatalogInfo" field is required - if strct.CatalogInfo == nil { - return nil, errors.New("catalogInfo is a required field") - } - // Marshal the "catalogInfo" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"catalogInfo\": ") + // "CatalogInfo" field is required + if strct.CatalogInfo == nil { + return nil, errors.New("catalogInfo is a required field") + } + // Marshal the "catalogInfo" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"catalogInfo\": ") if tmp, err := json.Marshal(strct.CatalogInfo); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "CategoryClassification" field is required - if strct.CategoryClassification == nil { - return nil, errors.New("categoryClassification is a required field") - } - // Marshal the "categoryClassification" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"categoryClassification\": ") + // "CategoryClassification" field is required + if strct.CategoryClassification == nil { + return nil, errors.New("categoryClassification is a required field") + } + // Marshal the "categoryClassification" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"categoryClassification\": ") if tmp, err := json.Marshal(strct.CategoryClassification); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "CheckDetails" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "checkDetails" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"checkDetails\": ") + // "CheckDetails" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "checkDetails" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"checkDetails\": ") if tmp, err := json.Marshal(strct.CheckDetails); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Duration" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "duration" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"duration\": ") + // "Duration" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "duration" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"duration\": ") if tmp, err := json.Marshal(strct.Duration); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "endTime" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"endTime\": ") + // Marshal the "endTime" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"endTime\": ") if tmp, err := json.Marshal(strct.EndTime); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "FailureLineContent" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "failureLineContent" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"failureLineContent\": ") + // "FailureLineContent" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "failureLineContent" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"failureLineContent\": ") if tmp, err := json.Marshal(strct.FailureLineContent); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "FailureLocation" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "failureLocation" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"failureLocation\": ") + // "FailureLocation" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "failureLocation" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"failureLocation\": ") if tmp, err := json.Marshal(strct.FailureLocation); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "SkipReason" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "skipReason" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"skipReason\": ") + // "SkipReason" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "skipReason" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"skipReason\": ") if tmp, err := json.Marshal(strct.SkipReason); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "StartTime" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "startTime" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"startTime\": ") + // "StartTime" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "startTime" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"startTime\": ") if tmp, err := json.Marshal(strct.StartTime); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "State" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "state" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"state\": ") + // "State" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "state" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"state\": ") if tmp, err := json.Marshal(strct.State); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "TestID" field is required - if strct.TestID == nil { - return nil, errors.New("testID is a required field") - } - // Marshal the "testID" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"testID\": ") + // "TestID" field is required + if strct.TestID == nil { + return nil, errors.New("testID is a required field") + } + // Marshal the "testID" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"testID\": ") if tmp, err := json.Marshal(strct.TestID); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -837,151 +837,151 @@ func (strct *Result) MarshalJSON() ([]byte, error) { } func (strct *Result) UnmarshalJSON(b []byte) error { - capturedTestOutputReceived := false - catalogInfoReceived := false - categoryClassificationReceived := false - checkDetailsReceived := false - durationReceived := false - failureLineContentReceived := false - failureLocationReceived := false - skipReasonReceived := false - startTimeReceived := false - stateReceived := false - testIDReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "capturedTestOutput": - if err := json.Unmarshal([]byte(v), &strct.CapturedTestOutput); err != nil { - return err - } - capturedTestOutputReceived = true - case "catalogInfo": - if err := json.Unmarshal([]byte(v), &strct.CatalogInfo); err != nil { - return err - } - catalogInfoReceived = true - case "categoryClassification": - if err := json.Unmarshal([]byte(v), &strct.CategoryClassification); err != nil { - return err - } - categoryClassificationReceived = true - case "checkDetails": - if err := json.Unmarshal([]byte(v), &strct.CheckDetails); err != nil { - return err - } - checkDetailsReceived = true - case "duration": - if err := json.Unmarshal([]byte(v), &strct.Duration); err != nil { - return err - } - durationReceived = true - case "endTime": - if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { - return err - } - case "failureLineContent": - if err := json.Unmarshal([]byte(v), &strct.FailureLineContent); err != nil { - return err - } - failureLineContentReceived = true - case "failureLocation": - if err := json.Unmarshal([]byte(v), &strct.FailureLocation); err != nil { - return err - } - failureLocationReceived = true - case "skipReason": - if err := json.Unmarshal([]byte(v), &strct.SkipReason); err != nil { - return err - } - skipReasonReceived = true - case "startTime": - if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { - return err - } - startTimeReceived = true - case "state": - if err := json.Unmarshal([]byte(v), &strct.State); err != nil { - return err - } - stateReceived = true - case "testID": - if err := json.Unmarshal([]byte(v), &strct.TestID); err != nil { - return err - } - testIDReceived = true - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if capturedTestOutput (a required property) was received - if !capturedTestOutputReceived { - return errors.New("\"capturedTestOutput\" is required but was not present") - } - // check if catalogInfo (a required property) was received - if !catalogInfoReceived { - return errors.New("\"catalogInfo\" is required but was not present") - } - // check if categoryClassification (a required property) was received - if !categoryClassificationReceived { - return errors.New("\"categoryClassification\" is required but was not present") - } - // check if checkDetails (a required property) was received - if !checkDetailsReceived { - return errors.New("\"checkDetails\" is required but was not present") - } - // check if duration (a required property) was received - if !durationReceived { - return errors.New("\"duration\" is required but was not present") - } - // check if failureLineContent (a required property) was received - if !failureLineContentReceived { - return errors.New("\"failureLineContent\" is required but was not present") - } - // check if failureLocation (a required property) was received - if !failureLocationReceived { - return errors.New("\"failureLocation\" is required but was not present") - } - // check if skipReason (a required property) was received - if !skipReasonReceived { - return errors.New("\"skipReason\" is required but was not present") - } - // check if startTime (a required property) was received - if !startTimeReceived { - return errors.New("\"startTime\" is required but was not present") - } - // check if state (a required property) was received - if !stateReceived { - return errors.New("\"state\" is required but was not present") - } - // check if testID (a required property) was received - if !testIDReceived { - return errors.New("\"testID\" is required but was not present") - } - return nil + capturedTestOutputReceived := false + catalogInfoReceived := false + categoryClassificationReceived := false + checkDetailsReceived := false + durationReceived := false + failureLineContentReceived := false + failureLocationReceived := false + skipReasonReceived := false + startTimeReceived := false + stateReceived := false + testIDReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "capturedTestOutput": + if err := json.Unmarshal([]byte(v), &strct.CapturedTestOutput); err != nil { + return err + } + capturedTestOutputReceived = true + case "catalogInfo": + if err := json.Unmarshal([]byte(v), &strct.CatalogInfo); err != nil { + return err + } + catalogInfoReceived = true + case "categoryClassification": + if err := json.Unmarshal([]byte(v), &strct.CategoryClassification); err != nil { + return err + } + categoryClassificationReceived = true + case "checkDetails": + if err := json.Unmarshal([]byte(v), &strct.CheckDetails); err != nil { + return err + } + checkDetailsReceived = true + case "duration": + if err := json.Unmarshal([]byte(v), &strct.Duration); err != nil { + return err + } + durationReceived = true + case "endTime": + if err := json.Unmarshal([]byte(v), &strct.EndTime); err != nil { + return err + } + case "failureLineContent": + if err := json.Unmarshal([]byte(v), &strct.FailureLineContent); err != nil { + return err + } + failureLineContentReceived = true + case "failureLocation": + if err := json.Unmarshal([]byte(v), &strct.FailureLocation); err != nil { + return err + } + failureLocationReceived = true + case "skipReason": + if err := json.Unmarshal([]byte(v), &strct.SkipReason); err != nil { + return err + } + skipReasonReceived = true + case "startTime": + if err := json.Unmarshal([]byte(v), &strct.StartTime); err != nil { + return err + } + startTimeReceived = true + case "state": + if err := json.Unmarshal([]byte(v), &strct.State); err != nil { + return err + } + stateReceived = true + case "testID": + if err := json.Unmarshal([]byte(v), &strct.TestID); err != nil { + return err + } + testIDReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if capturedTestOutput (a required property) was received + if !capturedTestOutputReceived { + return errors.New("\"capturedTestOutput\" is required but was not present") + } + // check if catalogInfo (a required property) was received + if !catalogInfoReceived { + return errors.New("\"catalogInfo\" is required but was not present") + } + // check if categoryClassification (a required property) was received + if !categoryClassificationReceived { + return errors.New("\"categoryClassification\" is required but was not present") + } + // check if checkDetails (a required property) was received + if !checkDetailsReceived { + return errors.New("\"checkDetails\" is required but was not present") + } + // check if duration (a required property) was received + if !durationReceived { + return errors.New("\"duration\" is required but was not present") + } + // check if failureLineContent (a required property) was received + if !failureLineContentReceived { + return errors.New("\"failureLineContent\" is required but was not present") + } + // check if failureLocation (a required property) was received + if !failureLocationReceived { + return errors.New("\"failureLocation\" is required but was not present") + } + // check if skipReason (a required property) was received + if !skipReasonReceived { + return errors.New("\"skipReason\" is required but was not present") + } + // check if startTime (a required property) was received + if !startTimeReceived { + return errors.New("\"startTime\" is required but was not present") + } + // check if state (a required property) was received + if !stateReceived { + return errors.New("\"state\" is required but was not present") + } + // check if testID (a required property) was received + if !testIDReceived { + return errors.New("\"testID\" is required but was not present") + } + return nil } func (strct *Root) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "Claim" field is required - if strct.Claim == nil { - return nil, errors.New("claim is a required field") - } - // Marshal the "claim" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"claim\": ") + comma := false + // "Claim" field is required + if strct.Claim == nil { + return nil, errors.New("claim is a required field") + } + // Marshal the "claim" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"claim\": ") if tmp, err := json.Marshal(strct.Claim); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -991,102 +991,102 @@ func (strct *Root) MarshalJSON() ([]byte, error) { } func (strct *Root) UnmarshalJSON(b []byte) error { - claimReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "claim": - if err := json.Unmarshal([]byte(v), &strct.Claim); err != nil { - return err - } - claimReceived = true - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if claim (a required property) was received - if !claimReceived { - return errors.New("\"claim\" is required but was not present") - } - return nil + claimReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "claim": + if err := json.Unmarshal([]byte(v), &strct.Claim); err != nil { + return err + } + claimReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if claim (a required property) was received + if !claimReceived { + return errors.New("\"claim\" is required but was not present") + } + return nil } func (strct *Versions) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") - comma := false - // "ClaimFormat" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "claimFormat" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"claimFormat\": ") - if tmp, err := json.Marshal(strct.ClaimFormat); err != nil { + comma := false + // "CertSuite" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "certSuite" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"certSuite\": ") + if tmp, err := json.Marshal(strct.CertSuite); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "k8s" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"k8s\": ") - if tmp, err := json.Marshal(strct.K8s); err != nil { + // Marshal the "certSuiteGitCommit" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"certSuiteGitCommit\": ") + if tmp, err := json.Marshal(strct.CertSuiteGitCommit); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "ocClient" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"ocClient\": ") - if tmp, err := json.Marshal(strct.OcClient); err != nil { + // "ClaimFormat" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "claimFormat" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"claimFormat\": ") + if tmp, err := json.Marshal(strct.ClaimFormat); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "ocp" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"ocp\": ") - if tmp, err := json.Marshal(strct.Ocp); err != nil { + // Marshal the "k8s" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"k8s\": ") + if tmp, err := json.Marshal(strct.K8s); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // "Tnf" field is required - // only required object types supported for marshal checking (for now) - // Marshal the "tnf" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"tnf\": ") - if tmp, err := json.Marshal(strct.Tnf); err != nil { + // Marshal the "ocClient" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"ocClient\": ") + if tmp, err := json.Marshal(strct.OcClient); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true - // Marshal the "tnfGitCommit" field - if comma { - buf.WriteString(",") - } - buf.WriteString("\"tnfGitCommit\": ") - if tmp, err := json.Marshal(strct.TnfGitCommit); err != nil { + // Marshal the "ocp" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"ocp\": ") + if tmp, err := json.Marshal(strct.Ocp); err != nil { return nil, err - } else { - buf.Write(tmp) + } else { + buf.Write(tmp) } comma = true @@ -1096,52 +1096,52 @@ func (strct *Versions) MarshalJSON() ([]byte, error) { } func (strct *Versions) UnmarshalJSON(b []byte) error { - claimFormatReceived := false - tnfReceived := false - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal(b, &jsonMap); err != nil { - return err - } - // parse all the defined properties - for k, v := range jsonMap { - switch k { - case "claimFormat": - if err := json.Unmarshal([]byte(v), &strct.ClaimFormat); err != nil { - return err - } - claimFormatReceived = true - case "k8s": - if err := json.Unmarshal([]byte(v), &strct.K8s); err != nil { - return err - } - case "ocClient": - if err := json.Unmarshal([]byte(v), &strct.OcClient); err != nil { - return err - } - case "ocp": - if err := json.Unmarshal([]byte(v), &strct.Ocp); err != nil { - return err - } - case "tnf": - if err := json.Unmarshal([]byte(v), &strct.Tnf); err != nil { - return err - } - tnfReceived = true - case "tnfGitCommit": - if err := json.Unmarshal([]byte(v), &strct.TnfGitCommit); err != nil { - return err - } - default: - return fmt.Errorf("additional property not allowed: \"" + k + "\"") - } - } - // check if claimFormat (a required property) was received - if !claimFormatReceived { - return errors.New("\"claimFormat\" is required but was not present") - } - // check if tnf (a required property) was received - if !tnfReceived { - return errors.New("\"tnf\" is required but was not present") - } - return nil + certSuiteReceived := false + claimFormatReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "certSuite": + if err := json.Unmarshal([]byte(v), &strct.CertSuite); err != nil { + return err + } + certSuiteReceived = true + case "certSuiteGitCommit": + if err := json.Unmarshal([]byte(v), &strct.CertSuiteGitCommit); err != nil { + return err + } + case "claimFormat": + if err := json.Unmarshal([]byte(v), &strct.ClaimFormat); err != nil { + return err + } + claimFormatReceived = true + case "k8s": + if err := json.Unmarshal([]byte(v), &strct.K8s); err != nil { + return err + } + case "ocClient": + if err := json.Unmarshal([]byte(v), &strct.OcClient); err != nil { + return err + } + case "ocp": + if err := json.Unmarshal([]byte(v), &strct.Ocp); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if certSuite (a required property) was received + if !certSuiteReceived { + return errors.New("\"certSuite\" is required but was not present") + } + // check if claimFormat (a required property) was received + if !claimFormatReceived { + return errors.New("\"claimFormat\" is required but was not present") + } + return nil } diff --git a/pkg/claim/schema_test.go b/pkg/claim/schema_test.go index a76a267..0016089 100644 --- a/pkg/claim/schema_test.go +++ b/pkg/claim/schema_test.go @@ -149,7 +149,7 @@ func TestResult_UnmarshalJSON(t *testing.T) { //nolint:funlen name: "ok", want: &Result{ //nolint:lll - CapturedTestOutput: "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", + CapturedTestOutput: "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", CatalogInfo: &CatalogInfo{ BestPracticeReference: "https://redhat-best-practices-for-k8s.github.io/cnf-best-practices/#cnf-best-practices-image-standards", //nolint:lll @@ -180,7 +180,7 @@ func TestResult_UnmarshalJSON(t *testing.T) { //nolint:funlen //nolint:lll args: args{b: []byte(` { - "capturedTestOutput": "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"tnf\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", + "capturedTestOutput": "{\"CompliantObjectsOut\":[{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-0\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-1\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-d78fbf8d6-jxgl2\",\"test\"]},{\"ObjectType\":\"Container\",\"ObjectFieldsKeys\":[\"Reason For Compliance\",\"Namespace\",\"Pod Name\",\"Container Name\"],\"ObjectFieldsValues\":[\"Container is not modified\",\"certSuite\",\"test-d78fbf8d6-n4jlv\",\"test\"]}],\"NonCompliantObjectsOut\":null}\n", "catalogInfo": { "bestPracticeReference": "https://redhat-best-practices-for-k8s.github.io/cnf-best-practices/#cnf-best-practices-image-standards", "description": "Ensures that the Container Base Image is not altered post-startup. This test is a heuristic, and ensures that there are no changes to the following directories: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64", @@ -206,7 +206,7 @@ func TestResult_UnmarshalJSON(t *testing.T) { //nolint:funlen "suite": "platform-alteration", "tags": "common" } - } + } `)}, wantErr: false, }, diff --git a/pkg/claim/testdata/claim-invalid-additional-property.json b/pkg/claim/testdata/claim-invalid-additional-property.json index 4dc4c25..d7a8964 100644 --- a/pkg/claim/testdata/claim-invalid-additional-property.json +++ b/pkg/claim/testdata/claim-invalid-additional-property.json @@ -6,12 +6,12 @@ "endTime": "1970-01-01T10:05:08+01:00" }, "versions": { - "tnf": "v0.0.1", + "certSuite": "v0.0.1", "claimFormat":"v0.0.1" }, "configurations": {}, "results": { - "{\"url\":\"https://redhat-best-practices-for-k8s.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ + "{\"url\":\"https://redhat-best-practices-for-k8s.com/certsuite/test\",{\"version\":\"v1.0.0\"}": [ { "testText": "someText", "isMeasurement": false, diff --git a/pkg/claim/testdata/claim-valid.json b/pkg/claim/testdata/claim-valid.json index 07a20db..2f3dadb 100644 --- a/pkg/claim/testdata/claim-valid.json +++ b/pkg/claim/testdata/claim-valid.json @@ -99708,7 +99708,7 @@ ], "targetNameSpaces": [ { - "name": "tnf" + "name": "certsuite" } ], "validProtocolNames": [ @@ -99724,12 +99724,12 @@ "openshift.io/scc": "privileged" }, "creationTimestamp": "2024-05-21T17:24:07Z", - "generateName": "tnf-debug-", + "generateName": "certsuite-debug-", "labels": { "controller-revision-hash": "6ddd47458f", - "name": "tnf-debug", + "name": "certsuite-debug", "pod-template-generation": "1", - "redhat-best-practices-for-k8s.com/app": "tnf-debug" + "redhat-best-practices-for-k8s.com/app": "certsuite-debug" }, "managedFields": [ { @@ -99877,7 +99877,7 @@ "time": "2024-05-21T17:24:14Z" } ], - "name": "tnf-debug-6vp4w", + "name": "certsuite-debug-6vp4w", "namespace": "cnf-suite", "ownerReferences": [ { @@ -99885,7 +99885,7 @@ "blockOwnerDeletion": true, "controller": true, "kind": "DaemonSet", - "name": "tnf-debug", + "name": "certsuite-debug", "uid": "8cbedd7f-8b0f-45b0-9bfd-ddcef9b8e418" } ], @@ -123523,7 +123523,7 @@ "testHelmChartReleases": null, "testHorizontalScaler": null, "testNamespaces": [ - "tnf" + "certsuite" ], "testOperators": [], "testPods": null, @@ -128609,8 +128609,8 @@ "k8s": "v1.28.9+2f7b992", "ocClient": "n/a, (not using oc or kubectl client)", "ocp": "4.15.12", - "tnf": "Unreleased build post ", - "tnfGitCommit": "" + "certSuite": "Unreleased build post ", + "certSuiteGitCommit": "" } } } diff --git a/schemas/claim.example.json b/schemas/claim.example.json index 0169a4d..4165e9e 100644 --- a/schemas/claim.example.json +++ b/schemas/claim.example.json @@ -31,7 +31,7 @@ "multusIpAddresses": [ "10.217.0.8" ], - "namespace": "tnf", + "namespace": "certsuite", "podName": "test" } ], @@ -48,13 +48,13 @@ "multusIpAddresses": [ "10.217.0.29" ], - "namespace": "tnf", + "namespace": "certsuite", "podName": "partner" } ], "testOrchestrator": { "containerName": "partner", - "namespace": "tnf", + "namespace": "certsuite", "podName": "partner" } }, @@ -500,7 +500,7 @@ "isMeasurement": false, "lineNumber": 373, "passed": true, - "testText": "generic Testing pod terminationGracePeriod tnf/test" + "testText": "generic Testing pod terminationGracePeriod certsuite/test" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/pod-cluster-role-bindings-best-practices\",\"Version\":\"v1.0.0\"}": [ @@ -511,7 +511,7 @@ "isMeasurement": false, "lineNumber": 554, "passed": true, - "testText": "generic when Testing roles and privileges of tnf/test Should not have ClusterRoleBindings" + "testText": "generic when Testing roles and privileges of certsuite/test Should not have ClusterRoleBindings" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/pod-deployment-best-practices\",\"Version\":\"v1.0.0\"}": [ @@ -533,7 +533,7 @@ "isMeasurement": false, "lineNumber": 389, "passed": true, - "testText": "generic Testing pod nodeSelector tnf/test" + "testText": "generic Testing pod nodeSelector certsuite/test" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/pod-role-bindings-best-practices\",\"Version\":\"v1.0.0\"}": [ @@ -544,7 +544,7 @@ "isMeasurement": false, "lineNumber": 535, "passed": true, - "testText": "generic when Testing roles and privileges of tnf/test Should not have RoleBinding in other namespaces" + "testText": "generic when Testing roles and privileges of certsuite/test Should not have RoleBinding in other namespaces" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/pod-service-account-best-practices\",\"Version\":\"v1.0.0\"}": [ @@ -555,7 +555,7 @@ "isMeasurement": false, "lineNumber": 520, "passed": true, - "testText": "generic when Testing roles and privileges of tnf/test Should have a valid ServiceAccount name" + "testText": "generic when Testing roles and privileges of certsuite/test Should have a valid ServiceAccount name" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/services-do-not-use-nodeports\",\"Version\":\"v1.0.0\"}": [ @@ -566,7 +566,7 @@ "isMeasurement": false, "lineNumber": 574, "passed": true, - "testText": "generic when Testing services in namespace tnf Should not have services of type NodePort" + "testText": "generic when Testing services in namespace certsuite Should not have services of type NodePort" } ], "{\"Url\":\"http://redhat-best-practices-for-k8s.com/testcases/generic/unaltered-startup-boot-params\",\"Version\":\"v1.0.0\"}": [ @@ -577,12 +577,12 @@ "isMeasurement": false, "lineNumber": 500, "passed": false, - "testText": "generic Testing boot params for the pod's node tnf/test" + "testText": "generic Testing boot params for the pod's node certsuite/test" } ] }, "versions": { - "tnf": "v1.0.6" + "certSuite": "v1.0.6" } } -} \ No newline at end of file +} diff --git a/schemas/claim.schema.json b/schemas/claim.schema.json index 62051f1..9a2b377 100644 --- a/schemas/claim.schema.json +++ b/schemas/claim.schema.json @@ -183,13 +183,13 @@ "versions": { "type": "object", "properties": { - "tnf": { + "certSuite": { "type": "string", - "description": "The redhat-best-practices-for-k8s (tnf) release version." + "description": "The redhat-best-practices-for-k8s (certSuite) release version." }, - "tnfGitCommit": { + "certSuiteGitCommit": { "type": "string", - "description": "The redhat-best-practices-for-k8s (tnf) Git Commit." + "description": "The redhat-best-practices-for-k8s (certSuite) Git Commit." }, "ocp": { "type": "string", @@ -210,7 +210,7 @@ }, "additionalProperties": false, "required": [ - "tnf", + "certSuite", "claimFormat" ] },