Skip to content

Commit af8323e

Browse files
committed
Merge branch 'feature/net10' into normj/file-based
2 parents 686434d + bf6810d commit af8323e

File tree

77 files changed

+918
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+918
-788
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.ECS.Tools",
5+
"Type": "Major",
6+
"ChangelogMessages": [
7+
"Updated to V4 of the AWS SDK for .NET",
8+
"Updated the minimum requirement from .NET Core 3.1 to .NET 6"
9+
]
10+
},
11+
{
12+
"Name": "Amazon.ElasticBeanstalk.Tools",
13+
"Type": "Major",
14+
"ChangelogMessages": [
15+
"Updated to V4 of the AWS SDK for .NET",
16+
"Updated the minimum requirement from .NET Core 3.1 to .NET 6"
17+
]
18+
},
19+
{
20+
"Name": "Amazon.Lambda.Tools",
21+
"Type": "Major",
22+
"ChangelogMessages": [
23+
"Updated to V4 of the AWS SDK for .NET",
24+
"Updated the minimum requirement from .NET Core 3.1 to .NET 6",
25+
"Fixed \"The image manifest or layer media type for the source image is not supported.\" issue when container image was built for a Lambda function by adding the \"--provenance=false\" switch for the docker buildx command"
26+
]
27+
}
28+
29+
]
30+
}
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\..\buildtools\common.props" />
33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
5+
<!--
6+
This is explicitly set to 7.3 to match what the AWS VS Toolkit uses. This is required because
7+
the source code here is also copied into the AWS VS Toolkit.
8+
-->
9+
<LangVersion>7.3</LangVersion>
510
</PropertyGroup>
611
<ItemGroup>
7-
<PackageReference Include="AWSSDK.Core" Version="3.7.303.20" />
8-
<PackageReference Include="AWSSDK.ECR" Version="3.7.301.75" />
9-
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.7.301.6" />
10-
<PackageReference Include="AWSSDK.S3" Version="3.7.307.21" />
11-
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.300.81" />
12-
<PackageReference Include="AWSSDK.SSO" Version="3.7.300.80" />
13-
<PackageReference Include="AWSSDK.SSOOIDC" Version="3.7.301.75" />
12+
<PackageReference Include="AWSSDK.Core" Version="4.0.0.26" />
13+
<PackageReference Include="AWSSDK.ECR" Version="4.0.4.1" />
14+
<PackageReference Include="AWSSDK.IdentityManagement" Version="4.0.3.2" />
15+
<PackageReference Include="AWSSDK.S3" Version="4.0.6.13" />
16+
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.2.1" />
17+
<PackageReference Include="AWSSDK.SSO" Version="4.0.1.1" />
18+
<PackageReference Include="AWSSDK.SSOOIDC" Version="4.0.1.1" />
1419
</ItemGroup>
1520
<PropertyGroup>
16-
<NoWarn>1701;1702;1705;1591</NoWarn>
21+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
22+
<NoWarn>1701;1702;1705;1591;NETSDK1138</NoWarn>
1723
</PropertyGroup>
1824

1925
</Project>

src/Amazon.Common.DotNetCli.Tools/Commands/BaseCommand.cs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
using System.Linq;
88
using System.Reflection;
99
using System.Text;
10+
using System.Text.Json;
1011
using System.Threading.Tasks;
11-
using ThirdParty.Json.LitJson;
1212

1313
using Amazon.ECR;
1414
using Amazon.IdentityManagement;
1515
using Amazon.IdentityManagement.Model;
1616
using Amazon.S3;
1717
using Amazon.SecurityToken;
18+
using Amazon.Runtime.Credentials;
1819

