Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Results spreadsheet constants and public functions #2466

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmd/certsuite/upload/results_spreadsheet/const.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package resultsspreadsheet

const (
ConclusionSheetName = "conclusions"
RawResultsSheetName = "raw results"
ConclusionSheetName = "conclusions"
RawResultsSheetName = "raw results"
SingleWorkloadResultsSheetName = "results"

categoryConclusionsCol = "Category"
workloadVersionConclusionsCol = "Workload Version"
ocpVersionConclusionsCol = "OCP Version"
WorkloadNameConclusionsCol = "Workload Name"
resultsConclusionsCol = "Results"
ResultsConclusionsCol = "Results"

workloadNameRawResultsCol = "CNFName"
workloadTypeRawResultsCol = "CNFType"
operatorVersionRawResultsCol = "OperatorVersion"

nextStepAIIfFailSingleWorkloadSheetCol = "Next Step AI If Fail"
conclusionIndividualSingleWorkloadSheetCol = "Owner/TechLead Conclusion"

cellContentLimit = 50000
)
12 changes: 6 additions & 6 deletions cmd/certsuite/upload/results_spreadsheet/results_spreadsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var stringToPointer = func(s string) *string { return &s }
var conclusionSheetHeaders = []string{categoryConclusionsCol, workloadVersionConclusionsCol, ocpVersionConclusionsCol, WorkloadNameConclusionsCol, resultsConclusionsCol}
var conclusionSheetHeaders = []string{categoryConclusionsCol, workloadVersionConclusionsCol, ocpVersionConclusionsCol, WorkloadNameConclusionsCol, ResultsConclusionsCol}

var (
resultsFilePath string
Expand Down Expand Up @@ -140,14 +140,14 @@ func prepareRecordsForSpreadSheet(records [][]string) []*sheets.RowData {
func createSingleWorkloadRawResultsSheet(rawResultsSheet *sheets.Sheet, workloadName string) (*sheets.Sheet, error) {
// Initialize sheet with the two new column headers only.
filteredRows := []*sheets.RowData{{Values: []*sheets.CellData{
{UserEnteredValue: &sheets.ExtendedValue{StringValue: stringToPointer("Owner/TechLead Conclusion")}},
{UserEnteredValue: &sheets.ExtendedValue{StringValue: stringToPointer("Next Step Actions")}},
{UserEnteredValue: &sheets.ExtendedValue{StringValue: stringToPointer(conclusionIndividualSingleWorkloadSheetCol)}},
{UserEnteredValue: &sheets.ExtendedValue{StringValue: stringToPointer(nextStepAIIfFailSingleWorkloadSheetCol)}},
}}}

// Add existing column headers from the rawResultsSheet
filteredRows[0].Values = append(filteredRows[0].Values, rawResultsSheet.Data[0].RowData[0].Values...)

headers := getHeadersFromSheet(rawResultsSheet)
headers := GetHeadersFromSheet(rawResultsSheet)
indices, err := GetHeaderIndicesByColumnNames(headers, []string{"CNFName"})
if err != nil {
return nil, err
Expand Down Expand Up @@ -221,7 +221,7 @@ func createConclusionsSheet(sheetsService *sheets.Service, driveService *drive.S
return nil, fmt.Errorf("unable to create workloads results folder: %v", err)
}

rawSheetHeaders := getHeadersFromSheet(rawResultsSheet)
rawSheetHeaders := GetHeadersFromSheet(rawResultsSheet)
colsIndices, err := GetHeaderIndicesByColumnNames(rawSheetHeaders, []string{workloadNameRawResultsCol, workloadTypeRawResultsCol, operatorVersionRawResultsCol})
if err != nil {
return nil, err
Expand Down Expand Up @@ -271,7 +271,7 @@ func createConclusionsSheet(sheetsService *sheets.Service, driveService *drive.S
case WorkloadNameConclusionsCol:
curCellData.UserEnteredValue.StringValue = &workloadName

case resultsConclusionsCol:
case ResultsConclusionsCol:
workloadResultsSpreadsheet, err := createSingleWorkloadRawResultsSpreadSheet(sheetsService, driveService, workloadsResultsFolder, rawResultsSheet, workloadName)
if err != nil {
return nil, fmt.Errorf("error has occurred while creating %s results file: %v", workloadName, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/certsuite/upload/results_spreadsheet/sheet_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"google.golang.org/api/sheets/v4"
)

func getHeadersFromSheet(sheet *sheets.Sheet) []string {
func GetHeadersFromSheet(sheet *sheets.Sheet) []string {
headers := []string{}
for _, val := range sheet.Data[0].RowData[0].Values {
headers = append(headers, *val.UserEnteredValue.StringValue)
Expand Down
Loading