-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix proposed new unknown blocks (#2060)
This updates our `objchange` algorithm with the newest one from the OpenTofu repo. This fixes an issue with the way unknown sets are presented to TF. fixes #1951
- Loading branch information
1 parent
ba48631
commit b012fa8
Showing
13 changed files
with
1,007 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
pkg/tfshim/sdk-v2/internal/tf/configs/configschema/decoder_spec.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
pkg/tfshim/sdk-v2/internal/tf/configs/configschema/empty_value.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
pkg/tfshim/sdk-v2/internal/tf/configs/configschema/implied_type.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
pkg/tfshim/sdk-v2/internal/tf/configs/configschema/nestingmode_string.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
pkg/tfshim/sdk-v2/internal/tf/configs/configschema/path.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Code copied from https://github.com/opentofu/opentofu.git by go generate; DO NOT EDIT. | ||
// Copyright (c) The OpenTofu Authors | ||
// SPDX-License-Identifier: MPL-2.0 | ||
// Copyright (c) 2023 HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package configschema | ||
|
||
import ( | ||
"github.com/zclconf/go-cty/cty" | ||
) | ||
|
||
// AttributeByPath looks up the Attribute schema which corresponds to the given | ||
// cty.Path. A nil value is returned if the given path does not correspond to a | ||
// specific attribute. | ||
func (b *Block) AttributeByPath(path cty.Path) *Attribute { | ||
block := b | ||
for i, step := range path { | ||
switch step := step.(type) { | ||
case cty.GetAttrStep: | ||
if attr := block.Attributes[step.Name]; attr != nil { | ||
// If the Attribute is defined with a NestedType and there's | ||
// more to the path, descend into the NestedType | ||
if attr.NestedType != nil && i < len(path)-1 { | ||
return attr.NestedType.AttributeByPath(path[i+1:]) | ||
} else if i < len(path)-1 { // There's more to the path, but not more to this Attribute. | ||
return nil | ||
} | ||
return attr | ||
} | ||
|
||
if nestedBlock := block.BlockTypes[step.Name]; nestedBlock != nil { | ||
block = &nestedBlock.Block | ||
continue | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// AttributeByPath recurses through a NestedType to look up the Attribute scheme | ||
// which corresponds to the given cty.Path. A nil value is returned if the given | ||
// path does not correspond to a specific attribute. | ||
func (o *Object) AttributeByPath(path cty.Path) *Attribute { | ||
for i, step := range path { | ||
switch step := step.(type) { | ||
case cty.GetAttrStep: | ||
if attr := o.Attributes[step.Name]; attr != nil { | ||
if attr.NestedType != nil && i < len(path)-1 { | ||
return attr.NestedType.AttributeByPath(path[i+1:]) | ||
} else if i < len(path)-1 { // There's more to the path, but not more to this Attribute. | ||
return nil | ||
} | ||
return attr | ||
} | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.