Skip to content

chore: Build service clients with exact dependencies #1996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ struct PackageManifestBuilder {
// Add the generated content that defines the list of services to include
buildServiceTargets(),
"",
// Add the dependencies for the internal clients
buildInternalAWSSTSDependencies(),
buildInternalAWSSSODependencies(),
buildInternalAWSSSOOIDCDependencies(),
"",
]
return contents.joined(separator: .newline)
}
Expand Down Expand Up @@ -139,10 +144,44 @@ struct PackageManifestBuilder {
/// This generates an array of strings, where the each item is a name of a service
/// and calls the `addServiceTarget` for each item.
private func buildServiceTargets() -> String {
guard !services.isEmpty else {
return "let serviceTargets: [String: [Target.Dependency]] = [:]"
}
var lines: [String] = []
lines += ["let serviceTargets: [String] = ["]
lines += services.map { " \($0.name.wrappedInQuotes())," }
lines += ["let serviceTargets: [String: [Target.Dependency]] = ["]
lines += services.map {
let jsonFilePath = "Sources/Services/\($0.name)/Dependencies.json"
let dependencies = clientDependencies(service: $0, jsonFilePath: jsonFilePath)
return " \($0.name.wrappedInQuotes()): \(dependencies),"
}
lines += ["]"]
return lines.joined(separator: .newline)
}

private func buildInternalAWSSTSDependencies() -> String {
buildInternalClientDependencies(name: "AWSSTS")
}

private func buildInternalAWSSSODependencies() -> String {
buildInternalClientDependencies(name: "AWSSSO")
}

private func buildInternalAWSSSOOIDCDependencies() -> String {
buildInternalClientDependencies(name: "AWSSSOOIDC")
Comment on lines +161 to +170
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder! The process had already changed when #1995 merged so this definitely needs revision.

}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three methods above create the dependency lists for the 3 internal clients.


private func buildInternalClientDependencies(name: String) -> String {
let jsonFilePath = "Sources/Core/AWSSDKIdentity/InternalClients/Internal\(name)/Dependencies.json"
let service = Service(name: name)
let dependencies = clientDependencies(service: service, jsonFilePath: jsonFilePath)
return "let internal\(name)Dependencies: [Target.Dependency] = \(dependencies)"
}

private func clientDependencies(service: Service, jsonFilePath: String) -> String {
let jsonFileData = FileManager.default.contents(atPath: jsonFilePath) ?? Data("[]".utf8)
let dependencies = try! JSONDecoder().decode([String].self, from: jsonFileData)
.filter { $0 != "SmithyTestUtil" } // links to test files only
return "[" + dependencies.map { ".\($0)" }.joined(separator: ", ") + "]"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method above takes the JSON in the generated code and makes it into a literal array of dependencies that can be used in a target.

}

Loading
Loading