Skip to content

Commit

Permalink
schema: plumb TF version generator via go generate
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Aug 4, 2022
1 parent 2f9d18f commit 20b8c89
Show file tree
Hide file tree
Showing 2 changed files with 254 additions and 0 deletions.
11 changes: 11 additions & 0 deletions schema/core_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ func CoreModuleSchemaForVersion(v *version.Version) (*schema.BodySchema, error)
return nil, fmt.Errorf("no compatible schema found for %s", v.String())
}

//go:generate go run ../internal/versiongen -w ./versions_gen.go
func CoreModuleSchemaForConstraint(vc version.Constraints) (*schema.BodySchema, error) {
for _, v := range terraformVersions {
if vc.Check(v) {
return CoreModuleSchemaForVersion(v)
}
}

return nil, fmt.Errorf("no compatible schema found for %s", vc.String())
}

func semVer(ver *version.Version) (*version.Version, error) {
// Assume that alpha/beta/rc prereleases have the same compatibility
segments := ver.Segments64()
Expand Down
243 changes: 243 additions & 0 deletions schema/versions_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20b8c89

Please sign in to comment.