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 static check for Check interface #761

Merged
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
2 changes: 2 additions & 0 deletions certification/internal/policy/container/base_on_ubi.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
pyxis "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/pyxis"
)

var _ certification.Check = &BasedOnUBICheck{}

// BasedOnUBICheck evaluates if the provided image is based on the Red Hat Universal Base Image.
type BasedOnUBICheck struct {
LayerHashCheckEngine layerHashChecker
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (

var errLicensesNotADir = errors.New("licenses is not a directory")

var _ certification.Check = &HasLicenseCheck{}

// HasLicenseCheck evaluates that the image contains a license definition available at
// /licenses.
type HasLicenseCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_modified_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &HasModifiedFilesCheck{}

// HasModifiedFilesCheck evaluates that no files from the base layer have been modified by
// subsequent layers by comparing the file list installed by Packages against the file list
// modified in subsequent layers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &HasNoProhibitedPackagesCheck{}

// HasProhibitedPackages evaluates that the image does not contain prohibited packages,
// which refers to packages that are not redistributable without an appropriate license.
type HasNoProhibitedPackagesCheck struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

var requiredLabels = []string{"name", "vendor", "version", "release", "summary", "description"}

var _ certification.Check = &HasRequiredLabelsCheck{}

// HasRequiredLabelsCheck evaluates the image manifest to ensure that the appropriate metadata
// labels are present on the image asset as it exists in its current container registry.
type HasRequiredLabelsCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_unique_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/authn"
)

var _ certification.Check = &hasUniqueTagCheck{}

func NewHasUniqueTagCheck(dockercfg string) *hasUniqueTagCheck {
return &hasUniqueTagCheck{
dockercfg: dockercfg,
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/max_layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
acceptableLayerMax = 40
)

var _ certification.Check = &MaxLayersCheck{}

// UnderLayerMaxCheck ensures that the image has less layers in its assembly than a predefined maximum.
type MaxLayersCheck struct{}

Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/runs_as_nonroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &RunAsNonRootCheck{}

// RunAsNonRootCheck evaluates the image to determine that the runtime UID is not 0,
// which correlates to the root user.
type RunAsNonRootCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/certified_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &certifiedImagesCheck{}

// imageFinder interface is used for testing. It represents the FindImagesByDigest
// function that is part of the Pyxis client.
type imageFinder interface {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/deployable_by_olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &DeployableByOlmCheck{}

type operatorData struct {
CatalogImage string
Channel string
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/related_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"sigs.k8s.io/yaml"
)

var _ certification.Check = &RelatedImagesCheck{}

type RelatedImagesCheck struct{}

func (p *RelatedImagesCheck) Validate(ctx context.Context, imgRef certification.ImageReference) (bool, error) {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/scc_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
)

var _ certification.Check = &securityContextConstraintsInCSV{}

// securityContextConstraintsInCSV evaluates the csv and logs a message if a non default security context constraint is
// needed by the operator
type securityContextConstraintsInCSV struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ScorecardBasicSpecCheck{}

// ScorecardBasicSpecCheck evaluates the image to ensure it passes the operator-sdk
// scorecard check with the basic-check-spec-test suite selected.
type ScorecardBasicSpecCheck struct {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/scorecard_olm_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ScorecardOlmSuiteCheck{}

// ScorecardOlmSuiteCheck evaluates the image to ensure it passes the operator-sdk
// scorecard check with the olm suite selected.
type ScorecardOlmSuiteCheck struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ValidateOperatorBundleCheck{}

// ValidateOperatorBundleCheck evaluates the image and ensures that it passes bundle validation
// as executed by `operator-sdk bundle validate`
type ValidateOperatorBundleCheck struct {
Expand Down