Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning for Automation API inline programs #388

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/bug-fixes-388.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
component: sdk/auto
kind: bug-fixes
body: Fix warning for inline programs
time: 2024-11-14T23:34:52.002286-08:00
custom:
PR: "388"
38 changes: 38 additions & 0 deletions sdk/Pulumi.Automation.Tests/LocalWorkspaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -728,6 +729,43 @@ public async Task StackLifecycleInlineProgram()
}
}

[Fact]
public async Task InlineProgramDoesNotEmitWarning()
{
var program = PulumiFn.Create(() =>
{
return new Dictionary<string, object?>();
});
Assert.IsType<PulumiFnInline>(program);

var stackName = RandomStackName();
var projectName = "inline_node";
using var stack = await LocalWorkspace.CreateStackAsync(new InlineProgramArgs(projectName, stackName, program)
{
EnvironmentVariables = new Dictionary<string, string?>
{
["PULUMI_CONFIG_PASSPHRASE"] = "test",
}
});

try
{
var stdout = new StringBuilder();
var stderr = new StringBuilder();
var previewResult = await stack.PreviewAsync(new PreviewOptions
{
OnStandardOutput = line => stdout.AppendLine(line),
OnStandardError = line => stderr.AppendLine(line),
});
Assert.DoesNotContain("warning", stdout.ToString(), StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("warning", stderr.ToString(), StringComparison.OrdinalIgnoreCase);
}
finally
{
await stack.Workspace.RemoveStackAsync(stackName);
}
}

[Fact]
public async Task SupportsStackOutputs()
{
Expand Down
10 changes: 10 additions & 0 deletions sdk/Pulumi.Automation/Runtime/LanguageRuntimeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using Microsoft.Extensions.Logging;
using Pulumirpc;
Expand Down Expand Up @@ -75,6 +76,15 @@ public override async Task<RunResponse> Run(RunRequest request, ServerCallContex
return new RunResponse();
}

public override Task<Pulumirpc.PluginInfo> GetPluginInfo(Empty request, ServerCallContext context)
{
var response = new Pulumirpc.PluginInfo
{
Version = "1.0.0",
};
return Task.FromResult(response);
}

public class CallerContext
{
public PulumiFn Program { get; }
Expand Down
Loading