Skip to content

Commit 971af4f

Browse files
committed
minor refactor and reformat
1 parent ca4d1c2 commit 971af4f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Plugins/AWSLambdaDeployer/Plugin.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct AWSLambdaPackager: CommandPlugin {
8585
print("`Deploy.Swift` file not found in directory \(projectDirectory)")
8686
throw DeployerPluginError.deployswiftDoesNotExist
8787
}
88-
88+
8989
do {
9090
let cmd = [
9191
swiftExecutable.string,
@@ -198,7 +198,7 @@ struct AWSLambdaPackager: CommandPlugin {
198198
print("Deploying AWS Lambda function")
199199
print("-------------------------------------------------------------------------")
200200
do {
201-
201+
202202
try Utils.execute(
203203
executable: samExecutablePath,
204204
arguments: ["deploy",
@@ -272,7 +272,7 @@ private struct Configuration: CustomStringConvertible {
272272
let archiveDirectoryArgument = argumentExtractor.extractOption(named: "archive-path")
273273
let stackNameArgument = argumentExtractor.extractOption(named: "stackname")
274274
let helpArgument = argumentExtractor.extractFlag(named: "help") > 0
275-
275+
276276
// help required ?
277277
self.help = helpArgument
278278

Sources/AWSLambdaDeploymentDescriptor/DeploymentDefinition.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Foundation
55
//
66
public struct DeploymentDefinition {
77

8-
private var deployment : DeploymentDescriptor? = nil // optional is required to allow initialization after the capturing closure (compactMap)
8+
private var deployment : DeploymentDescriptor
99

1010
public init (
1111
// the description of the SAM template
@@ -18,7 +18,7 @@ public struct DeploymentDefinition {
1818
resources: [Resource])
1919
{
2020

21-
let functionResources = createResources(for: functions)
21+
let functionResources = DeploymentDefinition.createResources(for: functions)
2222

2323
self.deployment = SAMDeployment(description: description,
2424
resources: functionResources + resources)
@@ -29,7 +29,7 @@ public struct DeploymentDefinition {
2929
}
3030

3131
// create one Resource per function + additional resource for the function dependencies (ex: a SQS queue)
32-
private func createResources(for functions: [Function]) -> [Resource] {
32+
private static func createResources(for functions: [Function]) -> [Resource] {
3333

3434
var additionalresources : [Resource] = []
3535
let functionResources = functions.compactMap { function in
@@ -43,7 +43,7 @@ public struct DeploymentDefinition {
4343
lambdaPackage = "\(archiveArg)/\(function.name)/\(function.name).zip"
4444
}
4545
}
46-
46+
4747
// check the ZIP file exists
4848
if !FileManager.default.fileExists(atPath: lambdaPackage!) {
4949
// I choose to report an error in the generated JSON.
@@ -57,9 +57,9 @@ public struct DeploymentDefinition {
5757
// TODO: can we add code in `Plugin.swift` to force it to fail when such error is detected
5858
lambdaPackage = "### ERROR package does not exist: \(lambdaPackage!) ###"
5959
}
60-
60+
6161
// extract sqs resources to be created, if any
62-
additionalresources += self.explicitQueueResources(function: function)
62+
additionalresources += DeploymentDefinition.explicitQueueResources(function: function)
6363

6464
return Resource.serverlessFunction(name: function.name,
6565
architecture: function.architecture,
@@ -77,7 +77,7 @@ public struct DeploymentDefinition {
7777
// the event source eventually creates the queue resource and it returns a reference to the resource it has created
7878
// This function collects all queue resources created by SQS event sources or passed by Lambda function developer
7979
// to add them to the list of resources to synthetize
80-
private func explicitQueueResources(function: Function) -> [Resource] {
80+
private static func explicitQueueResources(function: Function) -> [Resource] {
8181

8282
return function.eventSources
8383
// first filter on event sources of type SQS where the `queue` property is defined (not nil)
@@ -93,10 +93,10 @@ public struct DeploymentDefinition {
9393
if pretty {
9494
encoder.outputFormatting = .prettyPrinted
9595
}
96-
let jsonData = try! encoder.encode(self.deployment!)
96+
let jsonData = try! encoder.encode(self.deployment)
9797
return String(data: jsonData, encoding: .utf8)!
9898
}
99-
99+
100100
}
101101

102102
// Intermediate structure to generate SAM Resources of type AWS::Serverless::Function

Sources/AWSLambdaDeploymentDescriptor/DeploymentDescriptor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public struct Resource: SAMResource, Equatable {
6262
let type: String
6363
let properties: SAMResourceProperties
6464
let name: String
65-
65+
6666
public static func == (lhs: Resource, rhs: Resource) -> Bool {
6767
lhs.type == rhs.type && lhs.name == rhs.name
6868
}

0 commit comments

Comments
 (0)