Skip to content

Commit

Permalink
CLI for specific validations to accept run info
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Mar 17, 2021
1 parent 413944c commit bafba3f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/validateCHML.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ For example:
return err
}

runInfo, err := GetRunInfo(cmd)
if err != nil {
return err
}

// Get the configuration
cfg, err := config.GetSelectedConfiguration()
if err != nil {
Expand All @@ -107,6 +112,7 @@ For example:
$build: String!,
$validationStamp: String!,
$description: String!,
$runInfo: RunInfoInput,
$critical: Int!,
$high: Int!,
$medium: Int!,
Expand All @@ -118,6 +124,7 @@ For example:
build: $build,
validation: $validationStamp,
description: $description,
runInfo: $runInfo,
critical: $critical,
high: $high,
medium: $medium,
Expand All @@ -134,6 +141,7 @@ For example:
"build": build,
"validationStamp": validation,
"description": description,
"runInfo": runInfo,
"critical": critical,
"high": high,
"medium": medium,
Expand Down Expand Up @@ -167,4 +175,7 @@ func init() {
validateCHMLCmd.Flags().Int("high", 0, "Number of high issues")
validateCHMLCmd.Flags().Int("medium", 0, "Number of medium issues")
validateCHMLCmd.Flags().Int("low", 0, "Number of low issues")

// Run info arguments
InitRunInfoCommandFlags(validateCHMLCmd)
}
11 changes: 11 additions & 0 deletions cmd/validateMetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ An alternative syntax is:
return err
}

runInfo, err := GetRunInfo(cmd)
if err != nil {
return err
}

// List of metrics
var metricList = []metric{}

Expand Down Expand Up @@ -131,6 +136,7 @@ An alternative syntax is:
$build: String!,
$validationStamp: String!,
$description: String!,
$runInfo: RunInfoInput,
$metrics: [MetricsEntryInput!]!
) {
validateBuildWithMetrics(input: {
Expand All @@ -139,6 +145,7 @@ An alternative syntax is:
build: $build,
validation: $validationStamp,
description: $description,
runInfo: $runInfo,
metrics: $metrics
}) {
errors {
Expand All @@ -152,6 +159,7 @@ An alternative syntax is:
"build": build,
"validationStamp": validation,
"description": description,
"runInfo": runInfo,
"metrics": metricList,
}, &payload); err != nil {
return err
Expand Down Expand Up @@ -197,6 +205,9 @@ func init() {
// validateMetricsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
validateMetricsCmd.Flags().StringSliceP("metric", "m", []string{}, "List of metric, each value being provided like 'name=value'")
validateMetricsCmd.Flags().String("metrics", "", "Comma-separated list of metric, each value being provided like 'name=value'")

// Run info arguments
InitRunInfoCommandFlags(validateMetricsCmd)
}

type metric struct {
Expand Down
11 changes: 11 additions & 0 deletions cmd/validatePercentage.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ For example:
return err
}

runInfo, err := GetRunInfo(cmd)
if err != nil {
return err
}

value, err := cmd.Flags().GetInt("value")
if err != nil {
return err
Expand Down Expand Up @@ -93,6 +98,7 @@ For example:
$build: String!,
$validationStamp: String!,
$description: String!,
$runInfo: RunInfoInput,
$value: Int!
) {
validateBuildWithPercentage(input: {
Expand All @@ -101,6 +107,7 @@ For example:
build: $build,
validation: $validationStamp,
description: $description,
runInfo: $runInfo,
value: $value
}) {
errors {
Expand All @@ -114,6 +121,7 @@ For example:
"build": build,
"validationStamp": validation,
"description": description,
"runInfo": runInfo,
"value": value,
}, &payload); err != nil {
return err
Expand Down Expand Up @@ -142,4 +150,7 @@ func init() {
// is called directly, e.g.:
// validatePercentageCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
validatePercentageCmd.Flags().Int("value", 0, "Percentage value")

// Run info arguments
InitRunInfoCommandFlags(validatePercentageCmd)
}
11 changes: 11 additions & 0 deletions cmd/validateTests.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ For example:
return err
}

runInfo, err := GetRunInfo(cmd)
if err != nil {
return err
}

passed, err := cmd.Flags().GetInt("passed")
if err != nil {
return err
Expand Down Expand Up @@ -102,6 +107,7 @@ For example:
$build: String!,
$validationStamp: String!,
$description: String!,
$runInfo: RunInfoInput,
$passed: Int!,
$skipped: Int!,
$failed: Int!
Expand All @@ -112,6 +118,7 @@ For example:
build: $build,
validation: $validationStamp,
description: $description,
runInfo: $runInfo,
passed: $passed,
skipped: $skipped,
failed: $failed
Expand All @@ -127,6 +134,7 @@ For example:
"build": build,
"validationStamp": validation,
"description": description,
"runInfo": runInfo,
"passed": passed,
"skipped": skipped,
"failed": failed,
Expand Down Expand Up @@ -159,4 +167,7 @@ func init() {
validateTestsCmd.Flags().Int("passed", 0, "Number of passed tests")
validateTestsCmd.Flags().Int("skipped", 0, "Number of skipped tests")
validateTestsCmd.Flags().Int("failed", 0, "Number of failed tests")

// Run info arguments
InitRunInfoCommandFlags(validateTestsCmd)
}

0 comments on commit bafba3f

Please sign in to comment.