Skip to content

Commit c5fc47f

Browse files
authored
Merge pull request #779 from aws/dev
chore: release 1.14
2 parents 61135f7 + d66f1d0 commit c5fc47f

5 files changed

Lines changed: 62 additions & 10 deletions

File tree

src/AWS.Deploy.Common/Exceptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public enum DeployToolErrorCode
126126
FailedToReadCdkBootstrapVersion = 10010400,
127127
UnsupportedOptionSettingType = 10010500,
128128
FailedToSaveDeploymentSettings = 10010600,
129-
InvalidWindowsManifestFile = 10010700
129+
InvalidWindowsManifestFile = 10010700,
130+
UserDeploymentFileNotFound = 10010800,
130131
}
131132

132133
public class ProjectFileNotFoundException : DeployToolException

src/AWS.Deploy.Orchestration/DeploymentSettingsHandler.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,22 @@ public DeploymentSettingsHandler(IFileManager fileManager, IDirectoryManager dir
5252

5353
public async Task<DeploymentSettings?> ReadSettings(string filePath)
5454
{
55-
try
56-
{
57-
var contents = await _fileManager.ReadAllTextAsync(filePath);
58-
var userDeploymentSettings = JsonConvert.DeserializeObject<DeploymentSettings>(contents);
59-
return userDeploymentSettings;
55+
if (_fileManager.Exists(filePath))
56+
{
57+
try
58+
{
59+
var contents = await _fileManager.ReadAllTextAsync(filePath);
60+
var userDeploymentSettings = JsonConvert.DeserializeObject<DeploymentSettings>(contents);
61+
return userDeploymentSettings;
62+
}
63+
catch (Exception ex)
64+
{
65+
throw new InvalidDeploymentSettingsException(DeployToolErrorCode.FailedToDeserializeUserDeploymentFile, $"An error occurred while trying to deserialize the deployment settings file located at {filePath}.\n {ex.Message}", ex);
66+
}
6067
}
61-
catch (Exception ex)
62-
{
63-
throw new InvalidDeploymentSettingsException(DeployToolErrorCode.FailedToDeserializeUserDeploymentFile, $"An error occured while trying to deserialize the deployment settings file located at {filePath}", ex);
68+
else
69+
{
70+
throw new InvalidDeploymentSettingsException(DeployToolErrorCode.UserDeploymentFileNotFound, $"The deployment settings file located at {filePath} doesn't exist.");
6471
}
6572
}
6673

test/AWS.Deploy.CLI.Common.UnitTests/ConfigFileDeployment/DeploymentSettingsHandlerTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,38 @@ public async Task SaveSettings_PushImageToECR()
246246
Assert.Equal(expectedSnapshot, actualSnapshot);
247247
}
248248

249+
[Fact]
250+
public async Task ReadSettings_InvalidJson()
251+
{
252+
// ARRANGE
253+
var recommendations = await _recommendationEngine.ComputeRecommendations();
254+
var selectedRecommendation = recommendations.FirstOrDefault(x => string.Equals(x.Recipe.Id, "AspNetAppAppRunner"));
255+
var filePath = Path.Combine("ConfigFileDeployment", "TestFiles", "InvalidConfigFile.json");
256+
257+
// ACT
258+
var readAction = async () => await _deploymentSettingsHandler.ReadSettings(filePath);
259+
260+
// ASSERT
261+
var ex = await Assert.ThrowsAsync<InvalidDeploymentSettingsException>(readAction);
262+
Assert.Equal(DeployToolErrorCode.FailedToDeserializeUserDeploymentFile, ex.ErrorCode);
263+
}
264+
265+
[Fact]
266+
public async Task ReadSettings_FileNotFound()
267+
{
268+
// ARRANGE
269+
var recommendations = await _recommendationEngine.ComputeRecommendations();
270+
var selectedRecommendation = recommendations.FirstOrDefault(x => string.Equals(x.Recipe.Id, "AspNetAppAppRunner"));
271+
var filePath = Path.Combine("ConfigFileDeployment", "TestFiles", "AppRunnerConfigFile");
272+
273+
// ACT
274+
var readAction = async () => await _deploymentSettingsHandler.ReadSettings(filePath);
275+
276+
// ASSERT
277+
var ex = await Assert.ThrowsAsync<InvalidDeploymentSettingsException>(readAction);
278+
Assert.Equal(DeployToolErrorCode.UserDeploymentFileNotFound, ex.ErrorCode);
279+
}
280+
249281
private object GetOptionSettingValue(Recommendation recommendation, string fullyQualifiedId)
250282
{
251283
var optionSetting = _optionSettingHandler.GetOptionSetting(recommendation, fullyQualifiedId);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"AWSProfile": "default",
3+
"AWSRegion": "us-west-2",
4+
"RecipeId": "PushContainerImageEcr"
5+
"Settings": {
6+
"ImageTag": 123456789,
7+
"DockerBuildArgs": "",
8+
"DockerfilePath": "DockerAssets/Dockerfile",
9+
"DockerExecutionDirectory": "DockerAssets",
10+
"ECRRepositoryName": "my-ecr-repository"
11+
}
12+
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.13",
3+
"version": "1.14",
44
"publicReleaseRefSpec": [
55
".*"
66
],

0 commit comments

Comments
 (0)