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>main
parent
683a051502
commit
282cd097f9
@ -1,48 +0,0 @@
|
|||||||
// Copyright 2017, The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package value
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsZero reports whether v is the zero value.
|
|
||||||
// This does not rely on Interface and so can be used on unexported fields.
|
|
||||||
func IsZero(v reflect.Value) bool {
|
|
||||||
switch v.Kind() {
|
|
||||||
case reflect.Bool:
|
|
||||||
return v.Bool() == false
|
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
||||||
return v.Int() == 0
|
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
|
||||||
return v.Uint() == 0
|
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
return math.Float64bits(v.Float()) == 0
|
|
||||||
case reflect.Complex64, reflect.Complex128:
|
|
||||||
return math.Float64bits(real(v.Complex())) == 0 && math.Float64bits(imag(v.Complex())) == 0
|
|
||||||
case reflect.String:
|
|
||||||
return v.String() == ""
|
|
||||||
case reflect.UnsafePointer:
|
|
||||||
return v.Pointer() == 0
|
|
||||||
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
|
|
||||||
return v.IsNil()
|
|
||||||
case reflect.Array:
|
|
||||||
for i := 0; i < v.Len(); i++ {
|
|
||||||
if !IsZero(v.Index(i)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
case reflect.Struct:
|
|
||||||
for i := 0; i < v.NumField(); i++ {
|
|
||||||
if !IsZero(v.Field(i)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
## v1.4.6
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
* server: Prevent gRPC broker goroutine leak when using `GRPCServer` type `GracefulStop()` or `Stop()` methods [[GH-220](https://github.com/hashicorp/go-plugin/pull/220)]
|
||||||
|
|
||||||
|
## v1.4.5
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
|
||||||
|
* client: log warning when SecureConfig is nil [[GH-207](https://github.com/hashicorp/go-plugin/pull/207)]
|
||||||
|
|
||||||
|
|
||||||
|
## v1.4.4
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
|
||||||
|
* client: increase level of plugin exit logs [[GH-195](https://github.com/hashicorp/go-plugin/pull/195)]
|
||||||
|
|
||||||
|
BUG FIXES:
|
||||||
|
|
||||||
|
* Bidirectional communication: fix bidirectional communication when AutoMTLS is enabled [[GH-193](https://github.com/hashicorp/go-plugin/pull/193)]
|
||||||
|
* RPC: Trim a spurious log message for plugins using RPC [[GH-186](https://github.com/hashicorp/go-plugin/pull/186)]
|
||||||
|
|
||||||
|
|
54
vendor/github.com/hashicorp/terraform-plugin-go/internal/logging/protocol_data.go
generated
vendored
54
vendor/github.com/hashicorp/terraform-plugin-go/internal/logging/protocol_data.go
generated
vendored
32
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing.go
generated
vendored
32
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing.go
generated
vendored
17
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing_config.go
generated
vendored
17
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing_config.go
generated
vendored
75
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing_new.go
generated
vendored
75
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing_new.go
generated
vendored
@ -0,0 +1,97 @@
|
|||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
tfjson "github.com/hashicorp/terraform-json"
|
||||||
|
"github.com/mitchellh/go-testing-interface"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/logging"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||||
|
)
|
||||||
|
|
||||||
|
func testStepNewRefreshState(ctx context.Context, t testing.T, wd *plugintest.WorkingDir, step TestStep, providers *providerFactories) error {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
spewConf := spew.NewDefaultConfig()
|
||||||
|
spewConf.SortKeys = true
|
||||||
|
|
||||||
|
var err error
|
||||||
|
// Explicitly ensure prior state exists before refresh.
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
_, err = getState(ctx, t, wd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error getting state: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
return wd.Refresh(ctx)
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var refreshState *terraform.State
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
refreshState, err = getState(ctx, t, wd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error getting state: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go through the refreshed state and verify
|
||||||
|
if step.Check != nil {
|
||||||
|
logging.HelperResourceDebug(ctx, "Calling TestStep Check for RefreshState")
|
||||||
|
|
||||||
|
if err := step.Check(refreshState); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.HelperResourceDebug(ctx, "Called TestStep Check for RefreshState")
|
||||||
|
}
|
||||||
|
|
||||||
|
// do a plan
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
return wd.CreatePlan(ctx)
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error running post-apply plan: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var plan *tfjson.Plan
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
var err error
|
||||||
|
plan, err = wd.SavedPlan(ctx)
|
||||||
|
return err
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error retrieving post-apply plan: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !planIsEmpty(plan) && !step.ExpectNonEmptyPlan {
|
||||||
|
var stdout string
|
||||||
|
err = runProviderCommand(ctx, t, func() error {
|
||||||
|
var err error
|
||||||
|
stdout, err = wd.SavedPlanRawStdout(ctx)
|
||||||
|
return err
|
||||||
|
}, wd, providers)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error retrieving formatted plan output: %w", err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("After refreshing state during this test step, a followup plan was not empty.\nstdout:\n\n%s", stdout)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
34
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/teststep_validate.go
generated
vendored
34
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/teststep_validate.go
generated
vendored
3
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/config.go
generated
vendored
3
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/config.go
generated
vendored
5
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/helper.go
generated
vendored
5
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/helper.go
generated
vendored
69
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/util.go
generated
vendored
69
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/util.go
generated
vendored
79
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/working_dir.go
generated
vendored
79
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest/working_dir.go
generated
vendored
@ -1,204 +0,0 @@
|
|||||||
package cty
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/gob"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/zclconf/go-cty/cty/set"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GobEncode is an implementation of the gob.GobEncoder interface, which
|
|
||||||
// allows Values to be included in structures encoded with encoding/gob.
|
|
||||||
//
|
|
||||||
// Currently it is not possible to represent values of capsule types in gob,
|
|
||||||
// because the types themselves cannot be represented.
|
|
||||||
func (val Value) GobEncode() ([]byte, error) {
|
|
||||||
if val.IsMarked() {
|
|
||||||
return nil, errors.New("value is marked")
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
|
||||||
enc := gob.NewEncoder(buf)
|
|
||||||
|
|
||||||
gv := gobValue{
|
|
||||||
Version: 0,
|
|
||||||
Ty: val.ty,
|
|
||||||
V: val.v,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := enc.Encode(gv)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error encoding cty.Value: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GobDecode is an implementation of the gob.GobDecoder interface, which
|
|
||||||
// inverts the operation performed by GobEncode. See the documentation of
|
|
||||||
// GobEncode for considerations when using cty.Value instances with gob.
|
|
||||||
func (val *Value) GobDecode(buf []byte) error {
|
|
||||||
r := bytes.NewReader(buf)
|
|
||||||
dec := gob.NewDecoder(r)
|
|
||||||
|
|
||||||
var gv gobValue
|
|
||||||
err := dec.Decode(&gv)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error decoding cty.Value: %s", err)
|
|
||||||
}
|
|
||||||
if gv.Version != 0 {
|
|
||||||
return fmt.Errorf("unsupported cty.Value encoding version %d; only 0 is supported", gv.Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Because big.Float.GobEncode is implemented with a pointer reciever,
|
|
||||||
// gob encoding of an interface{} containing a *big.Float value does not
|
|
||||||
// round-trip correctly, emerging instead as a non-pointer big.Float.
|
|
||||||
// The rest of cty expects all number values to be represented by
|
|
||||||
// *big.Float, so we'll fix that up here.
|
|
||||||
gv.V = gobDecodeFixNumberPtr(gv.V, gv.Ty)
|
|
||||||
|
|
||||||
val.ty = gv.Ty
|
|
||||||
val.v = gv.V
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GobEncode is an implementation of the gob.GobEncoder interface, which
|
|
||||||
// allows Types to be included in structures encoded with encoding/gob.
|
|
||||||
//
|
|
||||||
// Currently it is not possible to represent capsule types in gob.
|
|
||||||
func (t Type) GobEncode() ([]byte, error) {
|
|
||||||
buf := &bytes.Buffer{}
|
|
||||||
enc := gob.NewEncoder(buf)
|
|
||||||
|
|
||||||
gt := gobType{
|
|
||||||
Version: 0,
|
|
||||||
Impl: t.typeImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := enc.Encode(gt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error encoding cty.Type: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GobDecode is an implementatino of the gob.GobDecoder interface, which
|
|
||||||
// reverses the encoding performed by GobEncode to allow types to be recovered
|
|
||||||
// from gob buffers.
|
|
||||||
func (t *Type) GobDecode(buf []byte) error {
|
|
||||||
r := bytes.NewReader(buf)
|
|
||||||
dec := gob.NewDecoder(r)
|
|
||||||
|
|
||||||
var gt gobType
|
|
||||||
err := dec.Decode(>)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error decoding cty.Type: %s", err)
|
|
||||||
}
|
|
||||||
if gt.Version != 0 {
|
|
||||||
return fmt.Errorf("unsupported cty.Type encoding version %d; only 0 is supported", gt.Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.typeImpl = gt.Impl
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Capsule types cannot currently be gob-encoded, because they rely on pointer
|
|
||||||
// equality and we have no way to recover the original pointer on decode.
|
|
||||||
func (t *capsuleType) GobEncode() ([]byte, error) {
|
|
||||||
return nil, fmt.Errorf("cannot gob-encode capsule type %q", t.FriendlyName(friendlyTypeName))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *capsuleType) GobDecode() ([]byte, error) {
|
|
||||||
return nil, fmt.Errorf("cannot gob-decode capsule type %q", t.FriendlyName(friendlyTypeName))
|
|
||||||
}
|
|
||||||
|
|
||||||
type gobValue struct {
|
|
||||||
Version int
|
|
||||||
Ty Type
|
|
||||||
V interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type gobType struct {
|
|
||||||
Version int
|
|
||||||
Impl typeImpl
|
|
||||||
}
|
|
||||||
|
|
||||||
type gobCapsuleTypeImpl struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
// goDecodeFixNumberPtr fixes an unfortunate quirk of round-tripping cty.Number
|
|
||||||
// values through gob: the big.Float.GobEncode method is implemented on a
|
|
||||||
// pointer receiver, and so it loses the "pointer-ness" of the value on
|
|
||||||
// encode, causing the values to emerge the other end as big.Float rather than
|
|
||||||
// *big.Float as we expect elsewhere in cty.
|
|
||||||
//
|
|
||||||
// The implementation of gobDecodeFixNumberPtr mutates the given raw value
|
|
||||||
// during its work, and may either return the same value mutated or a new
|
|
||||||
// value. Callers must no longer use whatever value they pass as "raw" after
|
|
||||||
// this function is called.
|
|
||||||
func gobDecodeFixNumberPtr(raw interface{}, ty Type) interface{} {
|
|
||||||
// Unfortunately we need to work recursively here because number values
|
|
||||||
// might be embedded in structural or collection type values.
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case ty.Equals(Number):
|
|
||||||
if bf, ok := raw.(big.Float); ok {
|
|
||||||
return &bf // wrap in pointer
|
|
||||||
}
|
|
||||||
case ty.IsMapType() && ty.ElementType().Equals(Number):
|
|
||||||
if m, ok := raw.(map[string]interface{}); ok {
|
|
||||||
for k, v := range m {
|
|
||||||
m[k] = gobDecodeFixNumberPtr(v, ty.ElementType())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case ty.IsListType() && ty.ElementType().Equals(Number):
|
|
||||||
if s, ok := raw.([]interface{}); ok {
|
|
||||||
for i, v := range s {
|
|
||||||
s[i] = gobDecodeFixNumberPtr(v, ty.ElementType())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case ty.IsSetType() && ty.ElementType().Equals(Number):
|
|
||||||
if s, ok := raw.(set.Set); ok {
|
|
||||||
newS := set.NewSet(s.Rules())
|
|
||||||
for it := s.Iterator(); it.Next(); {
|
|
||||||
newV := gobDecodeFixNumberPtr(it.Value(), ty.ElementType())
|
|
||||||
newS.Add(newV)
|
|
||||||
}
|
|
||||||
return newS
|
|
||||||
}
|
|
||||||
case ty.IsObjectType():
|
|
||||||
if m, ok := raw.(map[string]interface{}); ok {
|
|
||||||
for k, v := range m {
|
|
||||||
aty := ty.AttributeType(k)
|
|
||||||
m[k] = gobDecodeFixNumberPtr(v, aty)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case ty.IsTupleType():
|
|
||||||
if s, ok := raw.([]interface{}); ok {
|
|
||||||
for i, v := range s {
|
|
||||||
ety := ty.TupleElementType(i)
|
|
||||||
s[i] = gobDecodeFixNumberPtr(v, ety)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return raw
|
|
||||||
}
|
|
||||||
|
|
||||||
// gobDecodeFixNumberPtrVal is a helper wrapper around gobDecodeFixNumberPtr
|
|
||||||
// that works with already-constructed values. This is primarily for testing,
|
|
||||||
// to fix up intentionally-invalid number values for the parts of the test
|
|
||||||
// code that need them to be valid, such as calling GoString on them.
|
|
||||||
func gobDecodeFixNumberPtrVal(v Value) Value {
|
|
||||||
raw := gobDecodeFixNumberPtr(v.v, v.ty)
|
|
||||||
return Value{
|
|
||||||
v: raw,
|
|
||||||
ty: v.ty,
|
|
||||||
}
|
|
||||||
}
|
|
@ -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))
|
|
||||||
}
|
|
@ -1,15 +1,15 @@
|
|||||||
package set
|
package set
|
||||||
|
|
||||||
type Iterator struct {
|
type Iterator[T any] struct {
|
||||||
vals []interface{}
|
vals []T
|
||||||
idx int
|
idx int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *Iterator) Value() interface{} {
|
func (it *Iterator[T]) Value() T {
|
||||||
return it.vals[it.idx]
|
return it.vals[it.idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *Iterator) Next() bool {
|
func (it *Iterator[T]) Next() bool {
|
||||||
it.idx++
|
it.idx++
|
||||||
return it.idx < len(it.vals)
|
return it.idx < len(it.vals)
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue