Skip to content

Commit

Permalink
post-rebase cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: rbtr <[email protected]>
  • Loading branch information
rbtr committed Jan 12, 2021
1 parent be456c6 commit e42b5fc
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 7 deletions.
5 changes: 3 additions & 2 deletions api/v1alpha2/zz_generated.conversion.go

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

16 changes: 16 additions & 0 deletions api/v1alpha3/awsprincipal_types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha3

import (
Expand Down
1 change: 1 addition & 0 deletions controllers/awsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ func (r *AWSMachineReconciler) getInfraCluster(ctx context.Context, log logr.Log
Client: r.Client,
Logger: log,
Cluster: cluster,
AWSCluster: awsCluster,
ExternalInfraCluster: externalInfraCluster,
ControllerName: "externalInfraCluster",
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (r *AWSManagedControlPlaneReconciler) Reconcile(req ctrl.Request) (res ctrl
return ctrl.Result{Requeue: true}, nil
}


if util.IsPaused(cluster, awsControlPlane) {
logger.Info("Reconciliation is paused for this object")
return ctrl.Result{}, nil
Expand All @@ -158,7 +157,7 @@ func (r *AWSManagedControlPlaneReconciler) Reconcile(req ctrl.Request) (res ctrl
Client: r.Client,
Logger: logger,
Cluster: cluster,
AWSCluster: awsCluster,
AWSCluster: awsCluster,
ControlPlane: awsControlPlane,
ControllerName: "awsmanagedcontrolplane",
EnableIAM: r.EnableIAM,
Expand Down
15 changes: 15 additions & 0 deletions exp/controllers/awsmanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
controlplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1alpha3"
infrav1exp "sigs.k8s.io/cluster-api-provider-aws/exp/api/v1alpha3"
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/scope"
Expand Down Expand Up @@ -139,11 +140,25 @@ func (r *AWSManagedMachinePoolReconciler) Reconcile(req ctrl.Request) (_ ctrl.Re
return ctrl.Result{}, nil
}

awsCluster := &infrav1.AWSCluster{}

infraClusterName := client.ObjectKey{
Namespace: machinePool.Namespace,
Name: cluster.Spec.InfrastructureRef.Name,
}

if err := r.Client.Get(ctx, infraClusterName, awsCluster); err != nil {
// AWSCluster is not ready
logger.Info("AWSCluster is not ready")
return reconcile.Result{}, nil
}

machinePoolScope, err := scope.NewManagedMachinePoolScope(scope.ManagedMachinePoolScopeParams{
Logger: logger,
Client: r.Client,
ControllerName: "awsmanagedmachinepool",
Cluster: cluster,
AWSCluster: awsCluster,
ControlPlane: controlPlane,
MachinePool: machinePool,
ManagedMachinePool: awsPool,
Expand Down
3 changes: 2 additions & 1 deletion pkg/cloud/scope/externalinfracluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ExternalInfraClusterScopeParams struct {
Client client.Client
Logger logr.Logger
Cluster *clusterv1.Cluster
AWSCluster *infrav1.AWSCluster
ExternalInfraCluster *unstructured.Unstructured
ControllerName string
Endpoints []ServiceEndpoint
Expand All @@ -60,7 +61,7 @@ func NewExternalInfraClusterScope(params ExternalInfraClusterScopeParams) (*Exte
if err != nil || !found {
return nil, fmt.Errorf("error getting region: %w", err)
}
session, err := sessionForRegion(region, params.Endpoints)
session, err := sessionForClusterWithRegion(params.Client, params.AWSCluster, region, params.Endpoints, params.Logger)
if err != nil {
return nil, errors.Errorf("failed to create aws session: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cloud/scope/managednodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ManagedMachinePoolScopeParams struct {
Client client.Client
Logger logr.Logger
Cluster *clusterv1.Cluster
AWSCluster *infrav1.AWSCluster
ControlPlane *controlplanev1exp.AWSManagedControlPlane
ManagedMachinePool *infrav1exp.AWSManagedMachinePool
MachinePool *clusterv1exp.MachinePool
Expand All @@ -64,7 +65,7 @@ func NewManagedMachinePoolScope(params ManagedMachinePoolScopeParams) (*ManagedM
params.Logger = klogr.New()
}

session, err := sessionForRegion(params.ControlPlane.Spec.Region, params.Endpoints)
session, err := sessionForClusterWithRegion(params.Client, params.AWSCluster, params.ControlPlane.Spec.Region, params.Endpoints, params.Logger)
if err != nil {
return nil, errors.Errorf("failed to create aws session: %v", err)
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/cloud/scope/principal.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scope

import (
"bytes"
"crypto/sha256"
"encoding/gob"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
Expand Down
19 changes: 18 additions & 1 deletion pkg/cloud/scope/session_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scope

import (
"context"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
Expand All @@ -12,7 +30,6 @@ import (
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"testing"
)

func TestPrincipalParsing(t *testing.T) {
Expand Down

0 comments on commit e42b5fc

Please sign in to comment.