Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0a33aa9
auth package refactored to be async now
kneekey23 Jul 1, 2021
1a773d7
remove queue and depend on Deque type
kneekey23 Jul 2, 2021
870227c
refactor continuation code to be smoother and clenaer
kneekey23 Jul 2, 2021
553bea5
change macos platform requirement
kneekey23 Jul 2, 2021
3ab97f7
saving async work to test on linux
kneekey23 Jul 2, 2021
4dae96c
testing on async locally on linux works
kneekey23 Jul 7, 2021
e3c4505
save changes to credentials provider
kneekey23 Jul 8, 2021
6e884e5
added config to run in linux container
kneekey23 Jul 8, 2021
ab6c51f
refactored retryer now to use async
kneekey23 Jul 9, 2021
2e83313
refactored retryer now to use async
kneekey23 Jul 9, 2021
4b987f3
refactor client connection maanger to use async
kneekey23 Jul 9, 2021
40b66f6
refactored resolver function to be async
kneekey23 Jul 9, 2021
b3ec751
fix build
kneekey23 Nov 4, 2021
2fb493a
lint
kneekey23 Nov 4, 2021
4fb7c18
linter is a pain
kneekey23 Nov 4, 2021
489ef10
update ci to use xcode 13.2
kneekey23 Nov 4, 2021
725e6fb
update ci to use xcode 13.2 correctly
kneekey23 Nov 4, 2021
5caf431
update version of crt builder
kneekey23 Nov 4, 2021
bb3090f
fix ci
kneekey23 Nov 4, 2021
5861cc9
change ci back
kneekey23 Nov 4, 2021
c2eb6d8
refctored imds client to be all async
kneekey23 Nov 4, 2021
2482ce8
refactor credentials provider tobe async throws
kneekey23 Nov 4, 2021
321dfbf
update ci to new version
kneekey23 Nov 4, 2021
f8c5af7
change builder commmands to get ci to work
kneekey23 Nov 11, 2021
47150fc
fix mac os ci
kneekey23 Nov 11, 2021
817c522
another attempt for ci
kneekey23 Nov 11, 2021
077b2f7
lint
kneekey23 Nov 11, 2021
92b7f8d
fix ci jobs to actually run when another fails
kneekey23 Nov 11, 2021
25edc57
coming for you macos ci
kneekey23 Nov 11, 2021
147afc2
remove warnings on linux
kneekey23 Nov 11, 2021
83f92b1
update macos again
kneekey23 Nov 11, 2021
23ee185
remvoe tests from compilation
kneekey23 Nov 11, 2021
caeefba
linting
kneekey23 Nov 11, 2021
a1566ea
support for linux
kneekey23 Nov 11, 2021
f0d30de
support for macos
kneekey23 Nov 12, 2021
485d3b4
add script
kneekey23 Nov 12, 2021
bda1ef1
update tests
kneekey23 Nov 16, 2021
786b22a
all tests now working
kneekey23 Nov 17, 2021
74bb2ef
remove unnecessary script now
kneekey23 Nov 17, 2021
58d9242
lint
kneekey23 Nov 17, 2021
d1a3590
comment out centos version
kneekey23 Nov 17, 2021
87c1705
update tear down function
kneekey23 Nov 17, 2021
95856e5
trying something
kneekey23 Dec 20, 2021
0e21f37
fixed one bug in mac os build still one to fix
kneekey23 Dec 21, 2021
891baa7
remove linker commands and update to xcode 13.2.1
kneekey23 Dec 21, 2021
fd6a0ea
save builder json files
kneekey23 Dec 21, 2021
9f35c0a
fix linter
kneekey23 Dec 21, 2021
b377647
update builder with new swift images
kneekey23 Dec 22, 2021
19c451d
bug fixes
kneekey23 Jan 3, 2022
690949f
fix linter
kneekey23 Jan 3, 2022
2dc4118
remove commented out line
kneekey23 Jan 3, 2022
d10b126
remove not needed optional on stream
kneekey23 Jan 20, 2022
a249c63
add exclude to remove warning
kneekey23 Feb 10, 2022
e96e7cb
fix linter
kneekey23 Feb 10, 2022
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
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM swiftlang/swift:nightly-5.5-focal

