Skip to content

Commit

Permalink
Depend on pu/pu v3.48.0 (#424)
Browse files Browse the repository at this point in the history
* Upgrade pu/pu dep to v3.48.0

* Remove environmentType from azure-container-apps

This property is not present in the azure-native schema, not does it
pass type check in Pulumi YAML.

* Mock out RunPlugin for *uamlLanguageHost

This is needed for interface compliance.

* Skip typechecking for remaining examples

`azure-app-service` should type check, pulumi/pulumi#11572 will address
the issue.

I'm not sure why `aws-static-website` doesn't type check, the error
message is inscrutable. I opened pulumi/pulumi#11573 to address the
error message. We can come back to the underlying error after the error
message describes the error in a readable way.

* Update TestGenerateProgram tests
  • Loading branch information
iwahbe committed Dec 7, 2022
1 parent 03c59f6 commit d3bedd9
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 34 deletions.
1 change: 0 additions & 1 deletion examples/azure-container-apps/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ resources:
type: azure-native:web:KubeEnvironment
properties:
resourceGroupName: ${resourceGroup.name}
environmentType: Managed
appLogsConfiguration:
destination: "log-analytics"
logAnalyticsConfiguration:
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/hexops/autogold v1.3.0
github.com/iancoleman/strcase v0.2.0
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v3 v3.46.1
github.com/pulumi/pulumi/sdk/v3 v3.46.1
github.com/pulumi/pulumi/pkg/v3 v3.48.0
github.com/pulumi/pulumi/sdk/v3 v3.48.0
github.com/stretchr/testify v1.8.0
github.com/zclconf/go-cty v1.10.0
google.golang.org/grpc v1.49.0
Expand Down Expand Up @@ -101,6 +101,7 @@ require (
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
Expand All @@ -121,12 +122,12 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/natefinch/atomic v1.0.1 // indirect
github.com/nightlyone/lockfile v1.0.0 // indirect
Expand Down
114 changes: 108 additions & 6 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/pulumiyaml/codegen/gen_program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func TestGenerateProgram(t *testing.T) {
case "read-file-func", "python-regress-10914":
tt.SkipCompile = codegen.NewStringSet("yaml")
l = append(l, tt)
case "traverse-union-repro":
// Reason: this example is known to be invalid
default:
l = append(l, tt)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
source = remoteAsset("https://pulumi.test")
}

resource testFileArchive "aws:s3:BucketObject" {
bucket = siteBucket.id // Reference the s3.Bucket object
source = fileArchive("file.tar.gz")
resource testFileArchive "aws:lambda:Function" {
role = siteBucket.arn // Reference the s3.Bucket object
code = fileArchive("file.tar.gz")
}

resource testRemoteArchive "aws:s3:BucketObject" {
bucket = siteBucket.id // Reference the s3.Bucket object
source = remoteArchive("https://pulumi.test/foo.tar.gz")
resource testRemoteArchive "aws:lambda:Function" {
role = siteBucket.arn // Reference the s3.Bucket object
code = remoteArchive("https://pulumi.test/foo.tar.gz")
}

resource testAssetArchive "aws:s3:BucketObject" {
bucket = siteBucket.id // Reference the s3.Bucket object
source = assetArchive({
resource testAssetArchive "aws:lambda:Function" {
role = siteBucket.arn // Reference the s3.Bucket object
code = assetArchive({
"file.txt": fileAsset("file.txt")
"string.txt": stringAsset("<h1>File contents</h1>")
"remote.txt": remoteAsset("https://pulumi.test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ resources:
source:
fn::RemoteAsset: https://pulumi.test
testFileArchive:
type: aws:s3:BucketObject
type: aws:lambda:Function
properties:
bucket: ${siteBucket.id}
role: ${siteBucket.arn}
# Reference the s3.Bucket object
source:
code:
fn::FileArchive: file.tar.gz
testRemoteArchive:
type: aws:s3:BucketObject
type: aws:lambda:Function
properties:
bucket: ${siteBucket.id}
role: ${siteBucket.arn}
# Reference the s3.Bucket object
source:
code:
fn::RemoteArchive: https://pulumi.test/foo.tar.gz
testAssetArchive:
type: aws:s3:BucketObject
type: aws:lambda:Function
properties:
bucket: ${siteBucket.id}
role: ${siteBucket.arn}
# Reference the s3.Bucket object
source:
code:
fn::AssetArchive:
file.txt:
fn::FileAsset: file.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
resource bar "kubernetes:core/v1:Pod" {
apiVersion = "v1"
kind = "Pod"
metadata = {
namespace = "foo"
name = "bar"
Expand All @@ -21,3 +20,6 @@
]
}
}

// Test that we can assign from a constant without type errors
kind = bar.kind
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resources:
type: kubernetes:core/v1:Pod
properties:
apiVersion: v1
kind: Pod
metadata:
namespace: foo
name: bar
Expand All @@ -17,3 +16,6 @@ resources:
limits:
memory: 20Mi
cpu: 0.2
variables:
# Test that we can assign from a constant without type errors
kind: ${bar.kind}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "test" "aws:fsx:OpenZfsFileSystem" {
storageCapacity = 64
subnetIds = [aws_subnet.test1.id]
deploymentType = "SINGLE_AZ_1"
throughputCapacity = 64
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
test:
type: aws:fsx:OpenZfsFileSystem
properties:
storageCapacity: 64
subnetIds:
- ${aws_subnet.test1.id}
deploymentType: SINGLE_AZ_1
throughputCapacity: 64
6 changes: 6 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/pulumi/pulumi-yaml/pkg/pulumiyaml"
Expand Down Expand Up @@ -204,3 +206,7 @@ func (host *yamlLanguageHost) GetProgramDependencies(ctx context.Context, req *p
func (host *yamlLanguageHost) About(ctx context.Context, req *emptypb.Empty) (*pulumirpc.AboutResponse, error) {
return &pulumirpc.AboutResponse{}, nil
}

func (host *yamlLanguageHost) RunPlugin(*pulumirpc.RunPluginRequest, pulumirpc.LanguageRuntime_RunPluginServer) error {
return status.Errorf(codes.Unimplemented, "method RunPlugin not implemented")
}
11 changes: 10 additions & 1 deletion pkg/tests/example_transpile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ var (
// PCL does not have stringAssets
"getting-started",
}

pclBindOpts = map[string][]pcl.BindOption{
// pulumi/pulumi#11572
"azure-app-service": {pcl.SkipResourceTypechecking},

"aws-static-website": {pcl.SkipResourceTypechecking},
}
)

func makeAbs(path string) string {
Expand Down Expand Up @@ -151,7 +158,9 @@ func getValidPCLFile(t *testing.T, file *ast.TemplateDecl, fileName string) ([]b
return nil, diags, err
}
diags = diags.Extend(parser.Diagnostics)
_, pdiags, err := pcl.BindProgram(parser.Files, pcl.Loader(rootPluginLoader.ReferenceLoader))
bindOpts := append(pclBindOpts[strings.TrimSuffix(fileName, ".pp")],
pcl.Loader(rootPluginLoader.ReferenceLoader))
_, pdiags, err := pcl.BindProgram(parser.Files, bindOpts...)
if err != nil {
return []byte(program), diags, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
resource kubeEnv "azure-native:web:KubeEnvironment" {
__logicalName = "kubeEnv"
resourceGroupName = resourceGroup.name
environmentType = "Managed"
appLogsConfiguration = {
destination = "log-analytics",
logAnalyticsConfiguration = {
Expand Down

0 comments on commit d3bedd9

Please sign in to comment.