Skip to content

Commit

Permalink
Use go:embed schema-embed.json
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Sep 19, 2023
1 parent f8d9fd9 commit 20b52a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 3 additions & 7 deletions provider/cmd/pulumi-resource-ns1/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
// 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"
"io/ioutil"
"log"
"os"

Expand All @@ -32,7 +31,7 @@ func main() {
log.Fatal("version not found")
}

schemaContents, err := ioutil.ReadFile("./schema.json")
schemaContents, err := os.ReadFile("./schema.json")
if err != nil {
log.Fatal(err)
}
Expand All @@ -49,10 +48,7 @@ func main() {
log.Fatalf("cannot reserialize schema: %v", err)
}

err = ioutil.WriteFile("./schema.go", []byte(fmt.Sprintf(`package main
var pulumiSchema = %#v
`, versionedContents)), 0600)
if err != nil {
if err = os.WriteFile("./schema-embed.json", versionedContents, 0600); err != nil {
log.Fatal(err)
}
}
5 changes: 5 additions & 0 deletions provider/cmd/pulumi-resource-ns1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
package main

import (
_ "embed" // for embedding schema

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"

ns1 "github.com/pulumi/pulumi-ns1/provider/v3"
"github.com/pulumi/pulumi-ns1/provider/v3/pkg/version"
)

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

func main() {
// Modify the path to point to the new provider
tfbridge.Main("ns1", version.Version, ns1.Provider(), pulumiSchema)
Expand Down

0 comments on commit 20b52a0

Please sign in to comment.