Skip to content

Commit

Permalink
chore: remove minimal schema from source (#4829)
Browse files Browse the repository at this point in the history
Keeping a copy of minimal schema (introduced in
#4587) is proving to conflict
with Pulumi tooling such as `upgrade-provider` and is not strictly
necessary. With this change the minimal schema itself as well as CI
checks to make sure it is up to date are removed. Instead it will be
computed on-the-fly by the release job as before:
 
- GitHub actions invoke this:
https://github.com/pulumi/pulumi-aws/blob/916e6f28039407d7dcb1a295c6f9e43613dd6f87/.github/workflows/build_provider.yml#L60

- Make extension ensures that this runs go generate prior to the actual
build so that the minimal schema is re-computed:
https://github.com/pulumi/pulumi-aws/blob/916e6f28039407d7dcb1a295c6f9e43613dd6f87/.mk/minimal_schema.mk#L9

Fixes:

- #4811
- #4702
  • Loading branch information
t0yv0 authored Nov 26, 2024
1 parent 64a5e1d commit ea37dae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 426,052 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/aws-minimal-schema.yml

This file was deleted.

1 change: 1 addition & 0 deletions .mk/minimal_schema.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bin/linux-arm64/$(PROVIDER): minimal_schema_no_deps
bin/darwin-amd64/$(PROVIDER): minimal_schema_no_deps
bin/darwin-arm64/$(PROVIDER): minimal_schema_no_deps
bin/windows-amd64/$(PROVIDER).exe: minimal_schema_no_deps
provider_no_deps: minimal_schema_no_deps
3 changes: 0 additions & 3 deletions provider/cmd/pulumi-resource-aws/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,4 @@ func main() {
}); err != nil {
log.Fatal(err)
}

// Also compute the embedded version of the minimal schema.
embedMinimalSchema(version)
}
25 changes: 14 additions & 11 deletions provider/cmd/pulumi-resource-aws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package main

import (
"bytes"
"compress/gzip"
"context"
_ "embed"
"embed"
"io"
"os"

Expand All @@ -30,16 +29,15 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

//go:embed schema-embed.json
var pulumiSchema []byte

//go:embed schema-minimal-embed.json
var pulumiMinimalSchema []byte
//go:embed schema*embed.json
var schemas embed.FS

// The data in the minimal schema is compressed with GZIP to avoid bloating the provider size at the cost of slightly
// slower init for uses of the feature.
func decompressMinimalSchema() []byte {
reader, err := gzip.NewReader(bytes.NewReader(pulumiMinimalSchema))
reader0, err := schemas.Open("schema-minimal-embed.json")
contract.AssertNoErrorf(err, "Failed to open a reader into the embedded schema-minimal-embed.json")
reader, err := gzip.NewReader(reader0)
contract.AssertNoErrorf(err, "Failed to open a reader into schema-minimal-embed.json")
bytes, err := io.ReadAll(reader)
contract.AssertNoErrorf(err, "Failed to read schema-minimal-embed.json")
Expand All @@ -50,10 +48,15 @@ func main() {
ctx := context.Background()
info := aws.Provider()

s := pulumiSchema
var schemaBytes []byte
if cmdutil.IsTruthy(os.Getenv("PULUMI_AWS_MINIMAL_SCHEMA")) {
s = decompressMinimalSchema()
schemaBytes = decompressMinimalSchema()
} else {
schemaReader, err := schemas.Open("schema-embed.json")
contract.AssertNoErrorf(err, "Failed to open a reader into the embedded schema-embed.json")
schemaBytes, err = io.ReadAll(schemaReader)
contract.AssertNoErrorf(err, "Failed to read schema-embed.json")
}

pf.MainWithMuxer(ctx, "aws", *info, s)
pf.MainWithMuxer(ctx, "aws", *info, schemaBytes)
}
Loading

0 comments on commit ea37dae

Please sign in to comment.