Skip to content

Commit

Permalink
Adjust cnf to certsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Aug 26, 2024
1 parent 6a1a4c5 commit bef3de8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
23 changes: 11 additions & 12 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var outputFormat string

const (
dateFormat = "2006-01-02T15:04:05.999999"
tnfRegex = `v(\d+\.)?(\d+\.)?(\*|\d+)$`
)

var (
Expand Down Expand Up @@ -64,7 +63,7 @@ var getOcpCountCmd = &cobra.Command{
ocpVersionCount := make(map[string]int)
for _, job := range jobsResponses {
for _, j := range job.Jobs {
if isTnfJob(j.Components) {
if isCertsuiteJob(j.Components) {

// Get the OCP version from the components
ocpVersion := findOcpVersionFromComponents(j.Components)
Expand Down Expand Up @@ -129,7 +128,7 @@ var getJobsCmd = &cobra.Command{
var jsonOutput lib.JobsJsonOutput

// Initialize the counters
tnfJobsCtr := 0
certsuiteJobsCtr := 0
totalJobsCtr := 0
startRun := time.Now()

Expand Down Expand Up @@ -158,31 +157,31 @@ var getJobsCmd = &cobra.Command{
totalJobsCtr++ // Keep track of the total number of jobs

for _, c := range j.Components {
if strings.Contains(c.Name, "cnf-certification-test") {
if strings.Contains(c.Name, "cnf-certification-test") || strings.Contains(c.Name, "certsuite") {
// get the commit/version from the component name
commit := strings.Split(c.Name, " ")[1]

// find out how long ago this job ran
daysAgo, _ := time.Parse(dateFormat, j.CreatedAt)
daysSince := time.Since(daysAgo).Hours() / 24
if outputFormat != "json" {
fmt.Printf("Job ID: %s - TNF Version: %s (Days Since: %f)\n", j.ID, commit, daysSince)
fmt.Printf("Job ID: %s - Certsuite Version: %s (Days Since: %f)\n", j.ID, commit, daysSince)
}

jo := lib.JsonTNFInfo{
ID: j.ID,
TNFVersion: commit,
jo := lib.JsonCertsuiteInfo{
ID: j.ID,
CertsuiteVersion: commit,
}
jsonOutput.Jobs = append(jsonOutput.Jobs, jo)

tnfJobsCtr++
certsuiteJobsCtr++
}
}
}
}

if outputFormat != "json" {
fmt.Printf("Total TNF Jobs: %d\n", tnfJobsCtr)
fmt.Printf("Total Certsuite Jobs: %d\n", certsuiteJobsCtr)
fmt.Printf("Total DCI Jobs: %d\n", totalJobsCtr)
fmt.Printf("Total go-dci runtime: %v\n", time.Since(startRun))
} else {
Expand All @@ -196,9 +195,9 @@ var getJobsCmd = &cobra.Command{
},
}

func isTnfJob(components []lib.Components) bool {
func isCertsuiteJob(components []lib.Components) bool {
for _, c := range components {
if strings.Contains(c.Name, "cnf-certification-test") {
if strings.Contains(c.Name, "cnf-certification-test") || strings.Contains(c.Name, "certsuite") {
return true
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/structs.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package lib

type JsonTNFInfo struct {
ID string `json:"id"`
TNFVersion string `json:"tnf_version"`
OCPVersion string `json:"ocp_version"`
type JsonCertsuiteInfo struct {
ID string `json:"id"`
CertsuiteVersion string `json:"certsuite_version"`
OCPVersion string `json:"ocp_version"`
}

type JsonOcpVersionCount struct {
Expand All @@ -16,7 +16,7 @@ type OcpJsonOutput struct {
}

type JobsJsonOutput struct {
Jobs []JsonTNFInfo `json:"jobs"`
Jobs []JsonCertsuiteInfo `json:"jobs"`
}

type Components struct {
Expand Down

0 comments on commit bef3de8

Please sign in to comment.