Skip to content

Commit

Permalink
Merge branch 'main' into feature/handler-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerd committed Dec 1, 2023
2 parents 792d1c1 + 2c3b245 commit c0cf6d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Plugins/AWSLambdaPackager/Plugin.swift
Expand Up @@ -51,6 +51,7 @@ struct AWSLambdaPackager: CommandPlugin {
toolsProvider: { name in try context.tool(named: name).path },
outputDirectory: configuration.outputDirectory,
baseImage: configuration.baseDockerImage,
disableDockerImageUpdate: configuration.disableDockerImageUpdate,
buildConfiguration: configuration.buildConfiguration,
verboseLogging: configuration.verboseLogging
)
Expand All @@ -77,6 +78,7 @@ struct AWSLambdaPackager: CommandPlugin {
toolsProvider: (String) throws -> Path,
outputDirectory: Path,
baseImage: String,
disableDockerImageUpdate: Bool,
buildConfiguration: PackageManager.BuildConfiguration,
verboseLogging: Bool
) throws -> [LambdaProduct: Path] {
Expand All @@ -86,13 +88,15 @@ struct AWSLambdaPackager: CommandPlugin {
print("building \"\(packageIdentity)\" in docker")
print("-------------------------------------------------------------------------")

// update the underlying docker image, if necessary
print("updating \"\(baseImage)\" docker image")
try self.execute(
executable: dockerToolPath,
arguments: ["pull", baseImage],
logLevel: .output
)
if !disableDockerImageUpdate {
// update the underlying docker image, if necessary
print("updating \"\(baseImage)\" docker image")
try self.execute(
executable: dockerToolPath,
arguments: ["pull", baseImage],
logLevel: .output
)
}

// get the build output path
let buildOutputPathCommand = "swift build -c \(buildConfiguration.rawValue) --show-bin-path"
Expand Down Expand Up @@ -290,6 +294,7 @@ private struct Configuration: CustomStringConvertible {
public let buildConfiguration: PackageManager.BuildConfiguration
public let verboseLogging: Bool
public let baseDockerImage: String
public let disableDockerImageUpdate: Bool

public init(
context: PluginContext,
Expand All @@ -302,6 +307,7 @@ private struct Configuration: CustomStringConvertible {
let configurationArgument = argumentExtractor.extractOption(named: "configuration")
let swiftVersionArgument = argumentExtractor.extractOption(named: "swift-version")
let baseDockerImageArgument = argumentExtractor.extractOption(named: "base-docker-image")
let disableDockerImageUpdateArgument = argumentExtractor.extractFlag(named: "disable-docker-image-update") > 0

self.verboseLogging = verboseArgument

Expand Down Expand Up @@ -345,6 +351,8 @@ private struct Configuration: CustomStringConvertible {
let swiftVersion = swiftVersionArgument.first ?? .none // undefined version will yield the latest docker image
self.baseDockerImage = baseDockerImageArgument.first ?? "swift:\(swiftVersion.map { $0 + "-" } ?? "")amazonlinux2"

self.disableDockerImageUpdate = disableDockerImageUpdateArgument

if self.verboseLogging {
print("-------------------------------------------------------------------------")
print("configuration")
Expand All @@ -360,6 +368,7 @@ private struct Configuration: CustomStringConvertible {
products: \(self.products.map(\.name))
buildConfiguration: \(self.buildConfiguration)
baseDockerImage: \(self.baseDockerImage)
disableDockerImageUpdate: \(self.disableDockerImageUpdate)
}
"""
}
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -197,6 +197,7 @@ The `archive` command can be customized using the following parameters
* `2` (Debug)
* `--swift-version` Swift language version used to define the Amazon Linux 2 Docker image. For example "5.7.3"
* `--base-docker-image` An Amazon Linux 2 docker image name available in your system.
* `--disable-docker-image-update` If flag is set, docker image will not be updated and local image will be used.

Both `--swift-version` and `--base-docker-image` are mutually exclusive

Expand Down

0 comments on commit c0cf6d3

Please sign in to comment.