Repository: redhat-openshift-ecosystem/openshift-preflight
Pull request #783 (2022-09-15 22:01:14)

fix lint issues in main
- Not sure how there are errors in main, but making this change so PR #782 can pass
- See this [build](https://github.com/redhat-openshift-ecosystem/openshift-preflight/actions/runs/3063880057/jobs/4946441161) for clarity 
Signed-off-by: Adam D. Cornett <adc@redhat.com>

openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#" title="Author self-approved">acornett21</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-openshift-ecosystem%2Fopenshift-preflight).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/redhat-openshift-ecosystem/openshift-preflight/blob/main/OWNERS)~~ [acornett21]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
dcibot: -  SUCCESS https://www.distributed-ci.io/jobs/6936aeca-1c50-481d-9717-3cb4f09fd42e/jobStates
 from https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783
openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#" title="Author self-approved">acornett21</a>*, *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#pullrequestreview-1112363168" title="LGTM">bcrochet</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-openshift-ecosystem%2Fopenshift-preflight).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/redhat-openshift-ecosystem/openshift-preflight/blob/main/OWNERS)~~ [acornett21,bcrochet]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#" title="Author self-approved">acornett21</a>*, *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#pullrequestreview-1112363168" title="LGTM">bcrochet</a>*, *<a href="https://github.com/redhat-openshift-ecosystem/openshift-preflight/pull/783#pullrequestreview-1112391396" title="Approved">komish</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-openshift-ecosystem%2Fopenshift-preflight).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/redhat-openshift-ecosystem/openshift-preflight/blob/main/OWNERS)~~ [acornett21,bcrochet,komish]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/cmd/check_container.go b/cmd/check_container.go
index 794e570..8e0a218 100644
--- a/cmd/check_container.go
+++ b/cmd/check_container.go
@@ -2,7 +2,6 @@ package cmd
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"strings"
 
@@ -29,7 +28,7 @@ func checkContainerCmd() *cobra.Command {
 		Args:  checkContainerPositionalArgs,
 		// this fmt.Sprintf is in place to keep spacing consistent with cobras two spaces that's used in: Usage, Flags, etc
 		Example: fmt.Sprintf("  %s", "preflight check container quay.io/repo-name/container-name:version"),
-		PreRunE: validateCertificationProjectId,
+		PreRunE: validateCertificationProjectID,
 		RunE:    checkContainerRunE,
 	}
 
@@ -211,16 +210,16 @@ func checkContainerPositionalArgs(cmd *cobra.Command, args []string) error {
 	return nil
 }
 
-// validateCertificationProjectId validates that the certification project id is in the proper format
+// validateCertificationProjectID validates that the certification project id is in the proper format
 // and throws an error if the value provided is in a legacy format that is not usable to query pyxis
-func validateCertificationProjectId(cmd *cobra.Command, args []string) error {
+func validateCertificationProjectID(cmd *cobra.Command, args []string) error {
 	certificationProjectID := viper.GetString("certification_project_id")
 	// splitting the certification project id into parts. if there are more than 2 elements in the array,
 	// we know they inputted a legacy project id, which can not be used to query pyxis
 	parts := strings.Split(certificationProjectID, "-")
 
 	if len(parts) > 2 {
-		return errors.New(fmt.Sprintf("certification project id: %s is improperly formatted see help command for instructions on obtaining proper value", certificationProjectID))
+		return fmt.Errorf("certification project id: %s is improperly formatted see help command for instructions on obtaining proper value", certificationProjectID)
 	}
 
 	if parts[0] == "ospid" {


Test patch:
diff --git a/cmd/check_container_test.go b/cmd/check_container_test.go
index e72bcd5..6150ce2 100644
--- a/cmd/check_container_test.go
+++ b/cmd/check_container_test.go
@@ -536,7 +536,7 @@ certification_project_id: mycertid`
 				viper.Set("certification_project_id", "123456789")
 			})
 			It("should not change the flag value", func() {
-				err := validateCertificationProjectId(checkContainerCmd(), []string{"foo"})
+				err := validateCertificationProjectID(checkContainerCmd(), []string{"foo"})
 				Expect(err).ToNot(HaveOccurred())
 				Expect(viper.GetString("certification_project_id")).To(Equal("123456789"))
 			})
@@ -546,7 +546,7 @@ certification_project_id: mycertid`
 				viper.Set("certification_project_id", "ospid-123456789")
 			})
 			It("should strip ospid- from the flag value", func() {
-				err := validateCertificationProjectId(checkContainerCmd(), []string{"foo"})
+				err := validateCertificationProjectID(checkContainerCmd(), []string{"foo"})
 				Expect(err).ToNot(HaveOccurred())
 				Expect(viper.GetString("certification_project_id")).To(Equal("123456789"))
 			})
@@ -556,7 +556,7 @@ certification_project_id: mycertid`
 				viper.Set("certification_project_id", "ospid-62423-f26c346-6cc1dc7fae92")
 			})
 			It("should throw an error", func() {
-				err := validateCertificationProjectId(checkContainerCmd(), []string{"foo"})
+				err := validateCertificationProjectID(checkContainerCmd(), []string{"foo"})
 				Expect(err).To(HaveOccurred())
 			})
 		})
@@ -565,7 +565,7 @@ certification_project_id: mycertid`
 				viper.Set("certification_project_id", "62423-f26c346-6cc1dc7fae92")
 			})
 			It("should throw an error", func() {
-				err := validateCertificationProjectId(checkContainerCmd(), []string{"foo"})
+				err := validateCertificationProjectID(checkContainerCmd(), []string{"foo"})
 				Expect(err).To(HaveOccurred())
 			})
 		})