Skip to content

Commit 109db31

Browse files
Generate required fields for DABs (#3036)
## Changes This PR generates patterns for fields to perform required validation on. These patterns will be automatically updated every time we bump the SDK and run genkit. ## Why These generated fields are used in #3044 to perform the actual validation. See: bundle/config/validate/required.go in that PR.
1 parent 71785a5 commit 109db31

File tree

7 files changed

+448
-2
lines changed

7 files changed

+448
-2
lines changed

.codegen.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
"post_generate": [
2424
"go test -timeout 240s -run TestConsistentDatabricksSdkVersion github.com/databricks/cli/internal/build",
2525
"make schema",
26+
"make generate-validation",
2627
"echo 'bundle/internal/tf/schema/\\*.go linguist-generated=true' >> ./.gitattributes",
2728
"echo 'go.sum linguist-generated=true' >> ./.gitattributes",
28-
"echo 'bundle/schema/jsonschema.json linguist-generated=true' >> ./.gitattributes"
29+
"echo 'bundle/schema/jsonschema.json linguist-generated=true' >> ./.gitattributes",
30+
"echo 'bundle/internal/validation/generated/required_fields.go linguist-generated=true' >> ./.gitattributes"
2931
]
3032
}
3133
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,4 @@ cmd/workspace/workspace/workspace.go linguist-generated=true
153153
bundle/internal/tf/schema/\*.go linguist-generated=true
154154
go.sum linguist-generated=true
155155
bundle/schema/jsonschema.json linguist-generated=true
156+
bundle/internal/validation/generated/required_fields.go linguist-generated=true

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ integration:
9898
integration-short:
9999
VERBOSE_TEST=1 $(INTEGRATION) -short
100100

101+
generate-validation:
102+
go run ./bundle/internal/validation/.
103+
101104
generate:
102105
genkit update-sdk
103106
[ ! -f tagging.py ] || mv tagging.py internal/genkit/tagging.py
@@ -107,4 +110,4 @@ generate:
107110
[ ! -f .github/workflows/next-changelog.yml ] || rm .github/workflows/next-changelog.yml
108111
pushd experimental/python && make codegen
109112

110-
.PHONY: lint lintfull tidy lintcheck fmt fmtfull test cover showcover build snapshot schema integration integration-short acc-cover acc-showcover docs ws links checks test-update test-update-aws test-update-all
113+
.PHONY: lint lintfull tidy lintcheck fmt fmtfull test cover showcover build snapshot schema integration integration-short acc-cover acc-showcover docs ws links checks test-update test-update-aws test-update-all generate-validation

bundle/internal/validation/generated/required_fields.go

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/internal/validation/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"log"
5+
)
6+
7+
// This package is meant to be run from the root of the CLI repo.
8+
func main() {
9+
err := generateRequiredFields("bundle/internal/validation/generated")
10+
if err != nil {
11+
log.Fatalf("Error generating code: %v", err)
12+
}
13+
}

0 commit comments

Comments
 (0)