Skip to content

Commit

Permalink
Add Args: string[] to ConvertProgramRequest (pulumi#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-Ajaj authored Sep 23, 2023
1 parent c898b91 commit b80ffcb
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Improvements

- Plugin: clean up resources and exit cleanly on receiving SIGINT or CTRL_BREAK.
- Converter SDK: add `Args: string[]` to the `ConvertProgramRequest` fields

### Bug Fixes
7 changes: 7 additions & 0 deletions proto/pulumi/converter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ service Converter {
message ConvertStateRequest {
// the gRPC target of the mapper service.
string mapper_target = 1;
// the args passed to `pulumi import` for this conversion. Normally used to specifiy a state file to
// import from.
repeated string args = 2;
}

// A ResourceImport specifies a resource to import.
Expand Down Expand Up @@ -65,6 +68,10 @@ message ConvertProgramRequest {
string target_directory = 2;
// the gRPC target of the mapper service.
string mapper_target = 3;
// The target of a codegen.LoaderServer to use for loading schemas.
string loader_target = 4;
// the args passed to `pulumi convert` for this conversion. Normally used to specifiy a root file, or conversion options.
repeated string args = 5;
}

message ConvertProgramResponse {
Expand Down
20 changes: 20 additions & 0 deletions proto/pulumi/language.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ service LanguageRuntime {

// GeneratePackage generates a given pulumi package into a package for this language.
rpc GeneratePackage(GeneratePackageRequest) returns (GeneratePackageResponse) {}

// Pack packs a package into a language specific artifact.
rpc Pack(PackRequest) returns (PackResponse) {}
}

// AboutResponse returns runtime information about the language.
Expand Down Expand Up @@ -164,6 +167,9 @@ message GenerateProjectRequest {
bool strict = 4;
// The target of a codegen.LoaderServer to use for loading schemas.
string loader_target = 5;
// local dependencies to use instead of using the package system. This is a map of package name to a local
// path of a language specific artifact to use for the SDK for that package.
map<string, string> local_dependencies = 6;
}

message GenerateProjectResponse {
Expand All @@ -183,4 +189,18 @@ message GeneratePackageRequest {
}

message GeneratePackageResponse {
}

message PackRequest {
// the directory of a package to pack.
string package_directory = 1;
// the version to tag the artifact with.
string version = 2;
// the directory to write the packed artifact to.
string destination_directory = 3;
}

message PackResponse {
// the full path of the packed artifact.
string artifact_path = 1;
}
4 changes: 4 additions & 0 deletions proto/pulumi/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ message PluginDependency {
string kind = 2; // the kind of plugin (e.g., language, etc).
string version = 3; // the semver for this plugin.
string server = 4; // the URL of a server that can be used to download this plugin, if needed.

// a map of the checksums for the plugin, will be empty from old language runtimes. The keys should match
// the os and architecture names used in pulumi releases, e.g. "darwin-amd64", "windows-arm64".
map<string, bytes> checksums = 5;
}

// PluginAttach is used to attach an already running plugin to the engine.
Expand Down
26 changes: 26 additions & 0 deletions proto/pulumi/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ service ResourceProvider {
// GetMapping fetches the mapping for this resource provider, if any. A provider should return an empty
// response (not an error) if it doesn't have a mapping for the given key.
rpc GetMapping(GetMappingRequest) returns (GetMappingResponse) {}

// GetMappings is an optional method that returns what mappings (if any) a provider supports. If a provider does not
// implement this method the engine falls back to the old behaviour of just calling GetMapping without a name.
// If this method is implemented than the engine will then call GetMapping only with the names returned from this method.
rpc GetMappings(GetMappingsRequest) returns (GetMappingsResponse) {}
}

message GetSchemaRequest {
Expand Down Expand Up @@ -146,6 +151,7 @@ message CallRequest {
string provider = 4; // an optional reference to the provider to use for this invoke.
string version = 5; // the version of the provider to use when servicing this request.
string pluginDownloadURL = 13; // the pluginDownloadURL of the provider to use when servicing this request.
map<string, bytes> pluginChecksums = 16; // a map of checksums of the provider to use when servicing this request.

string project = 6; // the project name.
string stack = 7; // the name of the stack being deployed into.
Expand Down Expand Up @@ -392,13 +398,19 @@ message ErrorResourceInitFailed {
google.protobuf.Struct inputs = 4; // the current inputs to this resource (only applicable for Read)
}



// GetMappingRequest allows providers to return ecosystem specific information to allow the provider to be
// converted from a source markup to Pulumi. It's expected that provider bridges that target a given ecosystem
// (e.g. Terraform, Kubernetes) would also publish a conversion plugin to convert markup from that ecosystem
// to Pulumi, using the bridged providers.
message GetMappingRequest {
// the conversion key for the mapping being requested.
string key = 1;
// the optional provider key for the mapping being requested, if this is empty the provider should assume this
// request is from an old engine from before GetMappings and should return it's "primary" mapping. If this is set
// then the `provider` field in GetMappingResponse should be the same.
string provider = 2;
}

// GetMappingResponse returns convert plugin specific data for this provider. This will normally be human
Expand All @@ -410,3 +422,17 @@ message GetMappingResponse {
// the conversion plugin specific data.
bytes data = 2;
}

// GetMappingsRequest allows providers to return ecosystem specific information without having to send back large data
// blobs for provider mappings that the engine doesn't then need.
message GetMappingsRequest {
// the conversion key for the mapping being requested.
string key = 1;
}

// GetMappingsRequest returns a list of providers that this provider can provide mapping information for.
message GetMappingsResponse {
// the provider keys this provider can supply mappings for. For example the Pulumi provider "terraform-template"
// would return ["template"] for this.
repeated string providers = 1;
}
3 changes: 3 additions & 0 deletions proto/pulumi/resource.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ message ReadResourceRequest {

bool acceptResources = 12; // when true operations should return resource references as strongly typed.
string pluginDownloadURL = 13; // the server url of the provider to use when servicing this request.
map<string, bytes> pluginChecksums = 15; // a map of checksums of the provider to use when servicing this request.

SourcePosition sourcePosition = 14; // the optional source position of the user code that initiated the read.
}
Expand Down Expand Up @@ -118,6 +119,7 @@ message RegisterResourceRequest {
map<string, string> providers = 22; // an optional reference to the provider map to manage this resource's CRUD operations.
repeated string replaceOnChanges = 23; // a list of properties that if changed should force a replacement.
string pluginDownloadURL = 24; // the server URL of the provider to use when servicing this request.
map<string, bytes> pluginChecksums = 30; // a map of checksums expected for the provider plugin.
bool retainOnDelete = 25; // if true the engine will not call the resource providers delete method for this resource.
repeated Alias aliases = 26; // a list of additional aliases that should be considered the same.
string deletedWith = 27; // if set the engine will not call the resource providers delete method for this resource when specified resource is deleted.
Expand Down Expand Up @@ -163,6 +165,7 @@ message ResourceInvokeRequest {
string version = 4; // the version of the provider to use when servicing this request.
bool acceptResources = 5; // when true operations should return resource references as strongly typed.
string pluginDownloadURL = 6; // an optional reference to the provider url to use for this invoke.
map<string, bytes> pluginChecksums = 8; // a map of checksums expected for the provider plugin.

SourcePosition sourcePosition = 7; // the optional source position of the user code that initiated the invoke.
}
67 changes: 67 additions & 0 deletions proto/pulumi/testing/language.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2016-2023, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

import "google/protobuf/empty.proto";

package pulumirpc.testing;

option go_package = "github.com/pulumi/pulumi/sdk/v3/proto/go/testing";

// LanguageTest is the interface to the pulumi language test framework. This is _highly_ experimental and
// currently subject to breaking changes without warning.
service LanguageTest {
// GetLanguageTests returns a list of all the language tests.
rpc GetLanguageTests(GetLanguageTestsRequest) returns (GetLanguageTestsResponse) {}

// PrepareLanguageTests prepares the engine to run language tests. It sets up a stable artifacts folder
// (which should be .gitignore'd) and fills it with the core SDK artifact.
rpc PrepareLanguageTests(PrepareLanguageTestsRequest) returns (PrepareLanguageTestsResponse) {}

// RunLanguageTest runs a single test of the language plugin.
rpc RunLanguageTest(RunLanguageTestRequest) returns (RunLanguageTestResponse) {}
}

message GetLanguageTestsRequest {

}

message GetLanguageTestsResponse {
repeated string tests = 1;
}

message PrepareLanguageTestsRequest {
string language_plugin_name = 1;
string language_plugin_target = 2;
string snapshot_directory = 3;
string temporary_directory = 4;
string core_sdk_directory = 5;
}

message PrepareLanguageTestsResponse {
string token = 1;
}

message RunLanguageTestRequest {
string token = 1;
string test = 2;
}

message RunLanguageTestResponse {
bool success = 1;
repeated string messages = 2;
string stdout = 3;
string stderr = 4;
}
11 changes: 9 additions & 2 deletions sdk/Pulumi/Converter/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ public sealed class ConvertProgramRequest
public readonly string SourceDirectory;
public readonly string TargetDirectory;
public readonly string MapperTarget;
public readonly string[] Args;

public ConvertProgramRequest(string sourceDirectory, string targetDirectory, string mapperTarget)
public ConvertProgramRequest(
string sourceDirectory,
string targetDirectory,
string mapperTarget,
string[] args)
{
SourceDirectory = sourceDirectory;
TargetDirectory = targetDirectory;
MapperTarget = mapperTarget;
Args = args;
}
}

Expand Down Expand Up @@ -207,7 +213,8 @@ private Pulumirpc.Codegen.Range RpcRange(Pulumi.Codegen.Range range)
var request = new ConvertProgramRequest(
sourceDirectory: rpcRequest.SourceDirectory,
targetDirectory: rpcRequest.TargetDirectory,
mapperTarget: rpcRequest.MapperTarget);
mapperTarget: rpcRequest.MapperTarget,
args: rpcRequest.Args.ToArray());

var response = await _convertProgram(request);

Expand Down

0 comments on commit b80ffcb

Please sign in to comment.