Skip to content

Commit e13003f

Browse files
authored
fix: update submodules to latest versions (#59)
1 parent 6748354 commit e13003f

16 files changed

+256
-18
lines changed

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ awsCCommonPlatformExcludes.append("source/arch/intel/asm")
8080
awsCCommonPlatformExcludes.append("source/arch/arm/asm")
8181
#endif
8282

83-
var awsCIoPlatformExcludes = ["docs", "CODE_OF_CONDUCT.md", "codebuild"] + excludesFromAll
83+
var awsCIoPlatformExcludes = ["docs", "CODE_OF_CONDUCT.md", "codebuild", "PKCS11.md", "THIRD-PARTY-LICENSES.txt"] + excludesFromAll
8484

8585
#if os(macOS)
8686
awsCIoPlatformExcludes.append("source/windows")
@@ -116,7 +116,7 @@ var awsCCompressionPlatformExcludes = ["source/huffman_generator/", "CODE_OF_CON
116116
"codebuild"] + excludesFromAll
117117

118118
var awsCHttpPlatformExcludes = ["bin", "integration-testing", "include/aws/http/private",
119-
"CODE_OF_CONDUCT.md", "sanitizer-blacklist.txt"] + excludesFromAll
119+
"CODE_OF_CONDUCT.md", "sanitizer-blacklist.txt", "codebuild/linux-integration-tests.yml"] + excludesFromAll
120120
let awsCAuthPlatformExcludes = ["CODE_OF_CONDUCT.md"] + excludesFromAll
121121
let awsCMqttPlatformExcludes = ["bin", "CODE_OF_CONDUCT.md"] + excludesFromAll
122122

Source/AwsCommonRuntimeKit/http/HttpClientConnectionManager.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public class HttpClientConnectionManager {
1515
self.options = options
1616
self.allocator = allocator
1717
let shutDownPtr: UnsafeMutablePointer<ShutDownCallbackOptions>? = fromOptionalPointer(ptr: options.shutDownOptions)
18-
1918
var mgrOptions = aws_http_connection_manager_options(bootstrap: options.clientBootstrap.rawValue,
2019
initial_window_size: options.initialWindowSize,
2120
socket_options: options.socketOptions.rawValue,
2221
tls_connection_options: options.tlsOptions?.rawValue,
23-
proxy_options: options.proxyOptions?.rawValue,
2422
monitoring_options: options.monitoringOptions?.rawValue,
2523
host: options.hostName.awsByteCursor,
2624
port: options.port,
25+
proxy_options: options.proxyOptions?.rawValue,
26+
proxy_ev_settings: options.proxyEnvSettings?.rawValue,
2727
max_connections: options.maxConnections,
2828
shutdown_complete_user_data: shutDownPtr,
2929
shutdown_complete_callback: { (userData) in
@@ -36,11 +36,9 @@ public class HttpClientConnectionManager {
3636
defer {callbackOptions.deinitializeAndDeallocate()}
3737
callbackOptions.pointee.shutDownCallback(
3838
callbackOptions.pointee.semaphore)
39-
},
40-
enable_read_back_pressure:
41-
options.enableManualWindowManagement,
42-
max_connection_idle_in_milliseconds:
43-
options.maxConnectionIdleMs)
39+
},
40+
enable_read_back_pressure: options.enableManualWindowManagement,
41+
max_connection_idle_in_milliseconds: options.maxConnectionIdleMs)
4442

4543
self.manager = aws_http_connection_manager_new(allocator.rawValue, &mgrOptions)
4644
}

