diff --git a/.gitignore b/.gitignore index 0a304895..27dba564 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ sdk/nodejs/node_modules yarn.lock **/schema.go +**/schema-embed.json **/version.txt **/ci-scripts diff --git a/provider/cmd/pulumi-resource-kong/generate.go b/provider/cmd/pulumi-resource-kong/generate.go index a548fda8..8670f4cb 100644 --- a/provider/cmd/pulumi-resource-kong/generate.go +++ b/provider/cmd/pulumi-resource-kong/generate.go @@ -12,13 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build ignore // +build ignore package main import ( "encoding/json" - "fmt" + "errors" + "io/fs" "io/ioutil" "log" "os" @@ -49,9 +51,13 @@ func main() { log.Fatalf("cannot reserialize schema: %v", err) } - err = ioutil.WriteFile("./schema.go", []byte(fmt.Sprintf(`package main -var pulumiSchema = %#v -`, versionedContents)), 0600) + // Clean up schema.go as it may be present & gitignored and tolerate an error if the file isn't present. + err = os.Remove("./schema.go") + if err != nil && !errors.Is(err, fs.ErrNotExist) { + log.Fatal(err) + } + + err = ioutil.WriteFile("./schema-embed.json", versionedContents, 0600) if err != nil { log.Fatal(err) } diff --git a/provider/cmd/pulumi-resource-kong/main.go b/provider/cmd/pulumi-resource-kong/main.go index eaa5395d..d4e50d92 100644 --- a/provider/cmd/pulumi-resource-kong/main.go +++ b/provider/cmd/pulumi-resource-kong/main.go @@ -17,11 +17,15 @@ package main import ( + _ "embed" kong "github.com/pulumi/pulumi-kong/provider/v4" "github.com/pulumi/pulumi-kong/provider/v4/pkg/version" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" ) +//go:embed schema-embed.json +var pulumiSchema []byte + func main() { // Modify the path to point to the new provider tfbridge.Main("kong", version.Version, kong.Provider(), pulumiSchema)