@@ -10,6 +10,7 @@ import (
1010 "github.com/hashicorp/terraform/plugin/discovery"
1111 "github.com/hashicorp/terraform/providers"
1212 "go.starlark.net/starlark"
13+ "go.starlark.net/syntax"
1314)
1415
1516func BuiltinProvider (pm * terraform.PluginManager ) starlark.Value {
@@ -91,10 +92,9 @@ func MakeProvider(pm *terraform.PluginManager, name, version, alias string) (*Pr
9192 alias : alias ,
9293 provider : provider ,
9394 meta : meta ,
94-
95- Resource : MakeResource (alias , name , ProviderKind , response .Provider .Block , nil ),
9695 }
9796
97+ p .Resource = MakeResource (alias , name , ProviderKind , response .Provider .Block , p , nil )
9898 p .dataSources = NewMapSchema (p , name , DataSourceKind , response .DataSources )
9999 p .resources = NewMapSchema (p , name , ResourceKind , response .ResourceTypes )
100100
@@ -131,6 +131,19 @@ func (p *Provider) AttrNames() []string {
131131 return append (p .Resource .AttrNames (), "data" , "resource" , "version" )
132132}
133133
134+ // CompareSameType honors starlark.Comprable interface.
135+ func (x * Provider ) CompareSameType (op syntax.Token , y_ starlark.Value , depth int ) (bool , error ) {
136+ y := y_ .(* Provider )
137+ switch op {
138+ case syntax .EQL :
139+ return x == y , nil
140+ case syntax .NEQ :
141+ return x != y , nil
142+ default :
143+ return false , fmt .Errorf ("%s %s %s not implemented" , x .Type (), op , y .Type ())
144+ }
145+ }
146+
134147type MapSchema struct {
135148 p * Provider
136149
@@ -171,7 +184,7 @@ func (m *MapSchema) Attr(name string) (starlark.Value, error) {
171184 }
172185
173186 if schema , ok := m .schemas [name ]; ok {
174- m .collections [name ] = NewResourceCollection (name , m .kind , schema .Block , m .p .Resource )
187+ m .collections [name ] = NewResourceCollection (name , m .kind , schema .Block , m .p , m . p .Resource )
175188 return m .collections [name ], nil
176189 }
177190
0 commit comments