Skip to content

Commit

Permalink
Merge 47df4ca into 63e129a
Browse files Browse the repository at this point in the history
  • Loading branch information
pgavlin committed Jun 14, 2021
2 parents 63e129a + 47df4ca commit 03bb49a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions pkg/codegen/hcl2/binder.go
Expand Up @@ -29,9 +29,10 @@ import (
)

type bindOptions struct {
allowMissingVariables bool
loader schema.Loader
packageCache *PackageCache
allowMissingVariables bool
allowMissingProperties bool
loader schema.Loader
packageCache *PackageCache
}

func (opts bindOptions) modelOptions() []model.BindOption {
Expand All @@ -58,6 +59,10 @@ func AllowMissingVariables(options *bindOptions) {
options.allowMissingVariables = true
}

func AllowMissingProperties(options *bindOptions) {
options.allowMissingProperties = true
}

func PluginHost(host plugin.Host) BindOption {
return Loader(schema.NewPluginLoader(host))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/hcl2/binder_schema.go
Expand Up @@ -168,7 +168,7 @@ func (b *binder) schemaTypeToTypeImpl(src schema.Type, seen map[schema.Type]mode
seen[src] = objType
for _, prop := range src.Properties {
t := b.schemaTypeToTypeImpl(prop.Type, seen)
if !prop.IsRequired {
if !prop.IsRequired || b.options.allowMissingProperties {
t = model.NewOptionalType(t)
}
if prop.ConstValue != nil {
Expand Down

0 comments on commit 03bb49a

Please sign in to comment.