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: Restore minimal schema #5020

Merged
merged 1 commit into from
Dec 30, 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
8 changes: 2 additions & 6 deletions .mk/minimal_schema.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
minimal_schema: provider/cmd/pulumi-resource-aws/schema-minimal-embed.json

.PHONY: minimal_schema

provider/cmd/pulumi-resource-aws/schema-minimal-embed.json: provider/cmd/pulumi-resource-aws/schema.json
echo "Computing minimal schema"
cd provider/cmd/pulumi-resource-aws && PULUMI_AWS_MINIMAL_SCHEMA=true VERSION=$(VERSION_GENERIC) go generate
minimal_schema:
@(cd provider/cmd/pulumi-resource-aws && PULUMI_AWS_MINIMAL_SCHEMA=true VERSION=$(VERSION_GENERIC) go generate)

# In build_provider.yml workflow, minimal schema needs to be rebuilt right before the provider binary.
bin/linux-amd64/$(PROVIDER): minimal_schema
Expand Down
45 changes: 45 additions & 0 deletions examples/minimal_schema_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2016-2024, Pulumi Corporation. All rights reserved.
//go:build nodejs || all
// +build nodejs all

package examples

import (
"bytes"
"encoding/json"
"os"
"os/exec"
"path/filepath"
"testing"

"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/utils"
"github.com/stretchr/testify/require"
)

func TestMinimalSchema(t *testing.T) {
var buf bytes.Buffer
schemaSource := filepath.Join("..", "bin", "pulumi-resource-aws")
t.Logf("pulumi package get-schema %s", schemaSource)
cmd := exec.Command("pulumi", "package", "get-schema", schemaSource)
cmd.Env = append(os.Environ(), "PULUMI_AWS_MINIMAL_SCHEMA=true")
cmd.Stdout = &buf
err := cmd.Run()
cmd.Stderr = os.Stderr
if err != nil {
t.Logf("%s", buf.String())
require.NoError(t, err)
}
var packageSpec schema.PackageSpec
err = json.Unmarshal(buf.Bytes(), &packageSpec)
require.NoError(t, err)
t.Logf("Parsed minimal schema")
loader := schema.NewPluginLoader(utils.NewHostWithProviders(t.TempDir()))
_, diags, err := schema.BindSpec(packageSpec, loader)
require.NoError(t, err)
for _, d := range diags {
t.Logf("sev=%v summary: %s\n detail: %s", d.Severity, d.Summary, d.Detail)
}
require.False(t, diags.HasErrors())
t.Logf("Validated minimal schema")
}
Loading