File tree Expand file tree Collapse file tree 5 files changed +37
-206
lines changed
cmd/pulumi-resource-command Expand file tree Collapse file tree 5 files changed +37
-206
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ ci-scripts
1313sdk /dotnet /version.txt
1414.DS_Store
1515/provider /cmd /pulumi-resource-command /schema.go
16+ /provider /cmd /pulumi-resource-command /schema-embed.json
1617dist /
1718
1819rsa *
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515//go:build ignore
16- // +build ignore
1716
1817package main
1918
2019import (
21- "fmt"
20+ "encoding/json"
21+ "errors"
22+ "io/fs"
2223 "io/ioutil"
2324 "log"
25+ "os"
26+
27+ "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
2428)
2529
2630func main () {
31+ version , found := os .LookupEnv ("VERSION" )
32+ if ! found {
33+ log .Fatal ("version not found" )
34+ }
35+
2736 schemaContents , err := ioutil .ReadFile ("./schema.json" )
2837 if err != nil {
2938 log .Fatal (err )
3039 }
3140
32- err = ioutil .WriteFile ("./schema.go" , []byte (fmt .Sprintf (`package main
33- var pulumiSchema = %#v
34- ` , schemaContents )), 0600 )
41+ var packageSpec schema.PackageSpec
42+ err = json .Unmarshal (schemaContents , & packageSpec )
43+ if err != nil {
44+ log .Fatalf ("cannot deserialize schema: %v" , err )
45+ }
46+
47+ packageSpec .Version = version
48+ versionedContents , err := json .Marshal (packageSpec )
49+ if err != nil {
50+ log .Fatalf ("cannot reserialize schema: %v" , err )
51+ }
52+
53+ // Clean up schema.go as it may be present & gitignored and tolerate an error if the file isn't present.
54+ err = os .Remove ("./schema.go" )
55+ if err != nil && ! errors .Is (err , fs .ErrNotExist ) {
56+ log .Fatal (err )
57+ }
58+
59+ err = ioutil .WriteFile ("./schema-embed.json" , versionedContents , 0600 )
3560 if err != nil {
3661 log .Fatal (err )
3762 }
Original file line number Diff line number Diff line change 1717package main
1818
1919import (
20+ _ "embed"
21+
2022 "github.com/pulumi/pulumi-command/provider/pkg/provider"
2123 "github.com/pulumi/pulumi-command/provider/pkg/version"
2224)
2325
24- var providerName = "command"
26+ //go:embed schema-embed.json
27+ var pulumiSchema []byte
2528
2629func main () {
27- provider .Serve (providerName , version .Version , pulumiSchema )
30+ provider .Serve ("command" , version .Version , pulumiSchema )
2831}
Original file line number Diff line number Diff line change 11module github.com/pulumi/pulumi-command/provider
22
3- go 1.17
3+ go 1.18
44
55require (
66 github.com/golang/protobuf v1.5.2
You can’t perform that action at this time.
0 commit comments