udpate cty
This commit is contained in:
parent
37a6331ebf
commit
e4fbc49fb8
2
go.mod
2
go.mod
|
@ -115,7 +115,7 @@ require (
|
||||||
github.com/xanzy/ssh-agent v0.2.1
|
github.com/xanzy/ssh-agent v0.2.1
|
||||||
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
|
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
|
||||||
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557
|
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557
|
||||||
github.com/zclconf/go-cty v1.0.0
|
github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f
|
||||||
github.com/zclconf/go-cty-yaml v0.1.0
|
github.com/zclconf/go-cty-yaml v0.1.0
|
||||||
go.uber.org/atomic v1.3.2 // indirect
|
go.uber.org/atomic v1.3.2 // indirect
|
||||||
go.uber.org/multierr v1.1.0 // indirect
|
go.uber.org/multierr v1.1.0 // indirect
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -425,6 +425,8 @@ github.com/zclconf/go-cty v0.0.0-20190516203816-4fecf87372ec h1:MSeYjmyjucsFbecM
|
||||||
github.com/zclconf/go-cty v0.0.0-20190516203816-4fecf87372ec/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
github.com/zclconf/go-cty v0.0.0-20190516203816-4fecf87372ec/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||||
github.com/zclconf/go-cty v1.0.0 h1:EWtv3gKe2wPLIB9hQRQJa7k/059oIfAqcEkCNnaVckk=
|
github.com/zclconf/go-cty v1.0.0 h1:EWtv3gKe2wPLIB9hQRQJa7k/059oIfAqcEkCNnaVckk=
|
||||||
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||||
|
github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f h1:sq2p8SN6ji66CFEQFIWLlD/gFmGtr5hBrOzv5nLlGfA=
|
||||||
|
github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||||
github.com/zclconf/go-cty-yaml v0.1.0 h1:OP5nkApyAuXB88t8mRUqxD9gbKZocSLuVovrBAt8z10=
|
github.com/zclconf/go-cty-yaml v0.1.0 h1:OP5nkApyAuXB88t8mRUqxD9gbKZocSLuVovrBAt8z10=
|
||||||
github.com/zclconf/go-cty-yaml v0.1.0/go.mod h1:Lk26EcRlO3XbaQ8U2fxIJbEtbgEteSZFUpEr3XFTtsU=
|
github.com/zclconf/go-cty-yaml v0.1.0/go.mod h1:Lk26EcRlO3XbaQ8U2fxIJbEtbgEteSZFUpEr3XFTtsU=
|
||||||
go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938=
|
go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938=
|
||||||
|
|
|
@ -71,6 +71,48 @@ func (p Path) GetAttr(name string) Path {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Equals compares 2 Paths for exact equality.
|
||||||
|
func (p Path) Equals(other Path) bool {
|
||||||
|
if len(p) != len(other) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range p {
|
||||||
|
pv := p[i]
|
||||||
|
switch pv := pv.(type) {
|
||||||
|
case GetAttrStep:
|
||||||
|
ov, ok := other[i].(GetAttrStep)
|
||||||
|
if !ok || pv != ov {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
case IndexStep:
|
||||||
|
ov, ok := other[i].(IndexStep)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !pv.Key.RawEquals(ov.Key) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// Any invalid steps default to evaluating false.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasPrefix determines if the path p contains the provided prefix.
|
||||||
|
func (p Path) HasPrefix(prefix Path) bool {
|
||||||
|
if len(prefix) > len(p) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return p[:len(prefix)].Equals(prefix)
|
||||||
|
}
|
||||||
|
|
||||||
// GetAttrPath is a convenience method to start a new Path with a GetAttrStep.
|
// GetAttrPath is a convenience method to start a new Path with a GetAttrStep.
|
||||||
func GetAttrPath(name string) Path {
|
func GetAttrPath(name string) Path {
|
||||||
return Path{}.GetAttr(name)
|
return Path{}.GetAttr(name)
|
||||||
|
|
|
@ -459,7 +459,7 @@ github.com/vmihailenco/msgpack/codes
|
||||||
github.com/xanzy/ssh-agent
|
github.com/xanzy/ssh-agent
|
||||||
# github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557
|
# github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557
|
||||||
github.com/xlab/treeprint
|
github.com/xlab/treeprint
|
||||||
# github.com/zclconf/go-cty v1.0.0
|
# github.com/zclconf/go-cty v1.0.1-0.20190708163926-19588f92a98f
|
||||||
github.com/zclconf/go-cty/cty
|
github.com/zclconf/go-cty/cty
|
||||||
github.com/zclconf/go-cty/cty/gocty
|
github.com/zclconf/go-cty/cty/gocty
|
||||||
github.com/zclconf/go-cty/cty/convert
|
github.com/zclconf/go-cty/cty/convert
|
||||||
|
|
Loading…
Reference in New Issue