Skip to content

Commit 99437e5

Browse files
authored
chore: Convert AWS partitions data from resource to compiled Swift (#1890)
1 parent a3de344 commit 99437e5

File tree

8 files changed

+65
-13
lines changed

8 files changed

+65
-13
lines changed

AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ struct PrepareRelease {
207207
"Package.version.next",
208208
"packageDependencies.plist",
209209
"Sources/Services",
210-
"Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md"
210+
"Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md",
211+
"Sources/Core/AWSSDKPartitions/Source/AWSSDKPartitions/Partitions.swift",
211212
]
212213
case .smithySwift:
213214
files = ["Package.version", "Package.version.next"]

AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Resources/Package.Base.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extension Target.Dependency {
1010
static var awsSDKHTTPAuth: Self { "AWSSDKHTTPAuth" }
1111
static var awsSDKIdentity: Self { "AWSSDKIdentity" }
1212
static var awsSDKChecksums: Self { "AWSSDKChecksums" }
13+
static var awsSDKPartitions: Self { "AWSSDKPartitions" }
1314

1415
// CRT module
1516
static var crt: Self { .product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift") }
@@ -112,6 +113,7 @@ private var runtimeTargets: [Target] {
112113
.awsSDKHTTPAuth,
113114
.awsSDKIdentity,
114115
.awsSDKChecksums,
116+
.awsSDKPartitions,
115117
],
116118
path: "Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime",
117119
resources: [
@@ -142,7 +144,11 @@ private var runtimeTargets: [Target] {
142144
name: "AWSSDKChecksums",
143145
dependencies: [.crt, .smithy, .clientRuntime, .smithyChecksumsAPI, .smithyChecksums, .smithyHTTPAPI],
144146
path: "Sources/Core/AWSSDKChecksums/Sources"
145-
)
147+
),
148+
.target(
149+
name: "AWSSDKPartitions",
150+
path: "Sources/Core/AWSSDKPartitions/Sources"
151+
),
146152
]
147153
}
148154

AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Commands/PrepareReleaseTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PrepareReleaseTests: CLITestCase {
184184
ProcessRunner.testRunner = runner
185185
let subject = PrepareRelease.mock(repoType: .awsSdkSwift)
186186
try! subject.stageFiles()
187-
XCTAssertTrue(command.hasSuffix("git add Package.swift Package.version Package.version.next packageDependencies.plist Sources/Services Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md"))
187+
XCTAssertTrue(command.hasSuffix("git add Package.swift Package.version Package.version.next packageDependencies.plist Sources/Services Sources/Core/AWSSDKForSwift/Documentation.docc/AWSSDKForSwift.md Sources/Core/AWSSDKPartitions/Source/AWSSDKPartitions/Partitions.swift"))
188188
}
189189

190190
func testStageFilesForSmithySwift() {

Package.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ extension Target.Dependency {
439439
static var awsSDKHTTPAuth: Self { "AWSSDKHTTPAuth" }
440440
static var awsSDKIdentity: Self { "AWSSDKIdentity" }
441441
static var awsSDKChecksums: Self { "AWSSDKChecksums" }
442+
static var awsSDKPartitions: Self { "AWSSDKPartitions" }
442443

443444
// CRT module
444445
static var crt: Self { .product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift") }
@@ -541,6 +542,7 @@ private var runtimeTargets: [Target] {
541542
.awsSDKHTTPAuth,
542543
.awsSDKIdentity,
543544
.awsSDKChecksums,
545+
.awsSDKPartitions,
544546
],
545547
path: "Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime",
546548
resources: [
@@ -571,7 +573,11 @@ private var runtimeTargets: [Target] {
571573
name: "AWSSDKChecksums",
572574
dependencies: [.crt, .smithy, .clientRuntime, .smithyChecksumsAPI, .smithyChecksums, .smithyHTTPAPI],
573575
path: "Sources/Core/AWSSDKChecksums/Sources"
574-
)
576+
),
577+
.target(
578+
name: "AWSSDKPartitions",
579+
path: "Sources/Core/AWSSDKPartitions/Sources"
580+
),
575581
]
576582
}
577583

Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Endpoints/AWSPartitionDefinition.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
import Foundation
9-
10-
// SDK guarantees sdk-partitions.json will be present
11-
let partitionsFile = Bundle.module.url(forResource: "sdk-partitions", withExtension: "json")!
8+
import let AWSSDKPartitions.partitions
129

1310
// First-time load will take longer but subsequent calls will use cached data
14-
// swiftlint:disable:next force_try
15-
public let awsPartitionJSON = try! String(contentsOf: partitionsFile, encoding: .utf8)
11+
public let awsPartitionJSON = partitions

Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Resources/sdk-partitions.json Sources/Core/AWSSDKPartitions/Sources/AWSSDKPartitions/Partitions.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
// Code is auto-generated. DO NOT EDIT!
9+
10+
public let partitions = #"""
11+
12+
13+
114
{
215
"partitions" : [ {
316
"id" : "aws",
@@ -236,4 +249,5 @@
236249
}
237250
} ],
238251
"version" : "1.1"
239-
}
252+
}
253+
"""#

codegen/sdk-codegen/sdk-partitions.json

+21-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"supportsDualStack" : true,
1010
"supportsFIPS" : true
1111
},
12-
"regionRegex" : "^(us|eu|ap|sa|ca|me|af|il)\\-\\w+\\-\\d+$",
12+
"regionRegex" : "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$",
1313
"regions" : {
1414
"af-south-1" : {
1515
"description" : "Africa (Cape Town)"
@@ -44,6 +44,12 @@
4444
"ap-southeast-4" : {
4545
"description" : "Asia Pacific (Melbourne)"
4646
},
47+
"ap-southeast-5" : {
48+
"description" : "Asia Pacific (Malaysia)"
49+
},
50+
"ap-southeast-7" : {
51+
"description" : "Asia Pacific (Thailand)"
52+
},
4753
"aws-global" : {
4854
"description" : "AWS Standard global region"
4955
},
@@ -86,6 +92,9 @@
8692
"me-south-1" : {
8793
"description" : "Middle East (Bahrain)"
8894
},
95+
"mx-central-1" : {
96+
"description" : "Mexico (Central)"
97+
},
8998
"sa-east-1" : {
9099
"description" : "South America (Sao Paulo)"
91100
},
@@ -214,7 +223,17 @@
214223
"supportsFIPS" : true
215224
},
216225
"regionRegex" : "^us\\-isof\\-\\w+\\-\\d+$",
217-
"regions" : { }
226+
"regions" : {
227+
"aws-iso-f-global" : {
228+
"description" : "AWS ISOF global region"
229+
},
230+
"us-isof-east-1" : {
231+
"description" : "US ISOF EAST"
232+
},
233+
"us-isof-south-1" : {
234+
"description" : "US ISOF SOUTH"
235+
}
236+
}
218237
} ],
219238
"version" : "1.1"
220239
}

scripts/Partitions.base.swift

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
// Code is auto-generated. DO NOT EDIT!
9+
10+
public let partitions = #"""

0 commit comments

Comments
 (0)