@@ -10,6 +10,7 @@ import (
10
10
"github.com/hashicorp/terraform/plugin/discovery"
11
11
"github.com/hashicorp/terraform/providers"
12
12
"go.starlark.net/starlark"
13
+ "go.starlark.net/syntax"
13
14
)
14
15
15
16
func BuiltinProvider (pm * terraform.PluginManager ) starlark.Value {
@@ -91,10 +92,9 @@ func MakeProvider(pm *terraform.PluginManager, name, version, alias string) (*Pr
91
92
alias : alias ,
92
93
provider : provider ,
93
94
meta : meta ,
94
-
95
- Resource : MakeResource (alias , name , ProviderKind , response .Provider .Block , nil ),
96
95
}
97
96
97
+ p .Resource = MakeResource (alias , name , ProviderKind , response .Provider .Block , p , nil )
98
98
p .dataSources = NewMapSchema (p , name , DataSourceKind , response .DataSources )
99
99
p .resources = NewMapSchema (p , name , ResourceKind , response .ResourceTypes )
100
100
@@ -131,6 +131,19 @@ func (p *Provider) AttrNames() []string {
131
131
return append (p .Resource .AttrNames (), "data" , "resource" , "version" )
132
132
}
133
133
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
+
134
147
type MapSchema struct {
135
148
p * Provider
136
149
@@ -171,7 +184,7 @@ func (m *MapSchema) Attr(name string) (starlark.Value, error) {
171
184
}
172
185
173
186
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 )
175
188
return m .collections [name ], nil
176
189
}
177
190
0 commit comments