1920
namespace Amazon.Common.DotNetCli.Tools.Commands
2021
{
@@ -46,7 +47,7 @@ public BaseCommand(IToolLogger logger, string workingDirectory)
4647
public BaseCommand(IToolLogger logger, string workingDirectory, IList<CommandOption> possibleOptions, string[] args)
4748
: this(logger, workingDirectory)
4849
{
49-
args = args ?? new string[0];
50+
args = args ?? Array.Empty<string>();
5051
this.OriginalCommandLineArguments = args;
5152
var values = CommandLineParser.ParseArguments(possibleOptions, args);
5253
ParseCommandArguments(values);
@@ -260,12 +261,12 @@ protected AWSCredentials DetermineAWSCredentials()
260261
var chain = new CredentialProfileStoreChain(this.ProfileLocation);
261262
if (!chain.TryGetAWSCredentials(profile, out this._resolvedCredentials))
262263
{
263-
this._resolvedCredentials = FallbackCredentialsFactory.GetCredentials();
264+
this._resolvedCredentials = DefaultAWSCredentialsIdentityResolver.GetCredentials();
264265
}
265266
}
266267
else
267268
{
268-
this._resolvedCredentials = FallbackCredentialsFactory.GetCredentials();
269+
this._resolvedCredentials = DefaultAWSCredentialsIdentityResolver.GetCredentials();
269270
}
270271

271272
if(this._resolvedCredentials is AssumeRoleAWSCredentials)
@@ -394,21 +395,23 @@ public string GetRoleValueOrDefault(string propertyValue, CommandOption option,
394395
}
395396

396397
/// <summary>
397-
/// Complex parameters are formatted as a JSON string. This method parses the string into the JsonData object
398+
/// Complex parameters are formatted as a JSON string. This method parses the string into the JsonElement object
398399
/// </summary>
399400
/// <param name="propertyValue"></param>
400401
/// <param name="option"></param>
401402
/// <returns></returns>
402-
public JsonData GetJsonValueOrDefault(string propertyValue, CommandOption option)
403+
public JsonElement? GetJsonValueOrDefault(string propertyValue, CommandOption option)
403404
{
404405
string jsonContent = GetStringValueOrDefault(propertyValue, option, false);
405406
if (string.IsNullOrWhiteSpace(jsonContent))
406407
return null;
407408

408409
try
409410
{
410-
var data = JsonMapper.ToObject(jsonContent);
411-
return data;
411+
using (JsonDocument doc = JsonDocument.Parse(jsonContent))
412+
{
413+
return doc.RootElement.Clone();
414+
}
412415
}
413416
catch(Exception e)
414417
{
@@ -707,7 +710,7 @@ protected string PromptForValue(CommandOption option)
707710
return cachedValue;
708711
}
709712

710-
string input = null;
713+
string input;
711714

712715

713716
Console.Out.WriteLine($"Enter {option.Name}: ({option.Description})");
@@ -852,29 +855,27 @@ protected void SaveConfigFile()
852855
{
853856
try
854857
{
855-
JsonData data;
858+
var data = new Dictionary<string, object>();
856859
if (File.Exists(this.DefaultConfig.SourceFile))
857860
{
858-
data = JsonMapper.ToObject(File.ReadAllText(this.DefaultConfig.SourceFile));
859-
}
860-
else
861-
{
862-
data = new JsonData();
861+
string existingJson = File.ReadAllText(this.DefaultConfig.SourceFile);
862+
using (JsonDocument doc = JsonDocument.Parse(existingJson))
863+
{
864+
foreach (JsonProperty prop in doc.RootElement.EnumerateObject())
865+
{
866+
data[prop.Name] = prop.Value.GetJsonValue();
867+
}
868+
}
863869
}
864870

865871
data.SetIfNotNull(CommonDefinedCommandOptions.ARGUMENT_AWS_REGION.ConfigFileKey, this.GetStringValueOrDefault(this.Region, CommonDefinedCommandOptions.ARGUMENT_AWS_REGION, false));
866872
data.SetIfNotNull(CommonDefinedCommandOptions.ARGUMENT_AWS_PROFILE.ConfigFileKey, this.GetStringValueOrDefault(this.Profile, CommonDefinedCommandOptions.ARGUMENT_AWS_PROFILE, false));
867873
data.SetIfNotNull(CommonDefinedCommandOptions.ARGUMENT_AWS_PROFILE_LOCATION.ConfigFileKey, this.GetStringValueOrDefault(this.ProfileLocation, CommonDefinedCommandOptions.ARGUMENT_AWS_PROFILE_LOCATION, false));
868874

869-
870875
SaveConfigFile(data);
871876

872-
StringBuilder sb = new StringBuilder();
873-
JsonWriter writer = new JsonWriter(sb);
874-
writer.PrettyPrint = true;
875-
JsonMapper.ToJson(data, writer);
876-
877-
var json = sb.ToString();
877+
var options = new JsonSerializerOptions { WriteIndented = true };
878+
var json = JsonSerializer.Serialize(data, options);
878879
File.WriteAllText(this.DefaultConfig.SourceFile, json);
879880
this.Logger?.WriteLine($"Config settings saved to {this.DefaultConfig.SourceFile}");
880881
}
@@ -884,7 +885,7 @@ protected void SaveConfigFile()
884885
}
885886
}
886887

887-
protected abstract void SaveConfigFile(JsonData data);
888+
protected abstract void SaveConfigFile(Dictionary<string, object> data);
888889

889890
public bool ConfirmDeletion(string resource)
890891
{

src/Amazon.Common.DotNetCli.Tools/Commands/BasePushDockerImageCommand.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
using Amazon.ECR.Model;
77
using Amazon.ECR;
8-
using ThirdParty.Json.LitJson;
98
using System.IO;
109
using Amazon.Common.DotNetCli.Tools.Options;
1110
using Amazon.Common.DotNetCli.Tools;
@@ -338,7 +337,7 @@ private async Task<Repository> SetupECRRepository(string ecrRepositoryName)
338337
}
339338

340339
Repository repository;
341-
if (describeResponse != null && describeResponse.Repositories.Count == 1)
340+
if (describeResponse != null && describeResponse.Repositories != null && describeResponse.Repositories.Count == 1)
342341
{
343342
this.Logger?.WriteLine($"Found existing ECR Repository {ecrRepositoryName}");
344343
repository = describeResponse.Repositories[0];
@@ -367,6 +366,11 @@ private async Task InitiateDockerLogin(DockerCLIWrapper dockerCLI)
367366
this.Logger?.WriteLine("Fetching ECR authorization token to use to login with the docker CLI");
368367
var response = await this.ECRClient.GetAuthorizationTokenAsync(new GetAuthorizationTokenRequest());
369368

369+
if (response.AuthorizationData == null || response.AuthorizationData.Count == 0)
370+
{
371+
throw new ToolsException("No authorization data returned from ECR", ToolsException.CommonErrorCode.GetECRAuthTokens);
372+
}
373+
370374
var authTokenBytes = Convert.FromBase64String(response.AuthorizationData[0].AuthorizationToken);
371375
var authToken = Encoding.UTF8.GetString(authTokenBytes);
372376
var decodedTokens = authToken.Split(':');
@@ -387,7 +391,7 @@ private async Task InitiateDockerLogin(DockerCLIWrapper dockerCLI)
387391
}
388392
}
389393

390-
protected override void SaveConfigFile(JsonData data)
394+
protected override void SaveConfigFile(Dictionary<string, object> data)
391395
{
392396
this.PushDockerImageProperties.PersistSettings(this, data);
393397
}
@@ -493,7 +497,7 @@ public void ParseCommandArguments(CommandOptions values)
493497
}
494498

495499

496-
public void PersistSettings(BaseCommand<TDefaultConfig> command, JsonData data)
500+
public void PersistSettings(BaseCommand<TDefaultConfig> command, Dictionary<string, object> data)
497501
{
498502
data.SetIfNotNull(CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION.ConfigFileKey, command.GetStringValueOrDefault(this.Configuration, CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION, false));
499503
data.SetIfNotNull(CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK.ConfigFileKey, command.GetStringValueOrDefault(this.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, false));

0 commit comments

Comments
 (0)