Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.20.0 to 2.24.1
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.20.0 to 2.24.1. - [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.20.0...v2.24.1) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
76
vendor/github.com/zclconf/go-cty/cty/set/gob.go
generated
vendored
76
vendor/github.com/zclconf/go-cty/cty/set/gob.go
generated
vendored
@ -1,76 +0,0 @@
|
||||
package set
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// GobEncode is an implementation of the interface gob.GobEncoder, allowing
|
||||
// sets to be included in structures encoded via gob.
|
||||
//
|
||||
// The set rules are included in the serialized value, so the caller must
|
||||
// register its concrete rules type with gob.Register before using a
|
||||
// set in a gob, and possibly also implement GobEncode/GobDecode to customize
|
||||
// how any parameters are persisted.
|
||||
//
|
||||
// The set elements are also included, so if they are of non-primitive types
|
||||
// they too must be registered with gob.
|
||||
//
|
||||
// If the produced gob values will persist for a long time, the caller must
|
||||
// ensure compatibility of the rules implementation. In particular, if the
|
||||
// definition of element equivalence changes between encoding and decoding
|
||||
// then two distinct stored elements may be considered equivalent on decoding,
|
||||
// causing the recovered set to have fewer elements than when it was stored.
|
||||
func (s Set) GobEncode() ([]byte, error) {
|
||||
gs := gobSet{
|
||||
Version: 0,
|
||||
Rules: s.rules,
|
||||
Values: s.Values(),
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
enc := gob.NewEncoder(buf)
|
||||
err := enc.Encode(gs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error encoding set.Set: %s", err)
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// GobDecode is the opposite of GobEncode. See GobEncode for information
|
||||
// on the requirements for and caveats of including set values in gobs.
|
||||
func (s *Set) GobDecode(buf []byte) error {
|
||||
r := bytes.NewReader(buf)
|
||||
dec := gob.NewDecoder(r)
|
||||
|
||||
var gs gobSet
|
||||
err := dec.Decode(&gs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error decoding set.Set: %s", err)
|
||||
}
|
||||
if gs.Version != 0 {
|
||||
return fmt.Errorf("unsupported set.Set encoding version %d; need 0", gs.Version)
|
||||
}
|
||||
|
||||
victim := NewSetFromSlice(gs.Rules, gs.Values)
|
||||
s.vals = victim.vals
|
||||
s.rules = victim.rules
|
||||
return nil
|
||||
}
|
||||
|
||||
type gobSet struct {
|
||||
Version int
|
||||
Rules Rules
|
||||
|
||||
// The bucket-based representation is for efficient in-memory access, but
|
||||
// for serialization it's enough to just retain the values themselves,
|
||||
// which we can re-bucket using the rules (which may have changed!) when
|
||||
// we re-inflate.
|
||||
Values []interface{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
gob.Register([]interface{}(nil))
|
||||
}
|
8
vendor/github.com/zclconf/go-cty/cty/set/iterator.go
generated
vendored
8
vendor/github.com/zclconf/go-cty/cty/set/iterator.go
generated
vendored
@ -1,15 +1,15 @@
|
||||
package set
|
||||
|
||||
type Iterator struct {
|
||||
vals []interface{}
|
||||
type Iterator[T any] struct {
|
||||
vals []T
|
||||
idx int
|
||||
}
|
||||
|
||||
func (it *Iterator) Value() interface{} {
|
||||
func (it *Iterator[T]) Value() T {
|
||||
return it.vals[it.idx]
|
||||
}
|
||||
|
||||
func (it *Iterator) Next() bool {
|
||||
func (it *Iterator[T]) Next() bool {
|
||||
it.idx++
|
||||
return it.idx < len(it.vals)
|
||||
}
|
||||
|
46
vendor/github.com/zclconf/go-cty/cty/set/ops.go
generated
vendored
46
vendor/github.com/zclconf/go-cty/cty/set/ops.go
generated
vendored
@ -7,10 +7,10 @@ import (
|
||||
// Add inserts the given value into the receiving Set.
|
||||
//
|
||||
// This mutates the set in-place. This operation is not thread-safe.
|
||||
func (s Set) Add(val interface{}) {
|
||||
func (s Set[T]) Add(val T) {
|
||||
hv := s.rules.Hash(val)
|
||||
if _, ok := s.vals[hv]; !ok {
|
||||
s.vals[hv] = make([]interface{}, 0, 1)
|
||||
s.vals[hv] = make([]T, 0, 1)
|
||||
}
|
||||
bucket := s.vals[hv]
|
||||
|
||||
@ -26,7 +26,7 @@ func (s Set) Add(val interface{}) {
|
||||
|
||||
// Remove deletes the given value from the receiving set, if indeed it was
|
||||
// there in the first place. If the value is not present, this is a no-op.
|
||||
func (s Set) Remove(val interface{}) {
|
||||
func (s Set[T]) Remove(val T) {
|
||||
hv := s.rules.Hash(val)
|
||||
bucket, ok := s.vals[hv]
|
||||
if !ok {
|
||||
@ -35,7 +35,7 @@ func (s Set) Remove(val interface{}) {
|
||||
|
||||
for i, ev := range bucket {
|
||||
if s.rules.Equivalent(val, ev) {
|
||||
newBucket := make([]interface{}, 0, len(bucket)-1)
|
||||
newBucket := make([]T, 0, len(bucket)-1)
|
||||
newBucket = append(newBucket, bucket[:i]...)
|
||||
newBucket = append(newBucket, bucket[i+1:]...)
|
||||
if len(newBucket) > 0 {
|
||||
@ -50,7 +50,7 @@ func (s Set) Remove(val interface{}) {
|
||||
|
||||
// Has returns true if the given value is in the receiving set, or false if
|
||||
// it is not.
|
||||
func (s Set) Has(val interface{}) bool {
|
||||
func (s Set[T]) Has(val T) bool {
|
||||
hv := s.rules.Hash(val)
|
||||
bucket, ok := s.vals[hv]
|
||||
if !ok {
|
||||
@ -67,7 +67,7 @@ func (s Set) Has(val interface{}) bool {
|
||||
|
||||
// Copy performs a shallow copy of the receiving set, returning a new set
|
||||
// with the same rules and elements.
|
||||
func (s Set) Copy() Set {
|
||||
func (s Set[T]) Copy() Set[T] {
|
||||
ret := NewSet(s.rules)
|
||||
for k, v := range s.vals {
|
||||
ret.vals[k] = v
|
||||
@ -92,10 +92,10 @@ func (s Set) Copy() Set {
|
||||
//
|
||||
// Once an iterator has been created for a set, the set *must not* be mutated
|
||||
// until the iterator is no longer in use.
|
||||
func (s Set) Iterator() *Iterator {
|
||||
func (s Set[T]) Iterator() *Iterator[T] {
|
||||
vals := s.Values()
|
||||
|
||||
return &Iterator{
|
||||
return &Iterator[T]{
|
||||
vals: vals,
|
||||
idx: -1,
|
||||
}
|
||||
@ -103,7 +103,7 @@ func (s Set) Iterator() *Iterator {
|
||||
|
||||
// EachValue calls the given callback once for each value in the set, in an
|
||||
// undefined order that callers should not depend on.
|
||||
func (s Set) EachValue(cb func(interface{})) {
|
||||
func (s Set[T]) EachValue(cb func(T)) {
|
||||
it := s.Iterator()
|
||||
for it.Next() {
|
||||
cb(it.Value())
|
||||
@ -114,8 +114,8 @@ func (s Set) EachValue(cb func(interface{})) {
|
||||
// an order then the result is in that order. If no order is provided or if
|
||||
// it is not a total order then the result order is undefined, but consistent
|
||||
// for a particular set value within a specific release of cty.
|
||||
func (s Set) Values() []interface{} {
|
||||
var ret []interface{}
|
||||
func (s Set[T]) Values() []T {
|
||||
var ret []T
|
||||
// Sort the bucketIds to ensure that we always traverse in a
|
||||
// consistent order.
|
||||
bucketIDs := make([]int, 0, len(s.vals))
|
||||
@ -128,7 +128,7 @@ func (s Set) Values() []interface{} {
|
||||
ret = append(ret, s.vals[bucketID]...)
|
||||
}
|
||||
|
||||
if orderRules, ok := s.rules.(OrderedRules); ok {
|
||||
if orderRules, ok := s.rules.(OrderedRules[T]); ok {
|
||||
sort.SliceStable(ret, func(i, j int) bool {
|
||||
return orderRules.Less(ret[i], ret[j])
|
||||
})
|
||||
@ -138,7 +138,7 @@ func (s Set) Values() []interface{} {
|
||||
}
|
||||
|
||||
// Length returns the number of values in the set.
|
||||
func (s Set) Length() int {
|
||||
func (s Set[T]) Length() int {
|
||||
var count int
|
||||
for _, bucket := range s.vals {
|
||||
count = count + len(bucket)
|
||||
@ -149,13 +149,13 @@ func (s Set) Length() int {
|
||||
// Union returns a new set that contains all of the members of both the
|
||||
// receiving set and the given set. Both sets must have the same rules, or
|
||||
// else this function will panic.
|
||||
func (s1 Set) Union(s2 Set) Set {
|
||||
func (s1 Set[T]) Union(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
rs.Add(v)
|
||||
})
|
||||
s2.EachValue(func(v interface{}) {
|
||||
s2.EachValue(func(v T) {
|
||||
rs.Add(v)
|
||||
})
|
||||
return rs
|
||||
@ -164,10 +164,10 @@ func (s1 Set) Union(s2 Set) Set {
|
||||
// Intersection returns a new set that contains the values that both the
|
||||
// receiver and given sets have in common. Both sets must have the same rules,
|
||||
// or else this function will panic.
|
||||
func (s1 Set) Intersection(s2 Set) Set {
|
||||
func (s1 Set[T]) Intersection(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
@ -178,10 +178,10 @@ func (s1 Set) Intersection(s2 Set) Set {
|
||||
// Subtract returns a new set that contains all of the values from the receiver
|
||||
// that are not also in the given set. Both sets must have the same rules,
|
||||
// or else this function will panic.
|
||||
func (s1 Set) Subtract(s2 Set) Set {
|
||||
func (s1 Set[T]) Subtract(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if !s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
@ -193,15 +193,15 @@ func (s1 Set) Subtract(s2 Set) Set {
|
||||
// both the receiver and given sets, except those that both sets have in
|
||||
// common. Both sets must have the same rules, or else this function will
|
||||
// panic.
|
||||
func (s1 Set) SymmetricDifference(s2 Set) Set {
|
||||
func (s1 Set[T]) SymmetricDifference(s2 Set[T]) Set[T] {
|
||||
mustHaveSameRules(s1, s2)
|
||||
rs := NewSet(s1.rules)
|
||||
s1.EachValue(func(v interface{}) {
|
||||
s1.EachValue(func(v T) {
|
||||
if !s2.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
})
|
||||
s2.EachValue(func(v interface{}) {
|
||||
s2.EachValue(func(v T) {
|
||||
if !s1.Has(v) {
|
||||
rs.Add(v)
|
||||
}
|
||||
|
14
vendor/github.com/zclconf/go-cty/cty/set/rules.go
generated
vendored
14
vendor/github.com/zclconf/go-cty/cty/set/rules.go
generated
vendored
@ -4,13 +4,13 @@ package set
|
||||
//
|
||||
// Each Set has a Rules instance, whose methods must satisfy the interface
|
||||
// contracts given below for any value that will be added to the set.
|
||||
type Rules interface {
|
||||
type Rules[T any] interface {
|
||||
// Hash returns an int that somewhat-uniquely identifies the given value.
|
||||
//
|
||||
// A good hash function will minimize collisions for values that will be
|
||||
// added to the set, though collisions *are* permitted. Collisions will
|
||||
// simply reduce the efficiency of operations on the set.
|
||||
Hash(interface{}) int
|
||||
Hash(T) int
|
||||
|
||||
// Equivalent returns true if and only if the two values are considered
|
||||
// equivalent for the sake of set membership. Two values that are
|
||||
@ -21,11 +21,11 @@ type Rules interface {
|
||||
// Two values that are equivalent *must* result in the same hash value,
|
||||
// though it is *not* required that two values with the same hash value
|
||||
// be equivalent.
|
||||
Equivalent(interface{}, interface{}) bool
|
||||
Equivalent(T, T) bool
|
||||
|
||||
// SameRules returns true if the instance is equivalent to another Rules
|
||||
// instance.
|
||||
SameRules(Rules) bool
|
||||
// instance over the same element type.
|
||||
SameRules(Rules[T]) bool
|
||||
}
|
||||
|
||||
// OrderedRules is an extension of Rules that can apply a partial order to
|
||||
@ -37,8 +37,8 @@ type Rules interface {
|
||||
// is undefined but consistent for a particular version of cty. The exact
|
||||
// order in that case is not part of the contract and is subject to change
|
||||
// between versions.
|
||||
type OrderedRules interface {
|
||||
Rules
|
||||
type OrderedRules[T any] interface {
|
||||
Rules[T]
|
||||
|
||||
// Less returns true if and only if the first argument should sort before
|
||||
// the second argument. If the second argument should sort before the first
|
||||
|
22
vendor/github.com/zclconf/go-cty/cty/set/set.go
generated
vendored
22
vendor/github.com/zclconf/go-cty/cty/set/set.go
generated
vendored
@ -19,20 +19,20 @@ import (
|
||||
// Set operations are not optimized to minimize memory pressure. Mutating
|
||||
// a set will generally create garbage and so should perhaps be avoided in
|
||||
// tight loops where memory pressure is a concern.
|
||||
type Set struct {
|
||||
vals map[int][]interface{}
|
||||
rules Rules
|
||||
type Set[T any] struct {
|
||||
vals map[int][]T
|
||||
rules Rules[T]
|
||||
}
|
||||
|
||||
// NewSet returns an empty set with the membership rules given.
|
||||
func NewSet(rules Rules) Set {
|
||||
return Set{
|
||||
vals: map[int][]interface{}{},
|
||||
func NewSet[T any](rules Rules[T]) Set[T] {
|
||||
return Set[T]{
|
||||
vals: map[int][]T{},
|
||||
rules: rules,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSetFromSlice(rules Rules, vals []interface{}) Set {
|
||||
func NewSetFromSlice[T any](rules Rules[T], vals []T) Set[T] {
|
||||
s := NewSet(rules)
|
||||
for _, v := range vals {
|
||||
s.Add(v)
|
||||
@ -40,11 +40,11 @@ func NewSetFromSlice(rules Rules, vals []interface{}) Set {
|
||||
return s
|
||||
}
|
||||
|
||||
func sameRules(s1 Set, s2 Set) bool {
|
||||
func sameRules[T any](s1 Set[T], s2 Set[T]) bool {
|
||||
return s1.rules.SameRules(s2.rules)
|
||||
}
|
||||
|
||||
func mustHaveSameRules(s1 Set, s2 Set) {
|
||||
func mustHaveSameRules[T any](s1 Set[T], s2 Set[T]) {
|
||||
if !sameRules(s1, s2) {
|
||||
panic(fmt.Errorf("incompatible set rules: %#v, %#v", s1.rules, s2.rules))
|
||||
}
|
||||
@ -52,11 +52,11 @@ func mustHaveSameRules(s1 Set, s2 Set) {
|
||||
|
||||
// HasRules returns true if and only if the receiving set has the given rules
|
||||
// instance as its rules.
|
||||
func (s Set) HasRules(rules Rules) bool {
|
||||
func (s Set[T]) HasRules(rules Rules[T]) bool {
|
||||
return s.rules.SameRules(rules)
|
||||
}
|
||||
|
||||
// Rules returns the receiving set's rules instance.
|
||||
func (s Set) Rules() Rules {
|
||||
func (s Set[T]) Rules() Rules[T] {
|
||||
return s.rules
|
||||
}
|
||||
|
Reference in New Issue
Block a user