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

Generate SCC-related resources when on OCP #179

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust discovery usage
Signed-off-by: Lucas Caparelli <lucas.caparelli112@gmail.com>
  • Loading branch information
LCaparelli committed Oct 23, 2020
commit 7df54e10a5631958614002eee61af56250969e22
3 changes: 2 additions & 1 deletion controllers/nexus/resource/networking/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ func TestManager_createIngress(t *testing.T) {
func TestManager_GetDeployedResources(t *testing.T) {
// first with no deployed resources
fakeClient := test.NewFakeClientBuilder().WithIngress().OnOpenshift().Build()
mgr, _ := NewManager(nodePortNexus, fakeClient, fakeClient)
discovery.SetClient(fakeClient)
mgr, _ := NewManager(nodePortNexus, fakeClient)

resources, err := mgr.GetDeployedResources()
assert.Nil(t, resources)
Expand Down
7 changes: 3 additions & 4 deletions controllers/nexus/resource/security/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import (
secv1 "github.com/openshift/api/security/v1"
core "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/m88i/nexus-operator/api/v1alpha1"
"github.com/m88i/nexus-operator/controllers/nexus/resource/validation"
"github.com/m88i/nexus-operator/pkg/cluster/openshift"
"github.com/m88i/nexus-operator/pkg/cluster/discovery"
"github.com/m88i/nexus-operator/pkg/framework"
"github.com/m88i/nexus-operator/pkg/logger"
)
Expand All @@ -44,7 +43,7 @@ type Manager struct {
}

// NewManager creates a security resources Manager
func NewManager(nexus *v1alpha1.Nexus, client client.Client, disc discovery.DiscoveryInterface) (*Manager, error) {
func NewManager(nexus *v1alpha1.Nexus, client client.Client) (*Manager, error) {
mgr := &Manager{
nexus: nexus,
client: client,
Expand All @@ -56,7 +55,7 @@ func NewManager(nexus *v1alpha1.Nexus, client client.Client, disc discovery.Disc
},
}

isOCP, err := openshift.IsOpenShift(disc)
isOCP, err := discovery.IsOpenShift()
if err != nil {
return nil, fmt.Errorf("unable to determine if on Openshift: %v", err)
}
Expand Down
6 changes: 4 additions & 2 deletions controllers/nexus/resource/security/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"reflect"
"testing"

"github.com/m88i/nexus-operator/pkg/cluster/discovery"
"github.com/m88i/nexus-operator/pkg/logger"

"github.com/stretchr/testify/assert"
Expand All @@ -38,11 +39,12 @@ func TestNewManager(t *testing.T) {
// so here we just check if the resulting manager took in the arguments correctly
nexus := baseNexus
client := test.NewFakeClientBuilder().Build()
discovery.SetClient(client)
want := &Manager{
nexus: nexus,
client: client,
}
got, err := NewManager(nexus, client, client)
got, err := NewManager(nexus, client)
assert.Nil(t, err)
assert.Equal(t, want.nexus, got.nexus)
assert.Equal(t, want.client, got.client)
Expand All @@ -69,7 +71,7 @@ func TestManager_GetRequiredResources(t *testing.T) {
func TestManager_GetDeployedResources(t *testing.T) {
// first with no deployed resources
fakeClient := test.NewFakeClientBuilder().Build()
mgr, _ := NewManager(baseNexus, fakeClient, fakeClient)
mgr, _ := NewManager(baseNexus, fakeClient)

resources, err := mgr.GetDeployedResources()
assert.Nil(t, resources)
Expand Down