create generated package

This commit is contained in:
Shreyas Goenka 2024-09-04 11:56:52 +02:00
parent 446463b9eb
commit bfe9cc4d50
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
5 changed files with 11 additions and 7 deletions

View File

@ -11,10 +11,10 @@
"toolchain": {
"required": ["go"],
"post_generate": [
"go run ./bundle/internal/schema/*.go ./bundle/internal/schema/generated/jsonschema.json",
"go run ./bundle/internal/schema/*.go ./bundle/generated/jsonschema.json",
"echo 'bundle/internal/tf/schema/\\*.go linguist-generated=true' >> ./.gitattributes",
"echo 'go.sum linguist-generated=true' >> ./.gitattributes",
"echo 'bundle/internal/schema/generated/jsonschema.json linguist-generated=true' >> ./.gitattributes"
"echo 'bundle/generated/jsonschema.json linguist-generated=true' >> ./.gitattributes"
]
}
}

2
.gitattributes vendored
View File

@ -120,4 +120,4 @@ cmd/workspace/workspace-conf/workspace-conf.go linguist-generated=true
cmd/workspace/workspace/workspace.go linguist-generated=true
bundle/internal/tf/schema/\*.go linguist-generated=true
go.sum linguist-generated=true
bundle/internal/schema/generated/jsonschema.json linguist-generated=true
bundle/generated/jsonschema.json linguist-generated=true

View File

@ -0,0 +1,6 @@
package generated
import _ "embed"
// go:embed jsonschema.json
var BundleSchema []byte

View File

@ -3,13 +3,11 @@ package bundle
import (
_ "embed"
"github.com/databricks/cli/bundle/generated"
"github.com/databricks/cli/cmd/root"
"github.com/spf13/cobra"
)
//go:embed _generated/jsonschema.json
var bundleSchemaBytes []byte
func newSchemaCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "schema",
@ -18,7 +16,7 @@ func newSchemaCommand() *cobra.Command {
}
cmd.RunE = func(cmd *cobra.Command, args []string) error {
_, err := cmd.OutOrStdout().Write(bundleSchemaBytes)
_, err := cmd.OutOrStdout().Write(generated.BundleSchema)
return err
}