Skip to content

Commit

Permalink
update k8s pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
dwertent committed Dec 21, 2021
1 parent 214f16e commit 9880430
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/armosec/armoapi-go v0.0.23
github.com/armosec/k8s-interface v0.0.46
github.com/armosec/k8s-interface v0.0.49
github.com/francoispqt/gojay v1.2.13
github.com/open-policy-agent/opa v0.33.1
github.com/stretchr/testify v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ github.com/armosec/armoapi-go v0.0.2/go.mod h1:vIK17yoKbJRQyZXWWLe3AqfqCRITxW8qm
github.com/armosec/armoapi-go v0.0.23 h1:jqoLIWM5CR7DCD9fpFgN0ePqtHvOCoZv/XzCwsUluJU=
github.com/armosec/armoapi-go v0.0.23/go.mod h1:iaVVGyc23QGGzAdv4n+szGQg3Rbpixn9yQTU3qWRpaw=
github.com/armosec/k8s-interface v0.0.8/go.mod h1:xxS+V5QT3gVQTwZyAMMDrYLWGrfKOpiJ7Jfhfa0w9sM=
github.com/armosec/k8s-interface v0.0.46 h1:qfCGWtbDCRQg8le2K1OveL94Y3dvGuamHmIJZ61+qqs=
github.com/armosec/k8s-interface v0.0.46/go.mod h1:vHxGWqD/uh6+GQb9Sqv7OGMs+Rvc2dsFVc0XtgRh1ZU=
github.com/armosec/k8s-interface v0.0.49 h1:5MhQJjKRtFDnZByqhlCZ+CZoLNeaJ91a/AErkrtR9Pg=
github.com/armosec/k8s-interface v0.0.49/go.mod h1:vHxGWqD/uh6+GQb9Sqv7OGMs+Rvc2dsFVc0XtgRh1ZU=
github.com/armosec/rbac-utils v0.0.1 h1:N2MI98F/0zbDjmRZ29CNElU1AXkFLk5csd/qAHOBdXY=
github.com/armosec/rbac-utils v0.0.1/go.mod h1:pQ8CBiij8kSKV7aeZm9FMvtZN28VgA7LZcYyTWimq40=
github.com/armosec/utils-go v0.0.2/go.mod h1:itWmRLzRdsnwjpEOomL0mBWGnVNNIxSjDAdyc+b0iUo=
Expand Down
3 changes: 2 additions & 1 deletion objectsenvelopes/objectshandler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package objectsenvelopes

import (
"github.com/armosec/k8s-interface/cloudsupport/apis"
cloudsupportv1 "github.com/armosec/k8s-interface/cloudsupport/v1"
"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/k8s-interface/workloadinterface"
Expand Down Expand Up @@ -32,7 +33,7 @@ func GetObjectType(object map[string]interface{}) workloadinterface.ObjectType {
if hostsensor.IsTypeTypeHostSensor(object) {
return hostsensor.TypeHostSensor
}
if cloudsupportv1.IsTypeDescriptiveInfoFromCloudProvider(object) {
if apis.IsTypeDescriptiveInfoFromCloudProvider(object) {
return cloudsupportv1.TypeCloudProviderDescribe
}
if k8sinterface.IsTypeWorkload(object) {
Expand Down
4 changes: 0 additions & 4 deletions objectsenvelopes/regoresponsevectorobject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"testing"

"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/k8s-interface/workloadinterface"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -36,7 +35,6 @@ func assertObjectFields(t *testing.T, b workloadinterface.IMetadata) {
assert.Equal(t, "/default/User/[email protected]/rbac.authorization.k8s.io/v1/default/Role/pod-reader/rbac.authorization.k8s.io/v1/default/RoleBinding/read-pods", b.GetID())
}
func TestNewRegoResponseVectorObject(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

relatedObjects := []map[string]interface{}{}
relatedObject := getMock(role)
Expand All @@ -56,7 +54,6 @@ func TestNewRegoResponseVectorObject(t *testing.T) {
}

func TestSetGetObject(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

obj := `{"name":"Jane","namespace":"","kind":"User","apiVersion":""}`
relatedObjects := []map[string]interface{}{}
Expand Down Expand Up @@ -88,7 +85,6 @@ func TestSetGetObject(t *testing.T) {
}

func TestVectorObjGetters(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

v, err := NewRegoResponseVectorObjectFromBytes([]byte(subjectSA))
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions reporthandling/datastructures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"testing"

"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/k8s-interface/workloadinterface"
"github.com/stretchr/testify/assert"
)
Expand All @@ -22,7 +21,6 @@ func TestMockPolicyNotificationA(t *testing.T) {
}

func TestPostureReportWithK8SResource(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

expectedID := "apps/v1/default/Deployment/demoservice-server"
report := MockPostureReportA()
Expand Down
2 changes: 0 additions & 2 deletions reporthandling/datastructuresmethods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"testing"

"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/opa-utils/reporthandling/mock"
"github.com/stretchr/testify/assert"
)
Expand All @@ -26,7 +25,6 @@ func ControlsResultsMock(report string) ([]ControlReport, error) {
}

func TestControlsResults(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

framework, err := FrameworkResultsMock(mock.NSAScanV10119)
assert.NoError(t, err, err)
Expand Down
2 changes: 0 additions & 2 deletions reporthandling/regoresourcesaggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"testing"

"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/k8s-interface/workloadinterface"
"github.com/armosec/opa-utils/objectsenvelopes"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -36,7 +35,6 @@ func TestAggregateResourcesBySubjects(t *testing.T) {
}

func TestAggregateResourcesBySubjects2(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

r := make(map[string]interface{})
err := json.Unmarshal([]byte(role), &r)
Expand Down
2 changes: 0 additions & 2 deletions reporthandling/v2/datastructures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (
"time"

"github.com/armosec/armoapi-go/armotypes"
"github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/opa-utils/objectsenvelopes"
"github.com/armosec/opa-utils/reporthandling"
"github.com/stretchr/testify/assert"
)

func GetPostureReportMock() *PostureReport {
k8sinterface.InitializeMapResourcesMock()

resource := []Resource{}
err := json.Unmarshal([]byte(ResourcesListMock), &resource)
Expand Down
3 changes: 0 additions & 3 deletions score/score_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package score
import (
"testing"

k8sinterface "github.com/armosec/k8s-interface/k8sinterface"
"github.com/armosec/k8s-interface/workloadinterface"
)

func TestReplicaScore(t *testing.T) {
k8sinterface.InitializeMapResourcesMock()

deployment := getResourceByType("deployment")
if wl := workloadinterface.NewWorkloadObj(deployment); wl == nil || wl.GetReplicas() != 3 {
t.Errorf("invalid wl was put into the test, should have 3 replicas %v", deployment)
Expand Down

0 comments on commit 9880430

Please sign in to comment.