Skip to content

Commit

Permalink
Migrate provider to schema-embed.json to address linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Sep 20, 2023
1 parent 13e7217 commit 38bbcad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sdk/nodejs/node_modules
yarn.lock

**/schema.go
**/schema-embed.json
**/version.txt

**/ci-scripts
Expand Down
14 changes: 10 additions & 4 deletions provider/cmd/pulumi-resource-kong/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions provider/cmd/pulumi-resource-kong/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 38bbcad

Please sign in to comment.