WORKDIR /package

COPY . ./

# to test on al2 swift images uncomment this and comment out other line.
# RUN yum -y install openssl-devel
RUN apt-get update -qq
RUN apt-get -y install libssl-dev

# RUN swift package clean

# RUN swift build --verbose

CMD ["swift", "test", "-Xcc", "-g"]
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "AWS Swift CRT",
"dockerFile": "Dockerfile",
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt", "seccomp=unconfined"],
// Uncomment the next line if you want to publish any ports.
// "appPort": [8080, 1234],
"extensions": [
"pvasek.sourcekit-lsp--dev-unofficial",
"vadimcn.vscode-lldb"],
"settings": {
"lldb.adapterType": "bundled",
"lldb.executable": "/usr/bin/lldb",
"terminal.integrated.shell.linux": "/bin/bash"
}
}
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'main'

env:
BUILDER_VERSION: v0.9.1
BUILDER_VERSION: v0.9.7
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-swift
Expand All @@ -37,18 +37,22 @@ jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- ubuntu-x64
- al2-x64
- centos-x64
# issue to fix centos opened against apple here: https://github.com/apple/swift-docker/issues/258
# - centos-x64
steps:
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp --debug s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-swift-5-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
osx:
runs-on: macos-11
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
Expand All @@ -57,6 +61,8 @@ jobs:
./builder build -p ${{ env.PACKAGE_NAME }}
devices:
runs-on: macos-11
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
strategy:
fail-fast: false
matrix:
Expand All @@ -69,4 +75,4 @@ jobs:
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }} --target=${{ matrix.target }}-armv8
./builder build -p ${{ env.PACKAGE_NAME }} --target=${{ matrix.target }}-armv8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM swift:5.4-focal
FROM swiftlang/swift:nightly-5.5-focal

WORKDIR /package

Expand Down
8 changes: 0 additions & 8 deletions LinuxMain.swift

This file was deleted.

16 changes: 16 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 25 additions & 18 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.5
import PackageDescription

