Skip to content

Commit

Permalink
Fix issue related to yaml templates containing intrinsic functions in…
Browse files Browse the repository at this point in the history
… the short form

This is a manual merge of PR #39 by Albert Szilvasy(szilvaa) because the PR 38 caused too many conflicts
  • Loading branch information
normj committed Oct 12, 2018
1 parent 623986d commit 1305565
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/Amazon.Common.DotNetCli.Tools/IToolLogger.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -25,11 +26,18 @@ public class ConsoleToolLogger : IToolLogger
public void WriteLine(string message)
{
Console.WriteLine(message);
#if DEBUG
Debugger.Log(0, "console", message + "\n");
#endif
}

public void WriteLine(string message, params object[] args)
{
Console.WriteLine(string.Format(message, args));
var str = string.Format(message, args);
Console.WriteLine(str);
#if DEBUG
Debugger.Log(0, "console", str + "\n");
#endif
}
}
}
2 changes: 1 addition & 1 deletion src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.3.7.11" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.3.4.18" />
<PackageReference Include="AWSSDK.S3" Version="3.3.24.3" />
<PackageReference Include="YamlDotNet.Signed" Version="4.2.1" />
<PackageReference Include="YamlDotNet.Signed" Version="5.2.1" />
</ItemGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public YamlTemplateParser(string templateBody)
public string GetUpdatedTemplate()
{
var myText = new StringWriter();
this.Yaml.Save(myText);
this.Yaml.Save(myText, assignAnchors: false);

return myText.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.0.1" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="YamlDotNet.Signed" Version="4.2.1" />
<PackageReference Include="YamlDotNet.Signed" Version="5.2.1" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
2 changes: 2 additions & 0 deletions test/Amazon.Lambda.Tools.Test/TemplateCodeUpdateYamlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public void DeployServerlessWithSwaggerWithTemplateSubstitution()

//Does not throw an error when parsing template
var updateTemplateBody = LambdaUtilities.UpdateCodeLocationInYamlTemplate(template, S3_BUCKET, S3_OBJECT);
//validate that functions survive the template update
Assert.Contains("DevStack: !Equals [!Ref 'AWS::StackName', dev]", updateTemplateBody);
}
}
}
2 changes: 2 additions & 0 deletions test/Amazon.Lambda.Tools.Test/TestFiles/testtemplate.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
AWSTemplateFormatVersion : 2010-09-09
Transform : AWS::Serverless-2016-10-31
Description : An AWS Serverless Application.
Conditions:
DevStack: !Equals [!Ref 'AWS::StackName', dev ]
Resources :
RestApi :
Type: AWS::Serverless::Api
Expand Down

0 comments on commit 1305565

Please sign in to comment.