Skip to content

Commit 90517ad

Browse files
committed
swift format
1 parent bd46345 commit 90517ad

30 files changed

+1649
-1500
lines changed

Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ let package = Package(
1717

1818
// this has all the main functionality for lambda and it does not link Foundation
1919
.library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]),
20-
20+
2121
// plugin to create a new Lambda function, based on a template
2222
.plugin(name: "AWSLambdaInitializer", targets: ["AWSLambdaInitializer"]),
23-
23+
2424
// plugin to package the lambda, creating an archive that can be uploaded to AWS
2525
// requires Linux or at least macOS v15
2626
.plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]),
27-
27+
2828
// plugin to deploy a Lambda function
2929
.plugin(name: "AWSLambdaDeployer", targets: ["AWSLambdaDeployer"]),
30-
30+
3131
// an executable that implements the business logic for the plugins
3232
.executable(name: "AWSLambdaPluginHelper", targets: ["AWSLambdaPluginHelper"]),
33-
33+
3434
// for testing only
3535
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
3636
],

Plugins/AWSLambdaDeployer/Plugin.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ import PackagePlugin
1919
@available(macOS 15.0, *)
2020
struct AWSLambdaDeployer: CommandPlugin {
2121

22-
2322
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws {
2423
let configuration = try Configuration(context: context, arguments: arguments)
2524

2625
if configuration.help {
2726
self.displayHelpMessage()
2827
return
2928
}
30-
29+
3130
let tool = try context.tool(named: "AWSLambdaDeployerHelper")
3231
try Utils.execute(executable: tool.url, arguments: [], logLevel: .debug)
3332
}

Sources/AWSLambdaPluginHelper/Extensions.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Foundation
2626

2727
extension Data {
2828
var bytes: [UInt8] {
29-
return [UInt8](self)
29+
[UInt8](self)
3030
}
3131
}
3232

@@ -37,12 +37,20 @@ extension String {
3737
}
3838

3939
extension HMAC {
40-
public static func authenticate(for data: [UInt8], using key: [UInt8], variant: HMAC.Variant = .sha2(.sha256)) throws -> [UInt8] {
40+
public static func authenticate(
41+
for data: [UInt8],
42+
using key: [UInt8],
43+
variant: HMAC.Variant = .sha2(.sha256)
44+
) throws -> [UInt8] {
4145
let authenticator = HMAC(key: key, variant: variant)
4246
return try authenticator.authenticate(data)
4347
}
44-
public static func authenticate(for data: Data, using key: [UInt8], variant: HMAC.Variant = .sha2(.sha256)) throws -> [UInt8] {
48+
public static func authenticate(
49+
for data: Data,
50+
using key: [UInt8],
51+
variant: HMAC.Variant = .sha2(.sha256)
52+
) throws -> [UInt8] {
4553
let authenticator = HMAC(key: key, variant: variant)
4654
return try authenticator.authenticate(data.bytes)
4755
}
48-
}
56+
}

Sources/AWSLambdaPluginHelper/Vendored/crypto/Array+Extensions.swift

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -14,142 +14,142 @@
1414
//
1515

1616
extension Array {
17-
@inlinable
18-
init(reserveCapacity: Int) {
19-
self = Array<Element>()
20-
self.reserveCapacity(reserveCapacity)
21-
}
22-
23-
@inlinable
24-
var slice: ArraySlice<Element> {
25-
self[self.startIndex ..< self.endIndex]
26-
}
27-
28-
@inlinable
29-
subscript (safe index: Index) -> Element? {
30-
return indices.contains(index) ? self[index] : nil
31-
}
17+
@inlinable
18+
init(reserveCapacity: Int) {
19+
self = [Element]()
20+
self.reserveCapacity(reserveCapacity)
21+
}
22+
23+
@inlinable
24+
var slice: ArraySlice<Element> {
25+
self[self.startIndex..<self.endIndex]
26+
}
27+
28+
@inlinable
29+
subscript(safe index: Index) -> Element? {
30+
indices.contains(index) ? self[index] : nil
31+
}
3232
}
3333

3434
extension Array where Element == UInt8 {
35-
public init(hex: String) {
36-
self.init(reserveCapacity: hex.unicodeScalars.lazy.underestimatedCount)
37-
var buffer: UInt8?
38-
var skip = hex.hasPrefix("0x") ? 2 : 0
39-
for char in hex.unicodeScalars.lazy {
40-
guard skip == 0 else {
41-
skip -= 1
42-
continue
43-
}
44-
guard char.value >= 48 && char.value <= 102 else {
45-
removeAll()
46-
return
47-
}
48-
let v: UInt8
49-
let c: UInt8 = UInt8(char.value)
50-
switch c {
51-
case let c where c <= 57:
52-
v = c - 48
53-
case let c where c >= 65 && c <= 70:
54-
v = c - 55
55-
case let c where c >= 97:
56-
v = c - 87
57-
default:
58-
removeAll()
59-
return
60-
}
61-
if let b = buffer {
62-
append(b << 4 | v)
63-
buffer = nil
64-
} else {
65-
buffer = v
66-
}
67-
}
68-
if let b = buffer {
69-
append(b)
35+
public init(hex: String) {
36+
self.init(reserveCapacity: hex.unicodeScalars.lazy.underestimatedCount)
37+
var buffer: UInt8?
38+
var skip = hex.hasPrefix("0x") ? 2 : 0
39+
for char in hex.unicodeScalars.lazy {
40+
guard skip == 0 else {
41+
skip -= 1
42+
continue
43+
}
44+
guard char.value >= 48 && char.value <= 102 else {
45+
removeAll()
46+
return
47+
}
48+
let v: UInt8
49+
let c: UInt8 = UInt8(char.value)
50+
switch c {
51+
case let c where c <= 57:
52+
v = c - 48
53+
case let c where c >= 65 && c <= 70:
54+
v = c - 55
55+
case let c where c >= 97:
56+
v = c - 87
57+
default:
58+
removeAll()
59+
return
60+
}
61+
if let b = buffer {
62+
append(b << 4 | v)
63+
buffer = nil
64+
} else {
65+
buffer = v
66+
}
67+
}
68+
if let b = buffer {
69+
append(b)
70+
}
7071
}
71-
}
72-
73-
public func toHexString() -> String {
74-
`lazy`.reduce(into: "") {
75-
var s = String($1, radix: 16)
76-
if s.count == 1 {
77-
s = "0" + s
78-
}
79-
$0 += s
72+
73+
public func toHexString() -> String {
74+
`lazy`.reduce(into: "") {
75+
var s = String($1, radix: 16)
76+
if s.count == 1 {
77+
s = "0" + s
78+
}
79+
$0 += s
80+
}
8081
}
81-
}
8282
}
8383

8484
extension Array where Element == UInt8 {
85-
/// split in chunks with given chunk size
86-
@available(*, deprecated)
87-
public func chunks(size chunksize: Int) -> Array<Array<Element>> {
88-
var words = Array<Array<Element>>()
89-
words.reserveCapacity(count / chunksize)
90-
for idx in stride(from: chunksize, through: count, by: chunksize) {
91-
words.append(Array(self[idx - chunksize ..< idx])) // slow for large table
92-
}
93-
let remainder = suffix(count % chunksize)
94-
if !remainder.isEmpty {
95-
words.append(Array(remainder))
85+
/// split in chunks with given chunk size
86+
@available(*, deprecated)
87+
public func chunks(size chunksize: Int) -> [[Element]] {
88+
var words = [[Element]]()
89+
words.reserveCapacity(count / chunksize)
90+
for idx in stride(from: chunksize, through: count, by: chunksize) {
91+
words.append(Array(self[idx - chunksize..<idx])) // slow for large table
92+
}
93+
let remainder = suffix(count % chunksize)
94+
if !remainder.isEmpty {
95+
words.append(Array(remainder))
96+
}
97+
return words
9698
}
97-
return words
98-
}
9999

100-
// public func md5() -> [Element] {
101-
// Digest.md5(self)
102-
// }
100+
// public func md5() -> [Element] {
101+
// Digest.md5(self)
102+
// }
103103

104-
// public func sha1() -> [Element] {
105-
// Digest.sha1(self)
106-
// }
104+
// public func sha1() -> [Element] {
105+
// Digest.sha1(self)
106+
// }
107107

108-
// public func sha224() -> [Element] {
109-
// Digest.sha224(self)
110-
// }
108+
// public func sha224() -> [Element] {
109+
// Digest.sha224(self)
110+
// }
111111

112-
public func sha256() -> [Element] {
113-
Digest.sha256(self)
114-
}
112+
public func sha256() -> [Element] {
113+
Digest.sha256(self)
114+
}
115115

116-
public func sha384() -> [Element] {
117-
Digest.sha384(self)
118-
}
116+
public func sha384() -> [Element] {
117+
Digest.sha384(self)
118+
}
119119

120-
public func sha512() -> [Element] {
121-
Digest.sha512(self)
122-
}
120+
public func sha512() -> [Element] {
121+
Digest.sha512(self)
122+
}
123123

124-
public func sha2(_ variant: SHA2.Variant) -> [Element] {
125-
Digest.sha2(self, variant: variant)
126-
}
124+
public func sha2(_ variant: SHA2.Variant) -> [Element] {
125+
Digest.sha2(self, variant: variant)
126+
}
127127

128-
public func sha3(_ variant: SHA3.Variant) -> [Element] {
129-
Digest.sha3(self, variant: variant)
130-
}
128+
public func sha3(_ variant: SHA3.Variant) -> [Element] {
129+
Digest.sha3(self, variant: variant)
130+
}
131131

132-
// public func crc32(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
133-
// Checksum.crc32(self, seed: seed, reflect: reflect)
134-
// }
132+
// public func crc32(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
133+
// Checksum.crc32(self, seed: seed, reflect: reflect)
134+
// }
135135

136-
// public func crc32c(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
137-
// Checksum.crc32c(self, seed: seed, reflect: reflect)
138-
// }
136+
// public func crc32c(seed: UInt32? = nil, reflect: Bool = true) -> UInt32 {
137+
// Checksum.crc32c(self, seed: seed, reflect: reflect)
138+
// }
139139

140-
// public func crc16(seed: UInt16? = nil) -> UInt16 {
141-
// Checksum.crc16(self, seed: seed)
142-
// }
140+
// public func crc16(seed: UInt16? = nil) -> UInt16 {
141+
// Checksum.crc16(self, seed: seed)
142+
// }
143143

144-
// public func encrypt(cipher: Cipher) throws -> [Element] {
145-
// try cipher.encrypt(self.slice)
146-
// }
144+
// public func encrypt(cipher: Cipher) throws -> [Element] {
145+
// try cipher.encrypt(self.slice)
146+
// }
147147

148-
// public func decrypt(cipher: Cipher) throws -> [Element] {
149-
// try cipher.decrypt(self.slice)
150-
// }
148+
// public func decrypt(cipher: Cipher) throws -> [Element] {
149+
// try cipher.decrypt(self.slice)
150+
// }
151151

152-
public func authenticate<A: Authenticator>(with authenticator: A) throws -> [Element] {
153-
try authenticator.authenticate(self)
154-
}
155-
}
152+
public func authenticate<A: Authenticator>(with authenticator: A) throws -> [Element] {
153+
try authenticator.authenticate(self)
154+
}
155+
}

Sources/AWSLambdaPluginHelper/Vendored/crypto/Authenticator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
/// Message authentication code.
1717
public protocol Authenticator {
18-
/// Calculate Message Authentication Code (MAC) for message.
19-
func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8>
20-
}
18+
/// Calculate Message Authentication Code (MAC) for message.
19+
func authenticate(_ bytes: [UInt8]) throws -> [UInt8]
20+
}

0 commit comments

Comments
 (0)