Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Set schema.configmode in cli schema conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <[email protected]>
(cherry picked from commit dc08971)
  • Loading branch information
turkenh authored and github-actions[bot] committed Mar 4, 2022
1 parent ab247a2 commit 9a5f320
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/types/conversion/tfjson/tfjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func tfJSONBlockTypeToV2Schema(nb *tfjson.SchemaBlockType) *schemav2.Schema { //
}

func schemaV2TypeFromCtyType(typ cty.Type, schema *schemav2.Schema) error { //nolint:gocyclo
configMode := schemav2.SchemaConfigModeAuto

switch {
case typ.IsPrimitiveType():
schema.Type = primitiveToV2SchemaType(typ)
Expand All @@ -171,6 +173,7 @@ func schemaV2TypeFromCtyType(typ cty.Type, schema *schemav2.Schema) error { //no
return err
}
case et.IsObjectType():
configMode = schemav2.SchemaConfigModeAttr
res := &schemav2.Resource{}
res.Schema = make(map[string]*schemav2.Schema, len(et.AttributeTypes()))
for key, attrTyp := range et.AttributeTypes() {
Expand All @@ -191,6 +194,7 @@ func schemaV2TypeFromCtyType(typ cty.Type, schema *schemav2.Schema) error { //no
default:
return errors.Errorf("unexpected cty.Type %s", typ.GoString())
}
schema.ConfigMode = configMode
schema.Type = collectionToV2SchemaType(typ)
schema.Elem = elemType
case typ.IsTupleType():
Expand Down

0 comments on commit 9a5f320

Please sign in to comment.