Skip to content

Commit

Permalink
Add OpenShift DeploymentConfig schema (#153)
Browse files Browse the repository at this point in the history
Co-authored-by: Stan Kozlov <[email protected]>
Co-authored-by: Cereberus <[email protected]>
  • Loading branch information
3 people authored Apr 7, 2021
1 parent b614a5d commit a8478ee
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/golangci/golangci-lint v1.30.0
github.com/mitchellh/mapstructure v1.1.2
github.com/openshift/api v3.9.0+incompatible
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5X
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
github.com/openshift/api v3.9.0+incompatible h1:fJ/KsefYuZAjmrr3+5U9yZIZbTOpVkDDLDLFresAeYs=
github.com/openshift/api v3.9.0+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
17 changes: 14 additions & 3 deletions pkg/lintcontext/parse_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package lintcontext
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"

y "github.com/ghodss/yaml"
ocsAppsV1 "github.com/openshift/api/apps/v1"
"github.com/pkg/errors"
"golang.stackrox.io/kube-linter/internal/k8sutil"
"helm.sh/helm/v3/pkg/chart"
Expand All @@ -31,10 +33,20 @@ const (
)

var (
clientSchema = scheme.Scheme
decoder = serializer.NewCodecFactory(clientSchema).UniversalDeserializer()
decoder runtime.Decoder
)

func init() {
clientScheme := scheme.Scheme

// Add OpenShift schema
schemeBuilder := runtime.NewSchemeBuilder(ocsAppsV1.AddToScheme)
if err := schemeBuilder.AddToScheme(clientScheme); err != nil {
panic(fmt.Sprintf("Can not add OpenShift schema %v", err))
}
decoder = serializer.NewCodecFactory(clientScheme).UniversalDeserializer()
}

func parseObjects(data []byte, d runtime.Decoder) ([]k8sutil.Object, error) {
if d == nil {
d = decoder
Expand Down Expand Up @@ -243,5 +255,4 @@ func (l *lintContextImpl) loadObjectsFromReader(filePath string, reader io.Reade
return err
}
}

}
2 changes: 2 additions & 0 deletions pkg/objectkinds/deployment_like.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package objectkinds
import (
"fmt"

ocsAppsV1 "github.com/openshift/api/apps/v1"
appsV1 "k8s.io/api/apps/v1"
batchV1 "k8s.io/api/batch/v1"
batchV1Beta1 "k8s.io/api/batch/v1beta1"
Expand All @@ -16,6 +17,7 @@ var (
for _, gk := range []schema.GroupKind{
{Group: appsV1.GroupName, Kind: "Deployment"},
{Group: appsV1.GroupName, Kind: "DaemonSet"},
{Group: ocsAppsV1.GroupName, Kind: "DeploymentConfig"},
{Group: appsV1.GroupName, Kind: "StatefulSet"},
{Group: appsV1.GroupName, Kind: "ReplicaSet"},
{Group: coreV1.GroupName, Kind: "Pod"},
Expand Down

0 comments on commit a8478ee

Please sign in to comment.