Skip to content

Commit

Permalink
Use bmclib directly: (aws#6851)
Browse files Browse the repository at this point in the history
* Use bmclib directly:

Going through Rufio just for the bmclib
client means that we had to take on Rufio's
dependencies. This is problematic because Rufio
uses the controller-runtime lib. Using bmclib directly
alleviates us from this concern.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>

* Add Rufio CRDs for envtest:

This avoids having to pull in Rufio as
a dependency.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>

* Update tests that were comparing logr.Logger:

New version of logr.Logger broken some tests.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>

---------

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
  • Loading branch information
jacobweinstock authored Oct 19, 2023
1 parent 2ebd9e8 commit 1f53592
Show file tree
Hide file tree
Showing 7 changed files with 832 additions and 85 deletions.
26 changes: 13 additions & 13 deletions controllers/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,14 @@ func TestClusterReconcilerReconcileConditions(t *testing.T) {
log := testr.New(t)
logCtx := ctrl.LoggerInto(ctx, log)

iam.EXPECT().EnsureCASecret(logCtx, log, sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().Reconcile(logCtx, log, sameName(config.Cluster)).Return(controller.Result{}, nil)
providerReconciler.EXPECT().Reconcile(logCtx, log, sameName(config.Cluster)).Times(1)
clusterValidator.EXPECT().ValidateManagementClusterName(logCtx, log, sameName(config.Cluster)).Return(nil)
iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)
providerReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Times(1)
clusterValidator.EXPECT().ValidateManagementClusterName(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil)

mockPkgs.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())

mhcReconciler.EXPECT().Reconcile(logCtx, log, sameName(config.Cluster)).Return(nil)
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil)

r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, mhcReconciler)

Expand Down Expand Up @@ -619,11 +619,11 @@ func TestClusterReconcilerReconcileSelfManagedClusterConditions(t *testing.T) {
log := testr.New(t)
logCtx := ctrl.LoggerInto(ctx, log)

iam.EXPECT().EnsureCASecret(logCtx, log, sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().Reconcile(logCtx, log, sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)

providerReconciler.EXPECT().ReconcileWorkerNodes(gomock.Any(), gomock.Any(), gomock.Any()).Times(1)
mhcReconciler.EXPECT().Reconcile(logCtx, log, sameName(config.Cluster)).Return(nil)
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil)

r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, mhcReconciler)

Expand Down Expand Up @@ -1284,7 +1284,7 @@ func TestClusterReconcilerPackagesDeletion(s *testing.T) {
fakeClient := fake.NewClientBuilder().WithRuntimeObjects(objs...).Build()
nullRegistry := newRegistryForDummyProviderReconciler()
mockPkgs := mocks.NewMockPackagesClient(ctrl)
mockPkgs.EXPECT().ReconcileDelete(logCtx, log, gomock.Any(), gomock.Any()).Return(fmt.Errorf("test error"))
mockPkgs.EXPECT().ReconcileDelete(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.Any(), gomock.Any()).Return(fmt.Errorf("test error"))
mockIAM := mocks.NewMockAWSIamConfigReconciler(ctrl)
mockValid := mocks.NewMockClusterValidator(ctrl)
mhcReconciler := mocks.NewMockMachineHealthCheckReconciler(ctrl)
Expand Down Expand Up @@ -1359,11 +1359,11 @@ func TestClusterReconcilerPackagesInstall(s *testing.T) {
nullRegistry := newRegistryForDummyProviderReconciler()
mockIAM := mocks.NewMockAWSIamConfigReconciler(ctrl)
mockValid := mocks.NewMockClusterValidator(ctrl)
mockValid.EXPECT().ValidateManagementClusterName(logCtx, log, gomock.Any()).Return(nil)
mockValid.EXPECT().ValidateManagementClusterName(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.Any()).Return(nil)
mockPkgs := mocks.NewMockPackagesClient(ctrl)
mhcReconciler := mocks.NewMockMachineHealthCheckReconciler(ctrl)

mhcReconciler.EXPECT().Reconcile(logCtx, log, sameName(cluster)).Return(nil)
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(cluster)).Return(nil)

mockPkgs.EXPECT().
EnableFullLifecycle(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Expand Down Expand Up @@ -1413,8 +1413,8 @@ func TestClusterReconcilerValidateManagementEksaVersionFail(t *testing.T) {
log := testr.New(t)
logCtx := ctrl.LoggerInto(ctx, log)

iam.EXPECT().EnsureCASecret(logCtx, log, sameName(config.Cluster)).Return(controller.Result{}, nil)
clusterValidator.EXPECT().ValidateManagementClusterName(logCtx, log, sameName(config.Cluster)).Return(nil)
iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)
clusterValidator.EXPECT().ValidateManagementClusterName(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil)

r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, nil)

Expand Down
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/docker/cli v23.0.5+incompatible
github.com/go-git/go-git/v5 v5.4.2
github.com/go-jose/go-jose/v3 v3.0.0
github.com/go-logr/logr v1.2.3
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.3
github.com/gocarina/gocsv v0.0.0-20220304222734-caabc5f00d30
github.com/golang/mock v1.6.0
Expand All @@ -37,7 +37,6 @@ require (
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288
github.com/tinkerbell/rufio v0.3.0
github.com/tinkerbell/tink v0.8.0
github.com/vmware/govmomi v0.29.0
go.uber.org/zap v1.24.0
Expand Down Expand Up @@ -68,14 +67,15 @@ require (
sigs.k8s.io/yaml v1.3.0
)

require github.com/Masterminds/semver/v3 v3.2.0 // indirect

require (
dario.cat/mergo v1.0.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/PaesslerAG/gval v1.0.0 // indirect
github.com/PaesslerAG/jsonpath v0.1.1 // indirect
Expand All @@ -95,8 +95,8 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bmc-toolbox/bmclib/v2 v2.0.1-0.20230212165211-bac64498b8ba // indirect
github.com/bmc-toolbox/common v0.0.0-20221115135648-0b584f504396 // indirect
github.com/bmc-toolbox/bmclib/v2 v2.1.1-0.20231017114451-153e11d62a71
github.com/bmc-toolbox/common v0.0.0-20230220061748-93ff001f4a1d // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/containerd/containerd v1.7.0 // indirect
Expand All @@ -116,6 +116,7 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -137,9 +138,8 @@ require (
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jacobweinstock/go-amt v0.0.0-20221125040441-53475f4ae023 // indirect
github.com/jacobweinstock/registrar v0.4.6 // indirect
github.com/jacobweinstock/wsman v0.0.0-20221125035617-2eae65734c77 // indirect
github.com/jacobweinstock/iamt v0.0.0-20230502042727-d7cdbe67d9ef // indirect
github.com/jacobweinstock/registrar v0.4.7 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -175,15 +175,14 @@ require (
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stmcginnis/gofish v0.13.1-0.20221107140645-5cc43fad050f // indirect
github.com/stmcginnis/gofish v0.14.1-0.20230920133920-77490fd98fa2 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/vektah/gqlparser/v2 v2.4.5 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/term v0.8.0 // indirect
Expand Down
Loading

0 comments on commit 1f53592

Please sign in to comment.