[sdk/nodejs] Keep prompt values prompt in construct (#6522)
In order to support prompt values in multi-lang components, if an input value is prompt, keep it as-is instead of wrapping it in an Output.
This commit is contained in:
parent
3dde9d02bf
commit
f7cc19f89d
|
@ -23,6 +23,9 @@
|
|||
- [automation/dotnet] Expose WorkspaceStack.GetOutputsAsync
|
||||
[#6699](https://github.com/pulumi/pulumi/pull/6699)
|
||||
|
||||
- [sdk/nodejs] Allow prompt values in `construct` for multi-lang components.
|
||||
[#6522](https://github.com/pulumi/pulumi/pull/6522)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [sdk/nodejs] Explicitly create event log file for NodeJS Automation API.
|
||||
|
|
1
Makefile
1
Makefile
|
@ -55,6 +55,7 @@ test_fast:: build
|
|||
test_build:: $(SUB_PROJECTS:%=%_install)
|
||||
cd tests/integration/construct_component/testcomponent && yarn install && yarn link @pulumi/pulumi && yarn run tsc
|
||||
cd tests/integration/construct_component_slow/testcomponent && yarn install && yarn link @pulumi/pulumi && yarn run tsc
|
||||
cd tests/integration/construct_component_plain/testcomponent && yarn install && yarn link @pulumi/pulumi && yarn run tsc
|
||||
|
||||
test_all:: build test_build $(SUB_PROJECTS:%=%_install)
|
||||
cd pkg && $(GO_TEST) ${PROJECT_PKGS}
|
||||
|
|
|
@ -284,11 +284,16 @@
|
|||
WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
|
||||
<Exec Command="yarn link @pulumi/pulumi"
|
||||
WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
|
||||
<Exec Command="yarn install"
|
||||
WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
|
||||
<Exec Command="yarn link @pulumi/pulumi"
|
||||
WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
|
||||
</Target>
|
||||
|
||||
<Target Name="TestBuild">
|
||||
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent" />
|
||||
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
|
||||
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
|
||||
</Target>
|
||||
|
||||
<!-- Tests -->
|
||||
|
|
|
@ -17,10 +17,7 @@ namespace Pulumi
|
|||
|
||||
private protected override void ValidateMember(Type memberType, string fullName)
|
||||
{
|
||||
if (!typeof(IInput).IsAssignableFrom(memberType))
|
||||
{
|
||||
throw new InvalidOperationException($"{fullName} must be an Input<T>");
|
||||
}
|
||||
// No validation. A member may or may not be IInput.
|
||||
}
|
||||
|
||||
private class EmptyResourceArgs : ResourceArgs
|
||||
|
|
|
@ -299,8 +299,15 @@ class Server implements grpc.UntypedServiceImplementation {
|
|||
const deps = (inputDeps ? <resource.URN[]>inputDeps.getUrnsList() : [])
|
||||
.map(depUrn => new resource.DependencyResource(depUrn));
|
||||
const input = deserializedInputs[k];
|
||||
inputs[k] = new Output(deps, Promise.resolve(runtime.unwrapRpcSecret(input)), Promise.resolve(true),
|
||||
Promise.resolve(runtime.isRpcSecret(input)), Promise.resolve([]));
|
||||
const isSecret = runtime.isRpcSecret(input);
|
||||
if (!isSecret && deps.length === 0) {
|
||||
// If it's a prompt value, return it directly without wrapping it as an output.
|
||||
inputs[k] = input;
|
||||
} else {
|
||||
// Otherwise, wrap it in an output so we can handle secrets and/or track dependencies.
|
||||
inputs[k] = new Output(deps, Promise.resolve(runtime.unwrapRpcSecret(input)), Promise.resolve(true),
|
||||
Promise.resolve(isSecret), Promise.resolve([]));
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild the resource options.
|
||||
|
|
353
tests/integration/construct_component_plain/dotnet/.gitignore
vendored
Normal file
353
tests/integration/construct_component_plain/dotnet/.gitignore
vendored
Normal file
|
@ -0,0 +1,353 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
using Pulumi;
|
||||
|
||||
class Component : Pulumi.ComponentResource
|
||||
{
|
||||
public Component(string name, ComponentArgs? args = null, ComponentResourceOptions? opts = null)
|
||||
: base("testcomponent:index:Component", name, args ?? ResourceArgs.Empty, opts, remote: true)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ComponentArgs : Pulumi.ResourceArgs
|
||||
{
|
||||
[Input("children")]
|
||||
public int? Children { get; set; }
|
||||
|
||||
public ComponentArgs()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
using Pulumi;
|
||||
|
||||
class MyStack : Stack
|
||||
{
|
||||
public MyStack()
|
||||
{
|
||||
new Component("component", new ComponentArgs { Children = 5 });
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Pulumi;
|
||||
|
||||
class Program
|
||||
{
|
||||
static Task<int> Main() => Deployment.RunAsync<MyStack>();
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
name: construct_component_plain_dotnet
|
||||
description: A program that constructs a remote component resource with prompt inputs.
|
||||
runtime: dotnet
|
|
@ -0,0 +1,3 @@
|
|||
name: construct_component_plain_go
|
||||
description: A program that constructs a remote component resource with prompt inputs.
|
||||
runtime: go
|
45
tests/integration/construct_component_plain/go/main.go
Normal file
45
tests/integration/construct_component_plain/go/main.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
|
||||
)
|
||||
|
||||
type Component struct {
|
||||
pulumi.ResourceState
|
||||
}
|
||||
|
||||
func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs,
|
||||
opts ...pulumi.ResourceOption) (*Component, error) {
|
||||
var resource Component
|
||||
err := ctx.RegisterRemoteComponentResource("testcomponent:index:Component", name, &args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
type componentArgs struct {
|
||||
Children *int `pulumi:"children"`
|
||||
}
|
||||
|
||||
type ComponentArgs struct {
|
||||
Children *int
|
||||
}
|
||||
|
||||
func (ComponentArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*componentArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
func main() {
|
||||
pulumi.Run(func(ctx *pulumi.Context) error {
|
||||
children := 5
|
||||
if _, err := NewComponent(ctx, "component", ComponentArgs{Children: &children}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
3
tests/integration/construct_component_plain/nodejs/.gitignore
vendored
Normal file
3
tests/integration/construct_component_plain/nodejs/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/.pulumi/
|
||||
/bin/
|
||||
/node_modules/
|
|
@ -0,0 +1,3 @@
|
|||
name: construct_component_plain_nodejs
|
||||
description: A program that constructs a remote component resource with prompt inputs.
|
||||
runtime: nodejs
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
|
||||
export interface ComponentArgs {
|
||||
children?: number;
|
||||
}
|
||||
|
||||
export class Component extends pulumi.ComponentResource {
|
||||
constructor(name: string, args: ComponentArgs, opts?: pulumi.ComponentResourceOptions) {
|
||||
super("testcomponent:index:Component", name, args, opts, true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
import { Component } from "./component";
|
||||
|
||||
new Component("component", { children: 5 });
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "steps",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "^3.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pulumi/pulumi": "latest"
|
||||
}
|
||||
}
|
5
tests/integration/construct_component_plain/python/.gitignore
vendored
Normal file
5
tests/integration/construct_component_plain/python/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
*.pyc
|
||||
/.pulumi/
|
||||
/dist/
|
||||
/*.egg-info
|
||||
venv/
|
|
@ -0,0 +1,3 @@
|
|||
name: construct_component_plain_py
|
||||
description: A program that constructs a remote component resource with prompt inputs.
|
||||
runtime: python
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
from component import Component
|
||||
|
||||
Component("component", children=5)
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
import pulumi
|
||||
|
||||
class Component(pulumi.ComponentResource):
|
||||
def __init__(self,
|
||||
name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
children: Optional[int] = None):
|
||||
props = dict()
|
||||
props["children"] = children
|
||||
super().__init__("testcomponent:index:Component", name, props, opts, True)
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as dynamic from "@pulumi/pulumi/dynamic";
|
||||
import * as provider from "@pulumi/pulumi/provider";
|
||||
|
||||
let currentID = 0;
|
||||
|
||||
class Resource extends dynamic.Resource {
|
||||
constructor(name: string, opts?: pulumi.CustomResourceOptions) {
|
||||
const provider = {
|
||||
create: async (inputs: any) => {
|
||||
return {
|
||||
id: (currentID++).toString(),
|
||||
outs: undefined,
|
||||
};
|
||||
},
|
||||
};
|
||||
super(provider, name, {}, opts);
|
||||
}
|
||||
}
|
||||
|
||||
interface ComponentArgs {
|
||||
children?: number;
|
||||
}
|
||||
|
||||
class Component extends pulumi.ComponentResource {
|
||||
constructor(name: string, args?: ComponentArgs, opts?: pulumi.ComponentResourceOptions) {
|
||||
super("testcomponent:index:Component", name, {}, opts);
|
||||
const children = args?.children ?? 0;
|
||||
if (children <= 0) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < children; i++) {
|
||||
new Resource(`child-${name}-${i+1}`, {parent: this});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Provider implements provider.Provider {
|
||||
public readonly version = "0.0.1";
|
||||
|
||||
construct(name: string, type: string, inputs: pulumi.Inputs,
|
||||
options: pulumi.ComponentResourceOptions): Promise<provider.ConstructResult> {
|
||||
if (type != "testcomponent:index:Component") {
|
||||
throw new Error(`unknown resource type ${type}`);
|
||||
}
|
||||
|
||||
const component = new Component(name, inputs, options);
|
||||
return Promise.resolve({
|
||||
urn: component.urn,
|
||||
state: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function main(args: string[]) {
|
||||
return provider.main(new Provider(), args);
|
||||
}
|
||||
|
||||
main(process.argv.slice(2));
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "pulumi-resource-testcomponent",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"typescript": "^3.0.0",
|
||||
"@types/node": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pulumi/pulumi": "latest"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
node $SCRIPT_DIR/bin $@
|
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
setlocal
|
||||
set SCRIPT_DIR=%~dp0
|
||||
@node "%SCRIPT_DIR%/bin" %*
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"outDir": "bin",
|
||||
"target": "es2016",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"sourceMap": false,
|
||||
"stripInternal": true,
|
||||
"experimentalDecorators": true,
|
||||
"pretty": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.ts",
|
||||
]
|
||||
}
|
|
@ -279,6 +279,35 @@ func TestConstructSlowDotnet(t *testing.T) {
|
|||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
// Test remote component construction with prompt inputs.
|
||||
func TestConstructPlainDotnet(t *testing.T) {
|
||||
pathEnv, err := testComponentPlainPathEnv()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build test component PATH: %v", err)
|
||||
}
|
||||
|
||||
// TODO[pulumi/pulumi#5455]: Dynamic providers fail to load when used from multi-lang components.
|
||||
// Until we've addressed this, set PULUMI_TEST_YARN_LINK_PULUMI, which tells the integration test
|
||||
// module to run `yarn install && yarn link @pulumi/pulumi` in the .NET program's directory, allowing
|
||||
// the Node.js dynamic provider plugin to load.
|
||||
// When the underlying issue has been fixed, the use of this environment variable inside the integration
|
||||
// test module should be removed.
|
||||
const testYarnLinkPulumiEnv = "PULUMI_TEST_YARN_LINK_PULUMI=true"
|
||||
|
||||
var opts *integration.ProgramTestOptions
|
||||
opts = &integration.ProgramTestOptions{
|
||||
Env: []string{pathEnv, testYarnLinkPulumiEnv},
|
||||
Dir: filepath.Join("construct_component_plain", "dotnet"),
|
||||
Dependencies: []string{"Pulumi"},
|
||||
Quick: true,
|
||||
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
|
||||
assert.NotNil(t, stackInfo.Deployment)
|
||||
assert.Equal(t, 9, len(stackInfo.Deployment.Resources))
|
||||
},
|
||||
}
|
||||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
func TestGetResourceDotnet(t *testing.T) {
|
||||
integration.ProgramTest(t, &integration.ProgramTestOptions{
|
||||
Dependencies: []string{"Pulumi"},
|
||||
|
|
|
@ -211,6 +211,37 @@ func TestConstructSlowGo(t *testing.T) {
|
|||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
// Test remote component construction with prompt inputs.
|
||||
func TestConstructPlainGo(t *testing.T) {
|
||||
pathEnv, err := testComponentPlainPathEnv()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build test component PATH: %v", err)
|
||||
}
|
||||
|
||||
// TODO[pulumi/pulumi#5455]: Dynamic providers fail to load when used from multi-lang components.
|
||||
// Until we've addressed this, set PULUMI_TEST_YARN_LINK_PULUMI, which tells the integration test
|
||||
// module to run `yarn install && yarn link @pulumi/pulumi` in the Go program's directory, allowing
|
||||
// the Node.js dynamic provider plugin to load.
|
||||
// When the underlying issue has been fixed, the use of this environment variable inside the integration
|
||||
// test module should be removed.
|
||||
const testYarnLinkPulumiEnv = "PULUMI_TEST_YARN_LINK_PULUMI=true"
|
||||
|
||||
var opts *integration.ProgramTestOptions
|
||||
opts = &integration.ProgramTestOptions{
|
||||
Env: []string{pathEnv, testYarnLinkPulumiEnv},
|
||||
Dir: filepath.Join("construct_component_plain", "go"),
|
||||
Dependencies: []string{
|
||||
"github.com/pulumi/pulumi/sdk/v2",
|
||||
},
|
||||
Quick: true,
|
||||
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
|
||||
assert.NotNil(t, stackInfo.Deployment)
|
||||
assert.Equal(t, 9, len(stackInfo.Deployment.Resources))
|
||||
},
|
||||
}
|
||||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
func TestGetResourceGo(t *testing.T) {
|
||||
integration.ProgramTest(t, &integration.ProgramTestOptions{
|
||||
Dependencies: []string{
|
||||
|
|
|
@ -739,6 +739,27 @@ func TestConstructSlowNode(t *testing.T) {
|
|||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
// Test remote component construction with prompt inputs.
|
||||
func TestConstructPlainNode(t *testing.T) {
|
||||
pathEnv, err := testComponentPlainPathEnv()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build test component PATH: %v", err)
|
||||
}
|
||||
|
||||
var opts *integration.ProgramTestOptions
|
||||
opts = &integration.ProgramTestOptions{
|
||||
Env: []string{pathEnv},
|
||||
Dir: filepath.Join("construct_component_plain", "nodejs"),
|
||||
Dependencies: []string{"@pulumi/pulumi"},
|
||||
Quick: true,
|
||||
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
|
||||
assert.NotNil(t, stackInfo.Deployment)
|
||||
assert.Equal(t, 9, len(stackInfo.Deployment.Resources))
|
||||
},
|
||||
}
|
||||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
func TestGetResourceNode(t *testing.T) {
|
||||
integration.ProgramTest(t, &integration.ProgramTestOptions{
|
||||
Dir: filepath.Join("get_resource", "nodejs"),
|
||||
|
|
|
@ -468,6 +468,37 @@ func TestConstructSlowPython(t *testing.T) {
|
|||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
// Test remote component construction with prompt inputs.
|
||||
func TestConstructPlainPython(t *testing.T) {
|
||||
pathEnv, err := testComponentPlainPathEnv()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to build test component PATH: %v", err)
|
||||
}
|
||||
|
||||
// TODO[pulumi/pulumi#5455]: Dynamic providers fail to load when used from multi-lang components.
|
||||
// Until we've addressed this, set PULUMI_TEST_YARN_LINK_PULUMI, which tells the integration test
|
||||
// module to run `yarn install && yarn link @pulumi/pulumi` in the Python program's directory, allowing
|
||||
// the Node.js dynamic provider plugin to load.
|
||||
// When the underlying issue has been fixed, the use of this environment variable inside the integration
|
||||
// test module should be removed.
|
||||
const testYarnLinkPulumiEnv = "PULUMI_TEST_YARN_LINK_PULUMI=true"
|
||||
|
||||
var opts *integration.ProgramTestOptions
|
||||
opts = &integration.ProgramTestOptions{
|
||||
Env: []string{pathEnv, testYarnLinkPulumiEnv},
|
||||
Dir: filepath.Join("construct_component_plain", "python"),
|
||||
Dependencies: []string{
|
||||
filepath.Join("..", "..", "sdk", "python", "env", "src"),
|
||||
},
|
||||
Quick: true,
|
||||
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
|
||||
assert.NotNil(t, stackInfo.Deployment)
|
||||
assert.Equal(t, 9, len(stackInfo.Deployment.Resources))
|
||||
},
|
||||
}
|
||||
integration.ProgramTest(t, opts)
|
||||
}
|
||||
|
||||
func TestGetResourcePython(t *testing.T) {
|
||||
if runtime.GOOS == WindowsOS {
|
||||
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
|
||||
|
|
|
@ -575,6 +575,11 @@ func testComponentSlowPathEnv() (string, error) {
|
|||
return componentPathEnv("construct_component_slow", "testcomponent")
|
||||
}
|
||||
|
||||
//nolint:golint,deadcode
|
||||
func testComponentPlainPathEnv() (string, error) {
|
||||
return componentPathEnv("construct_component_plain", "testcomponent")
|
||||
}
|
||||
|
||||
func componentPathEnv(integrationTest, componentDir string) (string, error) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue