-
Notifications
You must be signed in to change notification settings - Fork 88
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
Changes from all commits
0f2cc68
21b6b4a
cc5a69d
b0e7b9a
5461a34
e19824f
89cfb59
8e8d967
fc3f62e
33cd0ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
} | ||
|
@@ -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") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: ", ") + "]" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this doc as needed: https://quip-amazon.com/2Ou5ABMKxHXP/Adding-new-service-client-dependent-credential-resolvers
There was a problem hiding this comment.
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.