Skip to content

Commit

Permalink
Last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedef committed Nov 24, 2020
1 parent 877e708 commit 6d2451e
Show file tree
Hide file tree
Showing 30 changed files with 254 additions and 248 deletions.
3 changes: 2 additions & 1 deletion bootstrap/eks/api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bootstrap/eks/api/v1alpha4/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions bootstrap/eks/controllers/eksconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"

"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -281,13 +282,14 @@ func (r *EKSConfigReconciler) storeBootstrapData(ctx context.Context, cluster *c

// MachineToBootstrapMapFunc is a handler.ToRequestsFunc to be used to enqueue requests
// for EKSConfig reconciliation
func (r *EKSConfigReconciler) MachineToBootstrapMapFunc(o handler.MapObject) []ctrl.Request {
func (r *EKSConfigReconciler) MachineToBootstrapMapFunc(o client.Object) []ctrl.Request {
result := []ctrl.Request{}

m, ok := o.Object.(*clusterv1.Machine)
m, ok := o.(*clusterv1.Machine)
if !ok {
return nil
panic(fmt.Sprintf("Expected a Machine but got a %T", o))
}

if m.Spec.Bootstrap.ConfigRef != nil && m.Spec.Bootstrap.ConfigRef.GroupVersionKind() == bootstrapv1.GroupVersion.WithKind("EKSConfig") {
name := client.ObjectKey{Namespace: m.Namespace, Name: m.Spec.Bootstrap.ConfigRef.Name}
result = append(result, ctrl.Request{NamespacedName: name})
Expand All @@ -297,13 +299,14 @@ func (r *EKSConfigReconciler) MachineToBootstrapMapFunc(o handler.MapObject) []c

// MachinePoolToBootstrapMapFunc is a handler.ToRequestsFunc to be uses to enqueue requests
// for EKSConfig reconciliation
func (r *EKSConfigReconciler) MachinePoolToBootstrapMapFunc(o handler.MapObject) []ctrl.Request {
func (r *EKSConfigReconciler) MachinePoolToBootstrapMapFunc(o client.Object) []ctrl.Request {
result := []ctrl.Request{}

m, ok := o.Object.(*expv1.MachinePool)
m, ok := o.(*expv1.MachinePool)
if !ok {
return nil
panic(fmt.Sprintf("Expected a MachinePool but got a %T", o))
}

configRef := m.Spec.Template.Spec.Bootstrap.ConfigRef
if configRef != nil && configRef.GroupVersionKind().GroupKind() == bootstrapv1.GroupVersion.WithKind("EKSConfig").GroupKind() {
name := client.ObjectKey{Namespace: m.Namespace, Name: configRef.Name}
Expand All @@ -315,12 +318,12 @@ func (r *EKSConfigReconciler) MachinePoolToBootstrapMapFunc(o handler.MapObject)

// ClusterToEKSConfigs is a handler.ToRequestsFunc to be used to enqueue requests for
// EKSConfig reconciliation
func (r *EKSConfigReconciler) ClusterToEKSConfigs(o handler.MapObject) []ctrl.Request {
func (r *EKSConfigReconciler) ClusterToEKSConfigs(o client.Object) []ctrl.Request {
result := []ctrl.Request{}

c, ok := o.Object.(*clusterv1.Cluster)
c, ok := o.(*clusterv1.Cluster)
if !ok {
return nil
panic(fmt.Sprintf("Expected a Cluster but got a %T", o))
}

selectors := []client.ListOption{
Expand All @@ -332,7 +335,6 @@ func (r *EKSConfigReconciler) ClusterToEKSConfigs(o handler.MapObject) []ctrl.Re

machineList := &clusterv1.MachineList{}
if err := r.Client.List(context.Background(), machineList, selectors...); err != nil {
r.Log.Error(err, "failed to list Machines for Cluster", "name", c.Name, "namespace", c.Namespace)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
bootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1alpha4"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/yaml"

"sigs.k8s.io/controller-runtime/pkg/log"
)

var _ = Describe("EKSConfigReconciler", func() {
Expand All @@ -52,12 +50,11 @@ var _ = Describe("EKSConfigReconciler", func() {
Expect(err).To(BeNil())

reconciler := EKSConfigReconciler{
Log: log.Log,
Client: testEnv.Client,
}

By("Calling reconcile should requeue")
result, err := reconciler.joinWorker(context.Background(), log.Log, cluster, config)
result, err := reconciler.joinWorker(context.Background(), cluster, config)
Expect(err).To(Succeed())
Expect(result.Requeue).To(BeFalse())
})
Expand Down
4 changes: 1 addition & 3 deletions bootstrap/eks/controllers/eksconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
. "github.com/onsi/gomega"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/cluster-api/test/helpers"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

Expand Down Expand Up @@ -64,11 +63,10 @@ func TestEKSConfigReconciler_ReturnEarlyIfClusterControlPlaneNotInitialized(t *t
testEnv = helpers.NewTestEnvironment()

reconciler := EKSConfigReconciler{
Log: log.Log,
Client: testEnv.Client,
}

result, err := reconciler.joinWorker(context.Background(), log.Log, cluster, config)
result, err := reconciler.joinWorker(context.Background(), cluster, config)
g.Expect(result).To(Equal(reconcile.Result{}))
g.Expect(err).NotTo(HaveOccurred())
}
3 changes: 2 additions & 1 deletion bootstrap/eks/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package controllers

import (
"context"
"testing"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -46,7 +47,7 @@ var _ = BeforeSuite(func(done Done) {
By("starting the manager")
go func() {
defer GinkgoRecover()
Expect(testEnv.StartManager()).To(Succeed())
Expect(testEnv.StartManager(context.Background())).To(Succeed())
}()

close(done)
Expand Down
1 change: 0 additions & 1 deletion bootstrap/eks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {

if err := (&bootstrapv1controllers.EKSConfigReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("EKSConfig"),
}).SetupWithManager(ctx, mgr, concurrency(eksConfigConcurrency)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "EKSConfig")
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterawsadm/api/bootstrap/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
utilpointer "k8s.io/utils/pointer"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterawsadm/api/bootstrap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/api/iam/v1alpha1"
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/awslabs/goformation/v4/cloudformation"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/api/iam/v1alpha1"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package bootstrap

import (
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/api/iam/v1alpha1"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterawsadm/cloudformation/bootstrap/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
bootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/api/bootstrap/v1alpha1"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/api/iam/v1alpha1"
"sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/converters"
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1alpha3"
infrav1exp "sigs.k8s.io/cluster-api-provider-aws/exp/api/v1alpha3"
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1alpha4"
infrav1exp "sigs.k8s.io/cluster-api-provider-aws/exp/api/v1alpha4"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterawsadm/cmd/alpha/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
awstags "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
"github.com/pkg/errors"
"github.com/spf13/cobra"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
"sigs.k8s.io/cluster-api-provider-aws/cmd/clusterawsadm/cmd/flags"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterawsadm/converters/cloudformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package converters

import (
"github.com/awslabs/goformation/v4/cloudformation/tags"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4"
)

// MapToCloudFormationTags converts a infrav1.Tags to []tags.Tag
Expand Down
Loading

0 comments on commit 6d2451e

Please sign in to comment.