Repository: redhat-openshift-ecosystem/openshift-preflight
Pull request #246 (2021-09-13 17:46:09)

Reorganize code for clarity
Some of the code was put (likely prematurely) into a "utils" package, even
if just a single package was using it. The moves that "utility" code closer
to the consumer, and in some cases, no longer exported.

This also moves some of the truly utility functions into a more sane package
(such as artifacts) that are shared, but make the package name more
descriptive, and therby allowing a shortening of the function name itself.

Signed-off-by: Brad P. Crochet <brad@redhat.com>


Patch:
diff --git a/.gitignore b/.gitignore
index 6b69473..bd8d84b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,10 @@ results.json
 *.test
 
 # Testing dirs
-artifacts
+/artifacts
+
+# But we don't want to ignore the artifacts package
+!/certification/artifacts
 
 # Output of the go coverage tool, specifically when used with LiteIDE
 *.out
diff --git a/certification/utils/utils.go b/certification/artifacts/artifacts.go
similarity index 62%
rename from certification/utils/utils.go
rename to certification/artifacts/artifacts.go
index 21d2666..45c797c 100644
--- a/certification/utils/utils.go
+++ b/certification/artifacts/artifacts.go
@@ -1,4 +1,4 @@
-package utils
+package artifacts
 
 import (
 	"os"
@@ -9,6 +9,19 @@ import (
 	"github.com/spf13/viper"
 )
 
+// WriteFile will write contents of the string to a file in
+// the artifacts directory.
+// Returns the full path (including the artifacts dir)
+func WriteFile(filename, contents string) (string, error) {
+	fullFilePath := filepath.Join(Path(), filename)
+
+	err := os.WriteFile(fullFilePath, []byte(contents), 0644)
+	if err != nil {
+		return fullFilePath, err
+	}
+	return fullFilePath, nil
+}
+
 func createArtifactsDir(artifactsDir string) (string, error) {
 	if !strings.HasPrefix(artifactsDir, "/") {
 		currentDir, err := os.Getwd()
@@ -28,7 +41,8 @@ func createArtifactsDir(artifactsDir string) (string, error) {
 	return artifactsDir, nil
 }
 
-func ArtifactPath() string {
+// Path will return the artifacts path from viper config
+func Path() string {
 	artifactDir := viper.GetString("artifacts")
 	artifactDir, err := createArtifactsDir(artifactDir)
 	if err != nil {
diff --git a/certification/internal/engine/engine.go b/certification/internal/engine/engine.go
index c81cef3..8a57a9e 100644
--- a/certification/internal/engine/engine.go
+++ b/certification/internal/engine/engine.go
@@ -1,19 +1,24 @@
 package engine
 
 import (
+	"archive/tar"
+	"bytes"
+	"crypto/md5"
 	"fmt"
 	"io"
+	"io/fs"
 	"os"
 	"path"
+	"path/filepath"
+	"sort"
 	"time"
 
 	"github.com/google/go-containerregistry/pkg/crane"
 	log "github.com/sirupsen/logrus"
 
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
+	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
-	containerutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/container"
-	fileutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/file"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
 )
 
@@ -82,7 +87,7 @@ func (c *CraneEngine) ExecuteChecks() error {
 	}()
 
 	log.Debug("extracting container filesystem to ", containerFSPath)
-	err = fileutils.Untar(containerFSPath, r)
+	err = untar(containerFSPath, r)
 	if err != nil {
 		return fmt.Errorf("%w: %s", errors.ErrExtractingTarball, err)
 	}
@@ -131,7 +136,7 @@ func (c *CraneEngine) ExecuteChecks() error {
 
 	// hash contents if bundle
 	if c.IsBundle {
-		md5sum, err := containerutils.GenerateBundleHash(c.imageRef.ImageFSPath)
+		md5sum, err := generateBundleHash(c.imageRef.ImageFSPath)
 		if err != nil {
 			log.Debugf("could not generate bundle hash")
 		}
@@ -141,7 +146,124 @@ func (c *CraneEngine) ExecuteChecks() error {
 	return nil
 }
 
+func generateBundleHash(bundlePath string) (string, error) {
+	files := make(map[string]string)
+	fileSystem := os.DirFS(bundlePath)
+
+	hashBuffer := bytes.Buffer{}
+
+	fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
+		if err != nil {
+			log.Errorf("could not read bundle directory: %s", path)
+			return err
+		}
+		if d.Name() == "Dockerfile" {
+			return nil
+		}
+		if d.IsDir() {
+			return nil
+		}
+		filebytes, err := fs.ReadFile(fileSystem, path)
+		if err != nil {
+			log.Errorf("could not read file: %s", path)
+			return err
+		}
+		md5sum := fmt.Sprintf("%x", md5.Sum(filebytes))
+		files[md5sum] = fmt.Sprintf("./%s", path)
+		return nil
+	})
+
+	keys := make([]string, 0, len(files))
+	for k := range files {
+		keys = append(keys, k)
+	}
+
+	sort.Strings(keys)
+	for _, k := range keys {
+		hashBuffer.WriteString(fmt.Sprintf("%s  %s\n", k, files[k]))
+	}
+
+	_, err := artifacts.WriteFile("hashes.txt", hashBuffer.String())
+	if err != nil {
+		return "", err
+	}
+
+	sum := fmt.Sprintf("%x", md5.Sum(hashBuffer.Bytes()))
+
+	log.Debugf("md5 sum: %s", sum)
+
+	return sum, nil
+}
+
 // Results will return the results of check execution.
 func (c *CraneEngine) Results() runtime.Results {
 	return c.results
 }
+
+// Untar takes a destination path and a reader; a tar reader loops over the tarfile
+// creating the file structure at 'dst' along the way, and writing any files
+func untar(dst string, r io.Reader) error {
+	tr := tar.NewReader(r)
+
+	for {
+		header, err := tr.Next()
+
+		switch {
+
+		// if no more files are found return
+		case err == io.EOF:
+			return nil
+
+		// return any other error
+		case err != nil:
+			return err
+
+		// if the header is nil, just skip it (not sure how this happens)
+		case header == nil:
+			continue
+		}
+
+		// the target location where the dir/file should be created
+		target := filepath.Join(dst, header.Name)
+
+		// the following switch could also be done using fi.Mode(), not sure if there
+		// a benefit of using one vs. the other.
+		// fi := header.FileInfo()
+
+		// check the file type
+		switch header.Typeflag {
+
+		// if its a dir and it doesn't exist create it
+		case tar.TypeDir:
+			if _, err := os.Stat(target); err != nil {
+				if err := os.MkdirAll(target, 0755); err != nil {
+					return err
+				}
+			}
+
+		// if it's a file create it
+		case tar.TypeReg:
+			f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
+			if err != nil {
+				return err
+			}
+
+			// copy over contents
+			if _, err := io.Copy(f, tr); err != nil {
+				return err
+			}
+
+			// manually close here after each file operation; defering would cause each file close
+			// to wait until all operations have completed.
+			f.Close()
+
+			// if it's a link create it
+		case tar.TypeSymlink:
+			err := os.Symlink(header.Linkname, filepath.Join(dst, header.Name))
+			if err != nil {
+				log.Println(fmt.Sprintf("Error creating link: %s. Ignoring.", header.Name))
+				continue
+			}
+		}
+	}
+}
diff --git a/certification/internal/engine/operatorsdk.go b/certification/internal/engine/operatorsdk.go
index 008b588..dc622c7 100644
--- a/certification/internal/engine/operatorsdk.go
+++ b/certification/internal/engine/operatorsdk.go
@@ -8,9 +8,9 @@ import (
 	"os/exec"
 	"strings"
 
+	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/cli"
-	fileutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/file"
 	log "github.com/sirupsen/logrus"
 )
 
@@ -138,7 +138,7 @@ func (o operatorSdkEngine) BundleValidate(image string, opts cli.OperatorSdkBund
 }
 
 func (o operatorSdkEngine) writeScorecardFile(resultFile, stdout string) error {
-	_, err := fileutils.WriteFileToArtifactsPath(resultFile, stdout)
+	_, err := artifacts.WriteFile(resultFile, stdout)
 	return err
 }
 
diff --git a/certification/internal/policy/operator/deployable_by_olm.go b/certification/internal/policy/operator/deployable_by_olm.go
index 7d3c350..a73c84e 100644
--- a/certification/internal/policy/operator/deployable_by_olm.go
+++ b/certification/internal/policy/operator/deployable_by_olm.go
@@ -8,14 +8,13 @@ import (
 	"time"
 
 	operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
+	"github.com/spf13/viper"
 
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
+	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/cli"
 	openshiftengine "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/engine"
-	containerutil "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/container"
-	fileutil "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/file"
-	viperutil "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/viper"
 	log "github.com/sirupsen/logrus"
 	yaml "gopkg.in/yaml.v2"
 	kubeErr "k8s.io/apimachinery/pkg/api/errors"
@@ -76,26 +75,26 @@ func (p *DeployableByOlmCheck) newOpenshiftEngine() (*openshiftengine.OpenshiftE
 
 func (p *DeployableByOlmCheck) operatorMetadata(bundleRef certification.ImageReference) (*OperatorData, error) {
 	// retrieve the operator metadata from bundle image
-	annotations, err := containerutil.GetAnnotationsFromBundle(bundleRef.ImageFSPath)
+	annotations, err := getAnnotationsFromBundle(bundleRef.ImageFSPath)
 
 	if err != nil {
 		log.Errorf("unable to get annotations.yaml from the bundle")
 		return nil, err
 	}
 
-	catalogImage, err := viperutil.GetString(indexImageKey)
-	if err != nil {
+	catalogImage := viper.GetString(indexImageKey)
+	if len(catalogImage) == 0 {
 		log.Error(fmt.Sprintf("To set the key, export PFLT_%s or add %s:<value> to config.yaml in the current working directory", strings.ToUpper(indexImageKey), indexImageKey))
 		return nil, err
 	}
 
-	channel, err := containerutil.Annotation(annotations, channelKey)
+	channel, err := annotation(annotations, channelKey)
 	if err != nil {
 		log.Error("unable to extract channel name from ClusterServicVersion", err)
 		return nil, err
 	}
 
-	packageName, err := containerutil.Annotation(annotations, packageKey)
+	packageName, err := annotation(annotations, packageKey)
 	if err != nil {
 		log.Error("unable to extract package name from ClusterServicVersion", err)
 		return nil, err
@@ -273,7 +272,7 @@ func (p *DeployableByOlmCheck) writeToFile(data interface{}, resource string, re
 	}
 
 	filename := fmt.Sprintf("%s-%s.yaml", resource, resourceType)
-	if _, err := fileutil.WriteFileToArtifactsPath(filename, string(yamlData)); err != nil {
+	if _, err := artifacts.WriteFile(filename, string(yamlData)); err != nil {
 		log.Error("failed to write the k8s object to the file", err)
 	}
 }
diff --git a/certification/internal/utils/container/helper.go b/certification/internal/policy/operator/operator.go
similarity index 50%
rename from certification/internal/utils/container/helper.go
rename to certification/internal/policy/operator/operator.go
index 33d2038..6c4e3a6 100644
--- a/certification/internal/utils/container/helper.go
+++ b/certification/internal/policy/operator/operator.go
@@ -1,71 +1,16 @@
-package container
+package operator
 
 import (
-	"bytes"
-	"crypto/md5"
 	"fmt"
-	"io/fs"
 	"os"
 	"path"
-	"path/filepath"
-	"sort"
 
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
-	certutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/utils"
 	log "github.com/sirupsen/logrus"
-	yaml "gopkg.in/yaml.v2"
+	"gopkg.in/yaml.v2"
 )
 
-func GenerateBundleHash(bundlePath string) (string, error) {
-	files := make(map[string]string)
-	fileSystem := os.DirFS(bundlePath)
-
-	hashBuffer := bytes.Buffer{}
-
-	fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
-		if err != nil {
-			log.Errorf("could not read bundle directory: %s", path)
-			return err
-		}
-		if d.Name() == "Dockerfile" {
-			return nil
-		}
-		if d.IsDir() {
-			return nil
-		}
-		filebytes, err := fs.ReadFile(fileSystem, path)
-		if err != nil {
-			log.Errorf("could not read file: %s", path)
-			return err
-		}
-		md5sum := fmt.Sprintf("%x", md5.Sum(filebytes))
-		files[md5sum] = fmt.Sprintf("./%s", path)
-		return nil
-	})
-
-	keys := make([]string, 0, len(files))
-	for k := range files {
-		keys = append(keys, k)
-	}
-
-	sort.Strings(keys)
-	for _, k := range keys {
-		hashBuffer.WriteString(fmt.Sprintf("%s  %s\n", k, files[k]))
-	}
-
-	err := os.WriteFile(filepath.Join(certutils.ArtifactPath(), "hashes.txt"), hashBuffer.Bytes(), 0644)
-	if err != nil {
-		return "", err
-	}
-
-	sum := fmt.Sprintf("%x", md5.Sum(hashBuffer.Bytes()))
-
-	log.Debugf("md5 sum: %s", sum)
-
-	return sum, nil
-}
-
-func GetAnnotationsFromBundle(mountedDir string) (map[string]string, error) {
+func getAnnotationsFromBundle(mountedDir string) (map[string]string, error) {
 	log.Trace("reading annotations file from the bundle")
 	log.Debug("mounted directory is ", mountedDir)
 	annotationsFilePath := path.Join(mountedDir, "metadata", "annotations.yaml")
@@ -88,6 +33,9 @@ func GetAnnotationsFromBundle(mountedDir string) (map[string]string, error) {
 // extractAnnotationsBytes reads the annotation data read from a file and returns the expected format for that yaml
 // represented as a map[string]string.
 func extractAnnotationsBytes(annotationBytes []byte) (map[string]string, error) {
+	type metadata struct {
+		Annotations map[string]string
+	}
 
 	if len(annotationBytes) == 0 {
 		return nil, errors.ErrEmptyAnnotationFile
@@ -102,9 +50,9 @@ func extractAnnotationsBytes(annotationBytes []byte) (map[string]string, error)
 	return bundleMeta.Annotations, nil
 }
 
-// Annotation() accepts the annotations map and searches for the specified annotation corresponding
+// annotation() accepts the annotations map and searches for the specified annotation corresponding
 // with the key, which is then returned.
-func Annotation(annotations map[string]string, key string) (string, error) {
+func annotation(annotations map[string]string, key string) (string, error) {
 	log.Tracef("searching for key (%s) in bundle", key)
 	log.Trace("bundle data: ", annotations)
 	value, found := annotations[key]
@@ -114,7 +62,3 @@ func Annotation(annotations map[string]string, key string) (string, error) {
 
 	return value, nil
 }
-
-type metadata struct {
-	Annotations map[string]string
-}
diff --git a/certification/internal/policy/operator/operator_pkg_name_uniqueness.go b/certification/internal/policy/operator/operator_pkg_name_uniqueness.go
index ad7793f..1b0e84d 100644
--- a/certification/internal/policy/operator/operator_pkg_name_uniqueness.go
+++ b/certification/internal/policy/operator/operator_pkg_name_uniqueness.go
@@ -7,7 +7,6 @@ import (
 	"net/http"
 
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
-	containerutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/container"
 	log "github.com/sirupsen/logrus"
 )
 
@@ -35,7 +34,7 @@ type packageData struct {
 type OperatorPkgNameIsUniqueCheck struct{}
 
 func (p *OperatorPkgNameIsUniqueCheck) Validate(bundleRef certification.ImageReference) (bool, error) {
-	annotations, err := containerutils.GetAnnotationsFromBundle(bundleRef.ImageFSPath)
+	annotations, err := getAnnotationsFromBundle(bundleRef.ImageFSPath)
 	if err != nil {
 		log.Errorf("unable to get annotations.yaml from the bundle")
 		return false, err
@@ -181,7 +180,3 @@ func (p *OperatorPkgNameIsUniqueCheck) Help() certification.HelpText {
 type apiClient interface {
 	Do(req *http.Request) (*http.Response, error)
 }
-
-type metadata struct {
-	Annotations map[string]string
-}
diff --git a/certification/internal/utils/file/helper.go b/certification/internal/utils/file/helper.go
deleted file mode 100644
index 7c93c27..0000000
--- a/certification/internal/utils/file/helper.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package file
-
-import (
-	"archive/tar"
-	"compress/bzip2"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"net/http"
-	"os"
-	"path/filepath"
-
-	certutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/utils"
-
-	log "github.com/sirupsen/logrus"
-)
-
-func DownloadFile(filename string, url string) error {
-	resp, err := http.Get(url)
-	if err != nil {
-		return err
-	}
-	defer resp.Body.Close()
-
-	out, err := os.Create(filename)
-	if err != nil {
-		return err
-	}
-	defer out.Close()
-
-	// Write the body to file
-	_, err = io.Copy(out, resp.Body)
-	return err
-}
-
-func Unzip(bzipfile string, destination string) error {
-
-	f, err := os.Open(bzipfile)
-	if err != nil {
-		return err
-	}
-	defer f.Close()
-
-	in := bzip2.NewReader(f)
-
-	out, err := os.Create(destination)
-
-	if err != nil {
-		return err
-	}
-	_, err = io.Copy(out, in)
-
-	if err != nil {
-		return err
-	}
-	out.Close()
-	return nil
-}
-
-func WriteFileToArtifactsPath(filename, contents string) (string, error) {
-	fullFilePath := filepath.Join(certutils.ArtifactPath(), filename)
-
-	err := ioutil.WriteFile(fullFilePath, []byte(contents), 0644)
-	if err != nil {
-		return fullFilePath, err
-	}
-	return fullFilePath, nil
-}
-
-// Untar takes a destination path and a reader; a tar reader loops over the tarfile
-// creating the file structure at 'dst' along the way, and writing any files
-func Untar(dst string, r io.Reader) error {
-	tr := tar.NewReader(r)
-
-	for {
-		header, err := tr.Next()
-
-		switch {
-
-		// if no more files are found return
-		case err == io.EOF:
-			return nil
-
-		// return any other error
-		case err != nil:
-			return err
-
-		// if the header is nil, just skip it (not sure how this happens)
-		case header == nil:
-			continue
-		}
-
-		// the target location where the dir/file should be created
-		target := filepath.Join(dst, header.Name)
-
-		// the following switch could also be done using fi.Mode(), not sure if there
-		// a benefit of using one vs. the other.
-		// fi := header.FileInfo()
-
-		// check the file type
-		switch header.Typeflag {
-
-		// if its a dir and it doesn't exist create it
-		case tar.TypeDir:
-			if _, err := os.Stat(target); err != nil {
-				if err := os.MkdirAll(target, 0755); err != nil {
-					return err
-				}
-			}
-
-		// if it's a file create it
-		case tar.TypeReg:
-			f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
-			if err != nil {
-				return err
-			}
-
-			// copy over contents
-			if _, err := io.Copy(f, tr); err != nil {
-				return err
-			}
-
-			// manually close here after each file operation; defering would cause each file close
-			// to wait until all operations have completed.
-			f.Close()
-
-			// if it's a link create it
-		case tar.TypeSymlink:
-			err := os.Symlink(header.Linkname, filepath.Join(dst, header.Name))
-			if err != nil {
-				log.Println(fmt.Sprintf("Error creating link: %s. Ignoring.", header.Name))
-				continue
-			}
-		}
-	}
-}
diff --git a/certification/internal/utils/viper/helper.go b/certification/internal/utils/viper/helper.go
deleted file mode 100644
index 256c69f..0000000
--- a/certification/internal/utils/viper/helper.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package viper
-
-import (
-	"fmt"
-
-	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
-	log "github.com/sirupsen/logrus"
-	"github.com/spf13/viper"
-)
-
-func GetString(key string) (string, error) {
-	val := viper.GetString(key)
-	if len(val) == 0 {
-		log.Error(fmt.Sprintf("unable to fetch %s from viper. The value is empty.", key))
-		return "", errors.ErrNoValueFoundInViper
-	}
-	return val, nil
-}
diff --git a/cmd/check_container.go b/cmd/check_container.go
index ff675d8..20cb8a1 100644
--- a/cmd/check_container.go
+++ b/cmd/check_container.go
@@ -7,11 +7,11 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/engine"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/formatters"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
-	certutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/utils"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/version"
 	log "github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
@@ -55,7 +55,7 @@ var checkContainerCmd = &cobra.Command{
 		// create the results file early to catch cases where we are not
 		// able to write to the filesystem before we attempt to execute checks.
 		resultsFile, err := os.OpenFile(
-			filepath.Join(certutils.ArtifactPath(), resultsFilenameWithExtension(formatter.FileExtension())),
+			filepath.Join(artifacts.Path(), resultsFilenameWithExtension(formatter.FileExtension())),
 			os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
 			0600,
 		)
diff --git a/cmd/check_operator.go b/cmd/check_operator.go
index e5395cc..11b68e0 100644
--- a/cmd/check_operator.go
+++ b/cmd/check_operator.go
@@ -7,6 +7,7 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/engine"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/errors"
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/formatters"
@@ -14,8 +15,6 @@ import (
 	"github.com/redhat-openshift-ecosystem/openshift-preflight/version"
 	log "github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
-
-	certutils "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/utils"
 )
 
 var checkOperatorCmd = &cobra.Command{
@@ -61,7 +60,7 @@ var checkOperatorCmd = &cobra.Command{
 		// create the results file early to catch cases where we are not
 		// able to write to the filesystem before we attempt to execute checks.
 		resultsFile, err := os.OpenFile(
-			filepath.Join(certutils.ArtifactPath(), resultsFilenameWithExtension(formatter.FileExtension())),
+			filepath.Join(artifacts.Path(), resultsFilenameWithExtension(formatter.FileExtension())),
 			os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
 			0600,
 		)


Test patch:
diff --git a/certification/internal/utils/container/helper_test.go b/certification/internal/policy/operator/operator_test.go
similarity index 98%
rename from certification/internal/utils/container/helper_test.go
rename to certification/internal/policy/operator/operator_test.go
index 33d5772..19ac8a1 100644
--- a/certification/internal/utils/container/helper_test.go
+++ b/certification/internal/policy/operator/operator_test.go
@@ -1,4 +1,4 @@
-package container
+package operator
 
 import (
 	. "github.com/onsi/ginkgo"
diff --git a/certification/internal/utils/container/helper_suite_test.go b/certification/internal/utils/container/helper_suite_test.go
deleted file mode 100644
index 28ea857..0000000
--- a/certification/internal/utils/container/helper_suite_test.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package container
-
-import (
-	"testing"
-
-	. "github.com/onsi/ginkgo"
-	. "github.com/onsi/gomega"
-)
-
-func TestEngine(t *testing.T) {
-	RegisterFailHandler(Fail)
-	RunSpecs(t, "Container Util Suite")
-}