Skip to content

Commit 3d9d15e

Browse files
committed
Add roleARN parameter to ManagerFor in resource manager factory
This commits upadtes the ManagerFor function generator in the resource manager factory to include the roleARN. The change also includes: - Updated `ManagerFor` function signature - Modified the rmId generation to incorporate `roleARN`, creating a unique identifier for each account/region/roleARN combination. - Update fake resource manager to match the new function signature
1 parent c30e068 commit 3d9d15e

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.22.4
66

77
require (
88
github.com/aws-controllers-k8s/pkg v0.0.15
9-
github.com/aws-controllers-k8s/runtime v0.37.1
9+
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f
1010
github.com/aws/aws-sdk-go v1.49.0
1111
github.com/dlclark/regexp2 v1.10.0 // indirect
1212
// pin to v0.1.1 due to release problem with v0.1.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ github.com/aws-controllers-k8s/pkg v0.0.15 h1:C1pnD/aDqJsU9oYf5upHkpSc+Hv4JQVtkd
7575
github.com/aws-controllers-k8s/pkg v0.0.15/go.mod h1:VvdjLWmR6IJ3KU8KByKiq/lJE8M+ur2piXysXKTGUS0=
7676
github.com/aws-controllers-k8s/runtime v0.37.1 h1:OKSG3WnswkazWgUtSZh3RApU6OK3l01LklP1DjWgEFY=
7777
github.com/aws-controllers-k8s/runtime v0.37.1/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
78+
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f h1:N5WNMehmiBNdthmGYlua3P0P+i6hctfGVEtPe4QHme8=
79+
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
7880
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
7981
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
8082
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

pkg/generate/ack/runtime_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (rmf *fakeRMF) ManagerFor(
9696
*session.Session,
9797
ackv1alpha1.AWSAccountID,
9898
ackv1alpha1.AWSRegion,
99+
ackv1alpha1.AWSResourceName,
99100
) (acktypes.AWSResourceManager, error) {
100101
return nil, nil
101102
}

templates/pkg/resource/manager_factory.go.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ func (f *resourceManagerFactory) ManagerFor(
4040
sess *session.Session,
4141
id ackv1alpha1.AWSAccountID,
4242
region ackv1alpha1.AWSRegion,
43+
roleARN ackv1alpha1.AWSResourceName,
4344
) (acktypes.AWSResourceManager, error) {
44-
rmId := fmt.Sprintf("%s/%s", id, region)
45+
// We use the account ID, region, and role ARN to uniquely identify a
46+
// resource manager. This helps us to avoid creating multiple resource
47+
// managers for the same account/region/roleARN combination.
48+
rmId := fmt.Sprintf("%s/%s/%s", id, region, roleARN)
4549
f.RLock()
4650
rm, found := f.rmCache[rmId]
4751
f.RUnlock()

0 commit comments

Comments
 (0)