Skip to content

Commit b61ebc6

Browse files
committed
unify import name
1 parent 15bea43 commit b61ebc6

8 files changed

+247
-247
lines changed

pkg/deploy/elbv2/target_group_binding_manager.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"sigs.k8s.io/aws-load-balancer-controller/pkg/annotations"
1616
"sigs.k8s.io/aws-load-balancer-controller/pkg/deploy/tracking"
1717
"sigs.k8s.io/aws-load-balancer-controller/pkg/k8s"
18-
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
18+
elbv2modelk8s "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
1919
"sigs.k8s.io/controller-runtime/pkg/client"
2020
"time"
2121
)
@@ -29,9 +29,9 @@ const (
2929

3030
// TargetGroupBindingManager is responsible for create/update/delete TargetGroupBinding resources.
3131
type TargetGroupBindingManager interface {
32-
Create(ctx context.Context, resTGB *elbv2model.TargetGroupBindingResource) (elbv2model.TargetGroupBindingResourceStatus, error)
32+
Create(ctx context.Context, resTGB *elbv2modelk8s.TargetGroupBindingResource) (elbv2modelk8s.TargetGroupBindingResourceStatus, error)
3333

34-
Update(ctx context.Context, resTGB *elbv2model.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) (elbv2model.TargetGroupBindingResourceStatus, error)
34+
Update(ctx context.Context, resTGB *elbv2modelk8s.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) (elbv2modelk8s.TargetGroupBindingResourceStatus, error)
3535

3636
Delete(ctx context.Context, k8sTGB *elbv2api.TargetGroupBinding) error
3737
}
@@ -64,10 +64,10 @@ type defaultTargetGroupBindingManager struct {
6464
waitTGBDeletionTimeout time.Duration
6565
}
6666

67-
func (m *defaultTargetGroupBindingManager) Create(ctx context.Context, resTGB *elbv2model.TargetGroupBindingResource) (elbv2model.TargetGroupBindingResourceStatus, error) {
67+
func (m *defaultTargetGroupBindingManager) Create(ctx context.Context, resTGB *elbv2modelk8s.TargetGroupBindingResource) (elbv2modelk8s.TargetGroupBindingResourceStatus, error) {
6868
k8sTGBSpec, err := buildK8sTargetGroupBindingSpec(ctx, resTGB)
6969
if err != nil {
70-
return elbv2model.TargetGroupBindingResourceStatus{}, err
70+
return elbv2modelk8s.TargetGroupBindingResourceStatus{}, err
7171
}
7272

7373
labels := m.trackingProvider.StackLabels(resTGB.Stack())
@@ -90,7 +90,7 @@ func (m *defaultTargetGroupBindingManager) Create(ctx context.Context, resTGB *e
9090
"stackID", resTGB.Stack().StackID(),
9191
"resourceID", resTGB.ID())
9292
if err := m.k8sClient.Create(ctx, k8sTGB); err != nil {
93-
return elbv2model.TargetGroupBindingResourceStatus{}, err
93+
return elbv2modelk8s.TargetGroupBindingResourceStatus{}, err
9494
}
9595
m.logger.Info("created targetGroupBinding",
9696
"stackID", resTGB.Stack().StackID(),
@@ -99,10 +99,10 @@ func (m *defaultTargetGroupBindingManager) Create(ctx context.Context, resTGB *e
9999
return buildResTargetGroupBindingStatus(k8sTGB), nil
100100
}
101101

102-
func (m *defaultTargetGroupBindingManager) Update(ctx context.Context, resTGB *elbv2model.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) (elbv2model.TargetGroupBindingResourceStatus, error) {
102+
func (m *defaultTargetGroupBindingManager) Update(ctx context.Context, resTGB *elbv2modelk8s.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) (elbv2modelk8s.TargetGroupBindingResourceStatus, error) {
103103
k8sTGBSpec, err := buildK8sTargetGroupBindingSpec(ctx, resTGB)
104104
if err != nil {
105-
return elbv2model.TargetGroupBindingResourceStatus{}, err
105+
return elbv2modelk8s.TargetGroupBindingResourceStatus{}, err
106106
}
107107

108108
calculatedLabels := m.trackingProvider.StackLabels(resTGB.Stack())
@@ -129,10 +129,10 @@ func (m *defaultTargetGroupBindingManager) Update(ctx context.Context, resTGB *e
129129
"targetGroupBinding", k8s.NamespacedName(k8sTGB))
130130

131131
if err := m.k8sClient.Patch(ctx, k8sTGB, client.MergeFrom(oldK8sTGB)); err != nil {
132-
return elbv2model.TargetGroupBindingResourceStatus{}, err
132+
return elbv2modelk8s.TargetGroupBindingResourceStatus{}, err
133133
}
134134
if err := m.waitUntilTargetGroupBindingObserved(ctx, k8sTGB); err != nil {
135-
return elbv2model.TargetGroupBindingResourceStatus{}, err
135+
return elbv2modelk8s.TargetGroupBindingResourceStatus{}, err
136136
}
137137
m.logger.Info("modified targetGroupBinding",
138138
"stackID", resTGB.Stack().StackID(),
@@ -189,7 +189,7 @@ func (m *defaultTargetGroupBindingManager) waitUntilTargetGroupBindingDeleted(ct
189189
}, ctx.Done())
190190
}
191191

192-
func buildK8sTargetGroupBindingSpec(ctx context.Context, resTGB *elbv2model.TargetGroupBindingResource) (elbv2api.TargetGroupBindingSpec, error) {
192+
func buildK8sTargetGroupBindingSpec(ctx context.Context, resTGB *elbv2modelk8s.TargetGroupBindingResource) (elbv2api.TargetGroupBindingSpec, error) {
193193
tgARN, err := resTGB.Spec.Template.Spec.TargetGroupARN.Resolve(ctx)
194194
if err != nil {
195195
return elbv2api.TargetGroupBindingSpec{}, err
@@ -216,7 +216,7 @@ func buildK8sTargetGroupBindingSpec(ctx context.Context, resTGB *elbv2model.Targ
216216
return k8sTGBSpec, nil
217217
}
218218

219-
func buildK8sTargetGroupBindingNetworking(ctx context.Context, resTGBNetworking elbv2model.TargetGroupBindingNetworking) (elbv2api.TargetGroupBindingNetworking, error) {
219+
func buildK8sTargetGroupBindingNetworking(ctx context.Context, resTGBNetworking elbv2modelk8s.TargetGroupBindingNetworking) (elbv2api.TargetGroupBindingNetworking, error) {
220220
k8sIngress := make([]elbv2api.NetworkingIngressRule, 0, len(resTGBNetworking.Ingress))
221221
for _, rule := range resTGBNetworking.Ingress {
222222
k8sPeers := make([]elbv2api.NetworkingPeer, 0, len(rule.From))
@@ -237,7 +237,7 @@ func buildK8sTargetGroupBindingNetworking(ctx context.Context, resTGBNetworking
237237
}, nil
238238
}
239239

240-
func buildK8sNetworkingPeer(ctx context.Context, resNetworkingPeer elbv2model.NetworkingPeer) (elbv2api.NetworkingPeer, error) {
240+
func buildK8sNetworkingPeer(ctx context.Context, resNetworkingPeer elbv2modelk8s.NetworkingPeer) (elbv2api.NetworkingPeer, error) {
241241
if resNetworkingPeer.IPBlock != nil {
242242
return elbv2api.NetworkingPeer{
243243
IPBlock: resNetworkingPeer.IPBlock,
@@ -257,8 +257,8 @@ func buildK8sNetworkingPeer(ctx context.Context, resNetworkingPeer elbv2model.Ne
257257
return elbv2api.NetworkingPeer{}, errors.New("either ipBlock or securityGroup should be specified")
258258
}
259259

260-
func buildResTargetGroupBindingStatus(k8sTGB *elbv2api.TargetGroupBinding) elbv2model.TargetGroupBindingResourceStatus {
261-
return elbv2model.TargetGroupBindingResourceStatus{
260+
func buildResTargetGroupBindingStatus(k8sTGB *elbv2api.TargetGroupBinding) elbv2modelk8s.TargetGroupBindingResourceStatus {
261+
return elbv2modelk8s.TargetGroupBindingResourceStatus{
262262
TargetGroupBindingRef: corev1.ObjectReference{
263263
Namespace: k8sTGB.Namespace,
264264
Name: k8sTGB.Name,
@@ -268,7 +268,7 @@ func buildResTargetGroupBindingStatus(k8sTGB *elbv2api.TargetGroupBinding) elbv2
268268
}
269269

270270
// tgbAnnotationsSame performs map equality with the two sets of annotations. Will ignore the check point annotations inserted by the TGB reconciler.
271-
func tgbAnnotationsSame(resTGB *elbv2model.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) bool {
271+
func tgbAnnotationsSame(resTGB *elbv2modelk8s.TargetGroupBindingResource, k8sTGB *elbv2api.TargetGroupBinding) bool {
272272
annotationsNoCheckpoint := make(map[string]string)
273273

274274
if k8sTGB.Annotations != nil {

pkg/deploy/elbv2/target_group_binding_manager_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"sigs.k8s.io/aws-load-balancer-controller/pkg/annotations"
1212
"sigs.k8s.io/aws-load-balancer-controller/pkg/deploy/tracking"
1313
coremodel "sigs.k8s.io/aws-load-balancer-controller/pkg/model/core"
14-
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
14+
elbv2modelk8s "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
1515
"sigs.k8s.io/aws-load-balancer-controller/pkg/testutils"
1616
"sigs.k8s.io/controller-runtime/pkg/client"
1717
"testing"
@@ -23,18 +23,18 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
2323
ipv4AddressType := elbv2api.IPAddressTypeIPV4
2424
testCases := []struct {
2525
name string
26-
spec elbv2model.TargetGroupBindingResourceSpec
26+
spec elbv2modelk8s.TargetGroupBindingResourceSpec
2727
expected elbv2api.TargetGroupBinding
2828
}{
2929
{
3030
name: "just spec, no labels or annotation",
31-
spec: elbv2model.TargetGroupBindingResourceSpec{
32-
Template: elbv2model.TargetGroupBindingTemplate{
31+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
32+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
3333
ObjectMeta: metav1.ObjectMeta{
3434
Name: "tgb",
3535
Namespace: "tgb-ns",
3636
},
37-
Spec: elbv2model.TargetGroupBindingSpec{
37+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
3838
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
3939
TargetType: &instanceTargetType,
4040
ServiceRef: elbv2api.ServiceReference{
@@ -69,8 +69,8 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
6969
},
7070
{
7171
name: "just spec, labels. no annotation",
72-
spec: elbv2model.TargetGroupBindingResourceSpec{
73-
Template: elbv2model.TargetGroupBindingTemplate{
72+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
73+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
7474
ObjectMeta: metav1.ObjectMeta{
7575
Name: "tgb",
7676
Namespace: "tgb-ns",
@@ -79,7 +79,7 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
7979
"baz": "bat",
8080
},
8181
},
82-
Spec: elbv2model.TargetGroupBindingSpec{
82+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
8383
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
8484
TargetType: &instanceTargetType,
8585
ServiceRef: elbv2api.ServiceReference{
@@ -116,8 +116,8 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
116116
},
117117
{
118118
name: "spec, labels, annotation",
119-
spec: elbv2model.TargetGroupBindingResourceSpec{
120-
Template: elbv2model.TargetGroupBindingTemplate{
119+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
120+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
121121
ObjectMeta: metav1.ObjectMeta{
122122
Name: "tgb",
123123
Namespace: "tgb-ns",
@@ -130,7 +130,7 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
130130
"ann3": "ann4",
131131
},
132132
},
133-
Spec: elbv2model.TargetGroupBindingSpec{
133+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
134134
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
135135
TargetType: &instanceTargetType,
136136
ServiceRef: elbv2api.ServiceReference{
@@ -177,7 +177,7 @@ func Test_defaultTargetGroupBindingManager_Create(t *testing.T) {
177177
Namespace: "test-ns",
178178
Name: "test-stack",
179179
}))
180-
resTGB := elbv2model.NewTargetGroupBindingResource(stack, "my-tgb", tc.spec)
180+
resTGB := elbv2modelk8s.NewTargetGroupBindingResource(stack, "my-tgb", tc.spec)
181181
manager, k8sClient := createTestDefaultTargetGroupBindingManager()
182182
status, err := manager.Create(context.Background(), resTGB)
183183
assert.NoError(t, err)
@@ -198,19 +198,19 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
198198
ipv4AddressType := elbv2api.IPAddressTypeIPV4
199199
testCases := []struct {
200200
name string
201-
spec elbv2model.TargetGroupBindingResourceSpec
201+
spec elbv2modelk8s.TargetGroupBindingResourceSpec
202202
existing elbv2api.TargetGroupBinding
203203
expected elbv2api.TargetGroupBinding
204204
}{
205205
{
206206
name: "just spec, no labels or annotation",
207-
spec: elbv2model.TargetGroupBindingResourceSpec{
208-
Template: elbv2model.TargetGroupBindingTemplate{
207+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
208+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
209209
ObjectMeta: metav1.ObjectMeta{
210210
Name: "tgb",
211211
Namespace: "tgb-ns",
212212
},
213-
Spec: elbv2model.TargetGroupBindingSpec{
213+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
214214
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
215215
TargetType: &instanceTargetType,
216216
ServiceRef: elbv2api.ServiceReference{
@@ -264,8 +264,8 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
264264
},
265265
{
266266
name: "spec labels annotation",
267-
spec: elbv2model.TargetGroupBindingResourceSpec{
268-
Template: elbv2model.TargetGroupBindingTemplate{
267+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
268+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
269269
ObjectMeta: metav1.ObjectMeta{
270270
Name: "tgb",
271271
Namespace: "tgb-ns",
@@ -277,7 +277,7 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
277277
"ann3": "ann4",
278278
},
279279
},
280-
Spec: elbv2model.TargetGroupBindingSpec{
280+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
281281
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
282282
TargetType: &instanceTargetType,
283283
ServiceRef: elbv2api.ServiceReference{
@@ -336,8 +336,8 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
336336
},
337337
{
338338
name: "only diff is checkpoint annotation, no update",
339-
spec: elbv2model.TargetGroupBindingResourceSpec{
340-
Template: elbv2model.TargetGroupBindingTemplate{
339+
spec: elbv2modelk8s.TargetGroupBindingResourceSpec{
340+
Template: elbv2modelk8s.TargetGroupBindingTemplate{
341341
ObjectMeta: metav1.ObjectMeta{
342342
Name: "tgb",
343343
Namespace: "tgb-ns",
@@ -349,7 +349,7 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
349349
"ann3": "ann4",
350350
},
351351
},
352-
Spec: elbv2model.TargetGroupBindingSpec{
352+
Spec: elbv2modelk8s.TargetGroupBindingSpec{
353353
TargetGroupARN: coremodel.LiteralStringToken("arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-echoserv-brokentg-0b7ba7f4ef/ae85b8ea9fb69748"),
354354
TargetType: &instanceTargetType,
355355
ServiceRef: elbv2api.ServiceReference{
@@ -422,7 +422,7 @@ func Test_defaultTargetGroupBindingManager_Update(t *testing.T) {
422422
Namespace: "test-ns",
423423
Name: "test-stack",
424424
}))
425-
resTGB := elbv2model.NewTargetGroupBindingResource(stack, "my-tgb", tc.spec)
425+
resTGB := elbv2modelk8s.NewTargetGroupBindingResource(stack, "my-tgb", tc.spec)
426426
manager, k8sClient := createTestDefaultTargetGroupBindingManager()
427427

428428
err := k8sClient.Create(context.Background(), &tc.existing)

pkg/deploy/elbv2/target_group_binding_synthesizer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
88
"sigs.k8s.io/aws-load-balancer-controller/pkg/deploy/tracking"
99
"sigs.k8s.io/aws-load-balancer-controller/pkg/model/core"
10-
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
10+
elbv2modelk8s "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2/k8s"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212
)
1313

@@ -36,7 +36,7 @@ type targetGroupBindingSynthesizer struct {
3636
}
3737

3838
func (s *targetGroupBindingSynthesizer) Synthesize(ctx context.Context) error {
39-
var resTGBs []*elbv2model.TargetGroupBindingResource
39+
var resTGBs []*elbv2modelk8s.TargetGroupBindingResource
4040
s.stack.ListResources(&resTGBs)
4141
k8sTGBs, err := s.findK8sTargetGroupBindings(ctx)
4242
if err != nil {
@@ -91,13 +91,13 @@ func (s *targetGroupBindingSynthesizer) findK8sTargetGroupBindings(ctx context.C
9191
}
9292

9393
type resAndK8sTargetGroupBindingPair struct {
94-
resTGB *elbv2model.TargetGroupBindingResource
94+
resTGB *elbv2modelk8s.TargetGroupBindingResource
9595
k8sTGB *elbv2api.TargetGroupBinding
9696
}
9797

98-
func matchResAndK8sTargetGroupBindings(resTGBs []*elbv2model.TargetGroupBindingResource, k8sTGBs []*elbv2api.TargetGroupBinding) ([]resAndK8sTargetGroupBindingPair, []*elbv2model.TargetGroupBindingResource, []*elbv2api.TargetGroupBinding, error) {
98+
func matchResAndK8sTargetGroupBindings(resTGBs []*elbv2modelk8s.TargetGroupBindingResource, k8sTGBs []*elbv2api.TargetGroupBinding) ([]resAndK8sTargetGroupBindingPair, []*elbv2modelk8s.TargetGroupBindingResource, []*elbv2api.TargetGroupBinding, error) {
9999
var matchedResAndK8sTGBs []resAndK8sTargetGroupBindingPair
100-
var unmatchedResTGBs []*elbv2model.TargetGroupBindingResource
100+
var unmatchedResTGBs []*elbv2modelk8s.TargetGroupBindingResource
101101
var unmatchedK8sTGBs []*elbv2api.TargetGroupBinding
102102
resTGBsByARN, err := mapResTargetGroupBindingByARN(resTGBs)
103103
if err != nil {
@@ -126,9 +126,9 @@ func matchResAndK8sTargetGroupBindings(resTGBs []*elbv2model.TargetGroupBindingR
126126
return matchedResAndK8sTGBs, unmatchedResTGBs, unmatchedK8sTGBs, nil
127127
}
128128

129-
func mapResTargetGroupBindingByARN(resTGBs []*elbv2model.TargetGroupBindingResource) (map[string]*elbv2model.TargetGroupBindingResource, error) {
129+
func mapResTargetGroupBindingByARN(resTGBs []*elbv2modelk8s.TargetGroupBindingResource) (map[string]*elbv2modelk8s.TargetGroupBindingResource, error) {
130130
ctx := context.Background()
131-
resTGBsByARN := make(map[string]*elbv2model.TargetGroupBindingResource, len(resTGBs))
131+
resTGBsByARN := make(map[string]*elbv2modelk8s.TargetGroupBindingResource, len(resTGBs))
132132
for _, resTGB := range resTGBs {
133133
tgARN, err := resTGB.Spec.Template.Spec.TargetGroupARN.Resolve(ctx)
134134
if err != nil {

0 commit comments

Comments
 (0)