Skip to content

Commit

Permalink
Address comments; move lib to /internal
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Oct 24, 2022
1 parent c7b8663 commit 7a84034
Show file tree
Hide file tree
Showing 18 changed files with 1,312 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ var _ = Describe("Check Container Command", func() {
})
})

It("should contain a ResultWriterFile resultWriter", func() {
It("should contain a ResultWriterFile ResultWriter", func() {
runner, err := NewCheckContainerRunner(context.TODO(), cfg, false)
Expect(err).ToNot(HaveOccurred())
_, rwIsExpectedType := runner.Rw.(*runtime.ResultWriterFile)
Expand Down
4 changes: 2 additions & 2 deletions lib/fakes.go → certification/internal/lib/fakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (e fakeCheckEngine) Results(ctx context.Context) runtime.Results {
}
}

// badResultWriter implements resultWriter and will automatically fail with the
// badResultWriter implements ResultWriter and will automatically fail with the
// provided errmsg.
type badResultWriter struct {
errmsg string
Expand Down Expand Up @@ -233,7 +233,7 @@ func (f *badFormatter) Format(ctx context.Context, r runtime.Results) ([]byte, e
return nil, errors.New(f.errormsg)
}

// badResultSubmitter implements resultSubmitter and fails to submit with the included errmsg.
// badResultSubmitter implements ResultSubmitter and fails to submit with the included errmsg.
type badResultSubmitter struct {
errmsg string
}
Expand Down
4 changes: 2 additions & 2 deletions lib/lib.go → certification/internal/lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func NewCheckOperatorRunner(ctx context.Context, cfg *runtime.Config) (*CheckOpe
}, nil
}

// resolveSubmitter will build out a resultSubmitter if the provided pyxisClient, pc, is not nil.
// resolveSubmitter will build out a ResultSubmitter if the provided pyxisClient, pc, is not nil.
// The pyxisClient is a required component of the submitter. If pc is nil, then a noop submitter
// is returned instead, which does nothing.
func ResolveSubmitter(pc PyxisClient, cfg certification.Config) ResultSubmitter {
Expand Down Expand Up @@ -138,7 +138,7 @@ func GetContainerPolicyExceptions(ctx context.Context, pc PyxisClient) (policy.P
func PreflightCheck(
ctx context.Context,
cfg *runtime.Config,
pc PyxisClient, //nolint:unparam // pyxisClient is currently unused.
pc PyxisClient, //nolint:unparam // PyxisClient is currently unused.
eng engine.CheckEngine,
formatter formatters.ResponseFormatter,
rw ResultWriter,
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions lib/types.go → certification/internal/lib/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import (
log "github.com/sirupsen/logrus"
)

// resultWriter defines methods associated with writing check results.
// ResultWriter defines methods associated with writing check results.
type ResultWriter interface {
OpenFile(name string) (io.WriteCloser, error)
io.WriteCloser
}

// resultSubmitter defines methods associated with submitting results to Red HAt.
// ResultSubmitter defines methods associated with submitting results to Red HAt.
type ResultSubmitter interface {
Submit(context.Context) error
}

// pyxisClient defines pyxis API interactions that are relevant to check executions in cmd.
// PyxisClient defines pyxis API interactions that are relevant to check executions in cmd.
type PyxisClient interface {
FindImagesByDigest(ctx context.Context, digests []string) ([]pyxis.CertImage, error)
GetProject(context.Context) (*pyxis.CertProject, error)
Expand All @@ -55,7 +55,7 @@ func NewPyxisClient(ctx context.Context, cfg certification.Config) PyxisClient {
}

// ContainerCertificationSubmitter submits container results to Pyxis, and implements
// a resultSubmitter.
// a ResultSubmitter.
type ContainerCertificationSubmitter struct {
CertificationProjectID string
Pyxis PyxisClient
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *ContainerCertificationSubmitter) Submit(ctx context.Context) error {
return nil
}

// noopSubmitter is a no-op resultSubmitter that optionally logs a message
// noopSubmitter is a no-op ResultSubmitter that optionally logs a message
// and a reason as to why results were not submitted.
type NoopSubmitter struct {
emitLog bool
Expand Down
2 changes: 1 addition & 1 deletion certification/runtime/result_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
)

// ResultWriterFile implements a resultWriter for use at preflight runtime.
// ResultWriterFile implements a ResultWriter for use at preflight runtime.
type ResultWriterFile struct {
file *os.File
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/check_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/formatters"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
"github.com/redhat-openshift-ecosystem/openshift-preflight/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/version"

log "github.com/sirupsen/logrus"
Expand Down
4 changes: 2 additions & 2 deletions cmd/check_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
"github.com/redhat-openshift-ecosystem/openshift-preflight/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/lib"
"github.com/spf13/viper"
)

Expand Down Expand Up @@ -151,7 +151,7 @@ certification_project_id: mycertid`
AfterEach(func() {
submit = origSubmitValue
})
It("should return a noopSubmitter resultSubmitter", func() {
It("should return a noopSubmitter ResultSubmitter", func() {
runner, err := lib.NewCheckContainerRunner(context.TODO(), cfg, false)
Expect(err).ToNot(HaveOccurred())
_, rsIsCorrectType := runner.Rs.(*lib.NoopSubmitter)
Expand Down
2 changes: 1 addition & 1 deletion cmd/check_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/formatters"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
"github.com/redhat-openshift-ecosystem/openshift-preflight/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/version"

log "github.com/sirupsen/logrus"
Expand Down
4 changes: 2 additions & 2 deletions cmd/check_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/formatters"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/policy"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
"github.com/redhat-openshift-ecosystem/openshift-preflight/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/lib"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -167,7 +167,7 @@ var _ = Describe("Check Operator", func() {
})
})

It("should contain a ResultWriterFile resultWriter", func() {
It("should contain a ResultWriterFile ResultWriter", func() {
runner, err := lib.NewCheckOperatorRunner(context.TODO(), cfg)
Expect(err).ToNot(HaveOccurred())
_, rwIsExpectedType := runner.Rw.(*runtime.ResultWriterFile)
Expand Down
2 changes: 1 addition & 1 deletion cmd/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/artifacts"
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime"
"github.com/redhat-openshift-ecosystem/openshift-preflight/lib"
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/lib"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
Loading

0 comments on commit 7a84034

Please sign in to comment.