let excludesFromAll = ["tests", "cmake", "CONTRIBUTING.md",
Expand All @@ -7,11 +7,12 @@ let excludesFromAll = ["tests", "cmake", "CONTRIBUTING.md",
var packageTargets: [Target] = []

var package = Package(name: "AwsCrt",
platforms: [.iOS(.v13), .macOS(.v10_14), .tvOS(.v13), .watchOS(.v5)],
platforms: [.iOS(.v13), .macOS(.v10_15), .tvOS(.v13), .watchOS(.v6)],
products: [
.library(name: "AwsCommonRuntimeKit", targets: ["AwsCommonRuntimeKit"]),
.executable(name: "Elasticurl", targets: ["Elasticurl"])
]
],
dependencies: [.package(url: "https://github.com/apple/swift-collections", from: "1.0.2")]
)

var calDependencies: [Target.Dependency] = ["AwsCCommon"]
Expand All @@ -27,17 +28,16 @@ packageTargets.append( .systemLibrary(
]
))
// add pq-crypto back after adding in platform and chipset detection
let s2nExcludes = excludesFromAll + ["bin", "codebuild", "coverage", "docker-images",
"docs", "lib", "pq-crypto/bike_r1", "pq-crypto/bike_r2",
"pq-crypto/bike_r3", "pq-crypto/kyber_90s_r2", "pq-crypto/kyber_r3",
"pq-crypto/kyber_r2", "pq-crypto/sike_r1", "pq-crypto/sike_r3",
"pq-crypto/README.md", "pq-crypto/Makefile", "pq-crypto/s2n_pq_asm.mk",
"libcrypto-build", "scram",
"s2n.mk", "Makefile", "stuffer/Makefile", "crypto/Makefile",
"tls/Makefile", "utils/Makefile", "error/Makefile",
"extensions/Makefile", "tls/extensions/Makefile",
"codecov.yml", "scripts/", "codebuild", "format-check.sh", "sanitizer-blacklist.txt",
"CODE_OF_CONDUCT.md", "build-deps.sh"]
let s2nExcludes = ["bin", "codebuild", "coverage", "docker-images",
"docs", "lib", "pq-crypto/bike_r1", "pq-crypto/bike_r2",
"pq-crypto/bike_r3", "pq-crypto/kyber_90s_r2", "pq-crypto/kyber_r3",
"pq-crypto/kyber_r2", "pq-crypto/sike_r1", "pq-crypto/sike_r3",
"pq-crypto/README.md", "pq-crypto/Makefile", "pq-crypto/s2n_pq_asm.mk",
"libcrypto-build", "scram",
"s2n.mk", "Makefile", "stuffer/Makefile", "crypto/Makefile",
"tls/Makefile", "utils/Makefile", "error/Makefile", "tls/extensions/Makefile",
"codecov.yml", "scripts/", "codebuild", "bindings/rust", "VERSIONING.rst", "tests",
"cmake/s2n-config.cmake", "CMakeLists.txt", "README.md", "cmake", "NOTICE", "LICENSE"]
packageTargets.append(.target(
name: "S2N",
dependencies: ["LibCrypto"],
Expand All @@ -53,7 +53,6 @@ packageTargets.append(.target(
ioDependencies.append("S2N")
calDependencies.append("LibCrypto")
#endif

// aws-c-common config
var awsCCommonPlatformExcludes = ["source/windows", "source/android",
"AWSCRTAndroidTestRunner", "docker-images", "verification",
Expand All @@ -80,7 +79,8 @@ awsCCommonPlatformExcludes.append("source/arch/intel/asm")
awsCCommonPlatformExcludes.append("source/arch/arm/asm")
#endif

var awsCIoPlatformExcludes = ["docs", "CODE_OF_CONDUCT.md", "codebuild", "PKCS11.md", "THIRD-PARTY-LICENSES.txt"] + excludesFromAll
var awsCIoPlatformExcludes = ["docs", "CODE_OF_CONDUCT.md", "codebuild", "PKCS11.md", "THIRD-PARTY-LICENSES.txt",
"source/pkcs11/v2.40"] + excludesFromAll

#if os(macOS)
awsCIoPlatformExcludes.append("source/windows")
Expand Down Expand Up @@ -206,7 +206,14 @@ packageTargets.append(contentsOf: [
),
.target(
name: "AwsCommonRuntimeKit",
dependencies: [ "AwsCMqtt", "AwsCAuth", "AwsCHttp", "AwsCCal", "AwsCCompression", "AwsCIo", "AwsCCommon"],
dependencies: [ "AwsCMqtt",
"AwsCAuth",
"AwsCHttp",
"AwsCCal",
"AwsCCompression",
"AwsCIo",
"AwsCCommon",
.product(name: "Collections", package: "swift-collections")],
path: "Source/AwsCommonRuntimeKit",
swiftSettings: [
// .unsafeFlags(["-g"]),
Expand All @@ -216,7 +223,7 @@ packageTargets.append(contentsOf: [
.testTarget(
name: "AwsCommonRuntimeKitTests",
dependencies: ["AwsCommonRuntimeKit"],
path: "Test",
path: "Test/AwsCommonRuntimeKitTests",
swiftSettings: [
// .unsafeFlags(["-g"]),
// .unsafeFlags(["-Onone"], .when(configuration: .debug))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,30 +279,33 @@ public final class CRTAWSCredentialsProvider {
/// Retrieves credentials from a provider by calling its implementation of get credentials and returns them to
/// the callback passed in.
///
/// - Parameters:
/// - credentialCallbackData: The `CredentialProviderCallbackData`options object.
public func getCredentials() -> Future<CRTCredentials> {
let future = Future<CRTCredentials>()
let callbackData = CRTCredentialsCallbackData(allocator: allocator) { (crtCredentials, crtError) in
if let crtCredentials = crtCredentials {
future.fulfill(crtCredentials)
} else {
future.fail(crtError)
}
/// - Returns: `Result<CRTCredentials, CRTError>`
public func getCredentials() async throws -> CRTCredentials {
return try await withCheckedThrowingContinuation { (continuation: CredentialsContinuation) in
getCredentialsFromCRT(continuation: continuation)
}
let pointer: UnsafeMutablePointer<CRTCredentialsCallbackData> = fromPointer(ptr: callbackData)
}

private func getCredentialsFromCRT(continuation: CredentialsContinuation) {
let callbackData = CRTCredentialsProviderCallbackData(continuation: continuation)
let pointer: UnsafeMutablePointer<CRTCredentialsProviderCallbackData> = fromPointer(ptr: callbackData)
aws_credentials_provider_get_credentials(rawValue, { (credentials, errorCode, userdata) -> Void in
guard let userdata = userdata else {
return
}
let pointer = userdata.assumingMemoryBound(to: CRTCredentialsCallbackData.self)
let pointer = userdata.assumingMemoryBound(to: CRTCredentialsProviderCallbackData.self)
defer { pointer.deinitializeAndDeallocate() }
let error = AWSError(errorCode: errorCode)
if let onCredentialsResolved = pointer.pointee.onCredentialsResolved {
onCredentialsResolved(CRTCredentials(rawValue: credentials), CRTError.crtError(error))

if errorCode == 0,
let credentials = credentials,
let crtCredentials = CRTCredentials(rawValue: credentials) {
pointer.pointee.continuation?.resume(returning: crtCredentials)
} else {
pointer.pointee.continuation?.resume(throwing: CRTError.crtError(error))
}

}, pointer)
return future
}

static func setUpShutDownOptions(shutDownOptions: CRTCredentialsProviderShutdownOptions?)
Expand Down Expand Up @@ -332,11 +335,20 @@ private func getCredentialsDelegateFn(_ delegatePtr: UnsafeMutableRawPointer?,
guard let credentialsProvider = delegatePtr?.assumingMemoryBound(to: CRTCredentialsProvider.self) else {
return 1
}
guard let credentialCallbackData = userData?.assumingMemoryBound(to: CRTCredentialsCallbackData.self) else {
guard let credentialCallbackData = userData?.assumingMemoryBound(to: CRTCredentialsProviderCallbackData.self) else {
return 1
}

credentialsProvider.pointee.getCredentials(credentialCallbackData: credentialCallbackData.pointee)
let callbackPointer = UnsafeMutablePointer<CRTCredentialsProviderCallbackData>.allocate(capacity: 1)
callbackPointer.initialize(to: credentialCallbackData.pointee)
Task {
do {
let credentials = try await credentialsProvider.pointee.getCredentials()
callbackFn?(credentials.rawValue, 0, callbackPointer)
} catch let err {
if case let CRTError.crtError(crtError) = err {
callbackFn?(nil, crtError.errorCode, callbackPointer)
}
}
}
return 0

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0.

public struct CRTCredentialsCallbackData {
public typealias OnCredentialsResolved = (CRTCredentials?, CRTError) -> Void
public var onCredentialsResolved: OnCredentialsResolved?
public typealias CredentialsContinuation = CheckedContinuation<CRTCredentials, Error>
public struct CRTCredentialsProviderCallbackData {
public var continuation: CredentialsContinuation?
public let allocator: Allocator

public init(allocator: Allocator = defaultAllocator,
onCredentialsResolved: OnCredentialsResolved? = nil) {
self.onCredentialsResolved = onCredentialsResolved
continuation: CredentialsContinuation? = nil) {
self.allocator = allocator
self.continuation = continuation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import AwsCAuth

public protocol CRTCredentialsProvider {
var allocator: Allocator {get set}
func getCredentials(credentialCallbackData: CRTCredentialsCallbackData)
func getCredentials() async throws -> CRTCredentials

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ public struct CRTCredentialsProviderShutdownOptions {

public init(shutDownCallback: @escaping ShutDownCallback) {
self.shutDownCallback = shutDownCallback

}
}
Loading