Source/AwsCommonRuntimeKit/http/HttpClientConnectionOptions.swift

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public struct HttpClientConnectionOptions {
1313
public let port: UInt16
1414
/// The proxy options for connections in the connection pool
1515
public let proxyOptions: HttpProxyOptions?
16+
/// Configuration for using proxy from environment variable. Only works when proxyOptions is not set.
17+
public let proxyEnvSettings: ProxyEnvSettings?
1618
/// The socket options to use for connections in the connection pool
1719
public var socketOptions: SocketOptions
1820
/// The tls options to use for connections in the connection pool
@@ -45,6 +47,7 @@ public struct HttpClientConnectionOptions {
4547
initialWindowSize: Int = Int.max,
4648
port: UInt16,
4749
proxyOptions: HttpProxyOptions?,
50+
proxyEnvSettings: ProxyEnvSettings? = nil,
4851
socketOptions: SocketOptions,
4952
tlsOptions: TlsConnectionOptions?,
5053
monitoringOptions: HttpMonitoringOptions?,
@@ -58,6 +61,7 @@ public struct HttpClientConnectionOptions {
5861
self.initialWindowSize = initialWindowSize
5962
self.port = port
6063
self.proxyOptions = proxyOptions
64+
self.proxyEnvSettings = proxyEnvSettings
6165
self.socketOptions = socketOptions
6266
self.tlsOptions = tlsOptions
6367
self.monitoringOptions = monitoringOptions

Source/AwsCommonRuntimeKit/http/HttpMonitoringOptions.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public class HttpMonitoringOptions {
1919

2020
let options = aws_http_connection_monitoring_options(
2121
minimum_throughput_bytes_per_second: UInt64(minThroughputBytesPerSecond),
22-
allowable_throughput_failure_interval_seconds: UInt32(allowableThroughputFailureInterval))
22+
allowable_throughput_failure_interval_seconds: UInt32(allowableThroughputFailureInterval),
23+
statistics_observer_fn: nil,
24+
statistics_observer_user_data: nil)
2325
self.rawValue = fromPointer(ptr: options)
2426

2527
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0.
3+
import AwsCHttp
4+
5+
public enum HttpProxyConnectionType {
6+
/// Deprecated, but 0-valued for backwards compatibility
7+
/// If tls options are provided (for the main connection) then treat the proxy as a tunneling proxy
8+
/// If tls options are not provided (for the main connection), then treat the proxy as a forwarding proxy
9+
case legacy
10+
/// Use the proxy to forward http requests. Attempting to use both this mode and TLS on the tunnel destination
11+
/// is a configuration error.
12+
case forward
13+
/// Use the proxy to establish a connection to a remote endpoint via a CONNECT request through the proxy.
14+
/// Works for both plaintext and tls connections.
15+
case tunnel
16+
}
17+
18+
extension HttpProxyConnectionType: RawRepresentable, CaseIterable {
19+
20+
public init(rawValue: aws_http_proxy_connection_type) {
21+
let value = Self.allCases.first(where: {$0.rawValue == rawValue})
22+
self = value ?? .forward
23+
}
24+
public var rawValue: aws_http_proxy_connection_type {
25+
switch self {
26+
case .legacy: return AWS_HPCT_HTTP_LEGACY
27+
case .forward: return AWS_HPCT_HTTP_FORWARD
28+
case .tunnel: return AWS_HPCT_HTTP_TUNNEL
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0.
3+
import AwsCHttp
4+
5+
public enum HttpProxyEnvType {
6+
/// Default. Disable reading from environment variable for proxy.
7+
case disable
8+
/// Enable get proxy URL from environment variable, when the manual proxy options of connection manager is not set.
9+
/// env HTTPS_PROXY/https_proxy will be checked when the main connection use tls.
10+
/// env HTTP_PROXY/http_proxy will be checked when the main connection NOT use tls.
11+
/// The lower case version has precedence.
12+
case enable
13+
}
14+
15+
extension HttpProxyEnvType: RawRepresentable, CaseIterable {
16+
17+
public init(rawValue: aws_http_proxy_env_var_type) {
18+
let value = Self.allCases.first(where: {$0.rawValue == rawValue})
19+
self = value ?? .disable
20+
}
21+
public var rawValue: aws_http_proxy_env_var_type {
22+
switch self {
23+
case .disable: return AWS_HPEV_DISABLE
24+
case .enable: return AWS_HPEV_ENABLE
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0.
3+
import AwsCHttp
4+
5+
public class ProxyEnvSettings {
6+
let rawValue: UnsafeMutablePointer<proxy_env_var_settings>
7+
public var envVarType: HttpProxyEnvType = .disable
8+
public var proxyConnectionType: HttpProxyConnectionType = .forward
9+
public var tlsOptions: TlsConnectionOptions?
10+
11+
public init(envVarType: HttpProxyEnvType = .disable,
12+
proxyConnectionType: HttpProxyConnectionType = .forward,
13+
tlsOptions: TlsConnectionOptions? = nil) {
14+
self.rawValue = allocatePointer()
15+
self.envVarType = envVarType
16+
self.proxyConnectionType = proxyConnectionType
17+
self.tlsOptions = tlsOptions
18+
}
19+
20+
deinit {
21+
rawValue.deinitializeAndDeallocate()
22+
}
23+
}

aws-common-runtime/aws-c-common

Submodule aws-c-common updated 50 files

aws-common-runtime/aws-c-http

Submodule aws-c-http updated 55 files

aws-common-runtime/aws-c-io

Submodule aws-c-io updated 51 files

aws-common-runtime/s2n

Submodule s2n updated 364 files

latest_submodules.py

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import argparse
2+
import os
3+
import os.path
4+
import re
5+
import subprocess
6+
import sys
7+
8+
9+
def run(*args, check=True):
10+
return subprocess.run(args, capture_output=True, check=check, universal_newlines=True)
11+
12+
13+
def get_submodules():
14+
"""
15+
Return list of submodules for current repo, sorted by name.
16+
17+
Each item looks like:
18+
{
19+
'name': 'aws-c-common',
20+
'path': 'crt/aws-c-common',
21+
'url': 'https://github.com/awslabs/aws-c-common.git',
22+
}
23+
"""
24+
if not os.path.exists('.gitmodules'):
25+
sys.exit(f'No .gitmodules found in {os.getcwd()}')
26+
27+
submodules = []
28+
start_pattern = re.compile(r'\[submodule')
29+
path_pattern = re.compile(r'\s+path = (\S+)')
30+
url_pattern = re.compile(r'\s+url = (\S+)')
31+
32+
current = None
33+
with open('.gitmodules', 'r') as f:
34+
for line in f.readlines():
35+
m = start_pattern.match(line)
36+
if m:
37+
current = {}
38+
submodules.append(current)
39+
continue
40+
41+
m = path_pattern.match(line)
42+
if m:
43+
current['path'] = m.group(1)
44+
current['name'] = os.path.basename(current['path'])
45+
continue
46+
47+
m = url_pattern.match(line)
48+
if m:
49+
current['url'] = m.group(1)
50+
continue
51+
52+
return sorted(submodules, key=lambda x: x['name'])
53+
54+
55+
def get_release_tags():
56+
"""
57+
Return list of release tags for current repo, sorted high to low.
58+
59+
Each item looks like:
60+
{
61+
'commit': 'e18f041a0c8d17189f2eae2a32f16e0a7a3f0f1c',
62+
'version': 'v0.5.18'
63+
'num_tuple': (0,5,18),
64+
}
65+
"""
66+
git_output = run('git', 'ls-remote', '--tags').stdout
67+
tags = []
68+
for line in git_output.splitlines():
69+
# line looks like: "e18f041a0c8d17189f2eae2a32f16e0a7a3f0f1c refs/tags/v0.5.18"
70+
match = re.match(
71+
r'([a-f0-9]+)\s+refs/tags/(v([0-9]+)\.([0-9]+)\.([0-9]+))$', line)
72+
if not match:
73+
# skip malformed release tags
74+
continue
75+
tags.append({
76+
'commit': match.group(1),
77+
'version': match.group(2),
78+
'num_tuple': (int(match.group(3)), int(match.group(4)), int(match.group(5))),
79+
})
80+
81+
# sort highest version first
82+
return sorted(tags, reverse=True, key=lambda tag: tag['num_tuple'])
83+
84+
85+
def get_current_commit():
86+
git_output = run('git', 'rev-parse', 'HEAD').stdout
87+
return git_output.splitlines()[0]
88+
89+
90+
def is_ancestor(ancestor, descendant):
91+
"""Return whether first commit is an ancestor to the second'"""
92+
result = run('git', 'merge-base', '--is-ancestor',
93+
ancestor, descendant, check=False)
94+
return result.returncode == 0
95+
96+
97+
def get_tag_for_commit(tags, commit):
98+
for tag in tags:
99+
if tag['commit'] == commit:
100+
return tag
101+
return None
102+
103+
104+
def main():
105+
parser = argparse.ArgumentParser(
106+
description="Update submodules to latest tags")
107+
parser.add_argument('ignore', nargs='*', help="submodules to ignore")
108+
parser.add_argument('--dry-run', action='store_true',
109+
help="print without actually updating")
110+
args = parser.parse_args()
111+
112+
root_path = os.getcwd()
113+
submodules = get_submodules()
114+
name_pad = max([len(x['name']) for x in submodules])
115+
for submodule in submodules:
116+
name = submodule['name']
117+
118+
os.chdir(os.path.join(root_path, submodule['path']))
119+
120+
tags = get_release_tags()
121+
current_commit = get_current_commit()
122+
current_tag = get_tag_for_commit(tags, current_commit)
123+
sync_from = current_tag['version'] if current_tag else current_commit
124+
125+
if name in args.ignore:
126+
print(f"{name:<{name_pad}} {sync_from} (ignored)")
127+
continue
128+
129+
latest_tag = tags[0]
130+
sync_to = latest_tag['version']
131+
132+
# The only time we don't want to sync to the latest release is:
133+
# The submodule is at some commit beyond the latest release,
134+
# and the CRT team doesn't control this repo so can't just cut a new release
135+
if sync_from != sync_to and current_tag is None:
136+
if name in ['aws-lc', 's2n', 's2n-tls']:
137+
# must fetch tags before we can check their ancestry
138+
run('git', 'fetch', '--tags', '--prune', '--prune-tags', '--force')
139+
if not is_ancestor(ancestor=current_commit, descendant=sync_to):
140+
sync_to = sync_from
141+
142+
if sync_from == sync_to:
143+
print(f"{name:<{name_pad}} {sync_from} ✓")
144+
else:
145+
print(f"{name:<{name_pad}} {sync_from} -> {sync_to}")
146+
if not args.dry_run:
147+
run('git', 'fetch', '--tags', '--prune', '--prune-tags', '--force')
148+
run('git', 'checkout', sync_to)
149+
run('git', 'submodule', 'update')
150+
151+
152+
if __name__ == '__main__':
153+
main()

0 commit comments

Comments
 (0)