Skip to content

Commit

Permalink
fix: compliance limit error
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan committed Apr 6, 2022
1 parent 76bd44a commit 0c06bab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ trivy:
#
# serverCustomHeaders: "foo=bar"
compliance:
# ClusterComplianceFailEntriesLimit the flag to limit the number of fail entries per control check in the cluster compliance detail report
# failEntriesLimit the flag to limit the number of fail entries per control check in the cluster compliance detail report
failEntriesLimit: 10
kubeBench:
imageRef: docker.io/aquasec/kube-bench:v0.6.6
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/get_clustercompliancereport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"

"k8s.io/client-go/kubernetes"

"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
Expand Down
31 changes: 3 additions & 28 deletions pkg/compliance/clustercompliancereport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/json"
fakesimple "k8s.io/client-go/kubernetes/fake"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -35,10 +33,8 @@ func loadResource(filePath string, resource interface{}) error {
}

var _ = ginkgo.Describe("cluster compliance report", func() {

logger := log.Log.WithName("operator")
config, err := getStarboardConfig()
Expect(err).ToNot(HaveOccurred())
config := getStarboardConfig()
ginkgo.Context("reconcile compliance spec report with cis-bench anc audit-config data and validate compliance reports data and requeue", func() {
var cisBenchList v1alpha1.CISKubeBenchReportList
err := loadResource("./testdata/fixture/cisBenchmarkReportList.json", &cisBenchList)
Expand Down Expand Up @@ -217,27 +213,6 @@ func getDetailReport(ctx context.Context, namespaceName types.NamespacedName, cl
return &report, nil
}

func getStarboardConfig() (starboard.ConfigData, error) {
clientset := fakesimple.NewSimpleClientset(
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: starboard.NamespaceName,
Name: starboard.ConfigMapName,
},
Data: map[string]string{
"compliance.failEntriesLimit": "1",
},
},
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: starboard.NamespaceName,
Name: starboard.SecretName,
},
Data: map[string][]byte{
"baz": []byte("s3cret"),
},
},
)
return starboard.NewConfigManager(clientset, starboard.NamespaceName).
Read(context.TODO())
func getStarboardConfig() starboard.ConfigData {
return starboard.ConfigData{"compliance.failEntriesLimit": "1"}
}

0 comments on commit 0c06bab

Please sign in to comment.