@@ -46,32 +46,23 @@ func resourceSysdigSecureZone() *schema.Resource {
4646 Type : schema .TypeString ,
4747 Computed : true ,
4848 },
49- SchemaScopesKey : {
50- Required : true ,
49+ SchemaScopeKey : {
5150 Type : schema .TypeSet ,
52- MaxItems : 1 ,
51+ MinItems : 1 ,
52+ Required : true ,
5353 Elem : & schema.Resource {
5454 Schema : map [string ]* schema.Schema {
55- SchemaScopeKey : {
56- Type : schema .TypeSet ,
57- MinItems : 1 ,
55+ SchemaIDKey : {
56+ Type : schema .TypeInt ,
57+ Computed : true ,
58+ },
59+ SchemaTargetTypeKey : {
60+ Type : schema .TypeString ,
5861 Required : true ,
59- Elem : & schema.Resource {
60- Schema : map [string ]* schema.Schema {
61- SchemaIDKey : {
62- Type : schema .TypeInt ,
63- Computed : true ,
64- },
65- SchemaTargetTypeKey : {
66- Type : schema .TypeString ,
67- Required : true ,
68- },
69- SchemaRulesKey : {
70- Type : schema .TypeString ,
71- Optional : true ,
72- },
73- },
74- },
62+ },
63+ SchemaRulesKey : {
64+ Type : schema .TypeString ,
65+ Optional : true ,
7566 },
7667 },
7768 },
@@ -158,7 +149,7 @@ func zoneRequestFromResourceData(d *schema.ResourceData) *v2.ZoneRequest {
158149 zoneRequest := & v2.ZoneRequest {
159150 Name : d .Get ("name" ).(string ),
160151 Description : d .Get ("description" ).(string ),
161- Scopes : toZoneScopesRequest (d .Get ("scopes" ).(* schema.Set )),
152+ Scopes : toZoneScopesRequest (d .Get (SchemaScopeKey ).(* schema.Set )),
162153 }
163154
164155 if d .Id () != "" {
@@ -173,17 +164,13 @@ func zoneRequestFromResourceData(d *schema.ResourceData) *v2.ZoneRequest {
173164
174165func toZoneScopesRequest (scopes * schema.Set ) []v2.ZoneScope {
175166 var zoneScopes []v2.ZoneScope
176- for _ , scopeData := range scopes .List () {
177- scopeMap := scopeData .(map [string ]interface {})
178- scopeSet := scopeMap [SchemaScopeKey ].(* schema.Set )
179- for _ , attr := range scopeSet .List () {
180- s := attr .(map [string ]interface {})
181- zoneScopes = append (zoneScopes , v2.ZoneScope {
182- ID : s [SchemaIDKey ].(int ),
183- TargetType : s [SchemaTargetTypeKey ].(string ),
184- Rules : s [SchemaRulesKey ].(string ),
185- })
186- }
167+ for _ , attr := range scopes .List () {
168+ s := attr .(map [string ]interface {})
169+ zoneScopes = append (zoneScopes , v2.ZoneScope {
170+ ID : s [SchemaIDKey ].(int ),
171+ TargetType : s [SchemaTargetTypeKey ].(string ),
172+ Rules : s [SchemaRulesKey ].(string ),
173+ })
187174 }
188175 return zoneScopes
189176}
@@ -197,28 +184,7 @@ func fromZoneScopesResponse(scopes []v2.ZoneScope) []interface{} {
197184 SchemaRulesKey : scope .Rules ,
198185 })
199186 }
200- response := []interface {}{
201- map [string ]interface {}{
202- SchemaScopeKey : schema .NewSet (schema .HashResource (& schema.Resource {
203- Schema : map [string ]* schema.Schema {
204- SchemaIDKey : {
205- Type : schema .TypeInt ,
206- Computed : true ,
207- },
208- SchemaTargetTypeKey : {
209- Type : schema .TypeString ,
210- Required : true ,
211- },
212- SchemaRulesKey : {
213- Type : schema .TypeString ,
214- Optional : true ,
215- },
216- },
217- }), flattenedScopes ),
218- },
219- }
220-
221- return response
187+ return flattenedScopes
222188}
223189
224190func getZoneClient (clients SysdigClients ) (v2.ZoneInterface , error ) {
0 commit comments