@@ -82,12 +82,8 @@ type AppCollaboratorConfig struct {
8282}
8383
8484func  resourceAppCollaboratorRead (d  * schema.ResourceData , meta  interface {}) error  {
85- 	acc  :=  & AppCollaboratorConfig {
86- 		owner :    d .Get ("owner" ).(string ),
87- 		platform : d .Get ("platform" ).(string ),
88- 		appID :    d .Get ("app_id" ).(string ),
89- 		users :    d .Get ("users" ).(string ),
90- 	}
85+ 
86+ 	acc  :=  setAppCollaboratorConfig (d )
9187
9288	log .Printf ("[DEBUG] resourceAppCollaboratorRead: %s" , acc )
9389
@@ -105,12 +101,7 @@ func resourceAppCollaboratorRead(d *schema.ResourceData, meta interface{}) error
105101}
106102
107103func  resourceAppCollaboratorCreate (d  * schema.ResourceData , meta  interface {}) error  {
108- 	acc  :=  & AppCollaboratorConfig {
109- 		owner :    d .Get ("owner" ).(string ),
110- 		platform : d .Get ("platform" ).(string ),
111- 		appID :    d .Get ("app_id" ).(string ),
112- 		users :    d .Get ("users" ).(string ),
113- 	}
104+ 	acc  :=  setAppCollaboratorConfig (d )
114105
115106	log .Printf ("[DEBUG] resourceAppCollaboratorCreate: %s" , acc )
116107
@@ -127,12 +118,7 @@ func resourceAppCollaboratorCreate(d *schema.ResourceData, meta interface{}) err
127118}
128119
129120func  resourceAppCollaboratorUpdate (d  * schema.ResourceData , meta  interface {}) error  {
130- 	acc  :=  & AppCollaboratorConfig {
131- 		owner :    d .Get ("owner" ).(string ),
132- 		platform : d .Get ("platform" ).(string ),
133- 		appID :    d .Get ("app_id" ).(string ),
134- 		users :    d .Get ("users" ).(string ),
135- 	}
121+ 	acc  :=  setAppCollaboratorConfig (d )
136122
137123	log .Printf ("[DEBUG] resourceAppCollaboratorUpdate: %s" , acc )
138124
@@ -146,12 +132,7 @@ func resourceAppCollaboratorUpdate(d *schema.ResourceData, meta interface{}) err
146132}
147133
148134func  resourceAppCollaboratorDelete (d  * schema.ResourceData , meta  interface {}) error  {
149- 	acc  :=  & AppCollaboratorConfig {
150- 		owner :    d .Get ("owner" ).(string ),
151- 		platform : d .Get ("platform" ).(string ),
152- 		appID :    d .Get ("app_id" ).(string ),
153- 		users :    d .Get ("users" ).(string ),
154- 	}
135+ 	acc  :=  setAppCollaboratorConfig (d )
155136
156137	log .Printf ("[DEBUG] resourceAppCollaboratorDelete: %s" , acc )
157138
@@ -185,6 +166,7 @@ func (clt *Client) addAppCollaborator(cfg *AppCollaboratorConfig) (*go_deploygat
185166		Platform : cfg .platform ,
186167		AppId :    cfg .appID ,
187168		Users :    cfg .users ,
169+ 		Role :     1 ,
188170	}
189171
190172	collaborator , err  :=  clt .client .AddAppCollaborator (g )
@@ -211,3 +193,23 @@ func (clt *Client) deleteAppCollaborator(cfg *AppCollaboratorConfig) (*go_deploy
211193
212194	return  collaborator , nil 
213195}
196+ 
197+ func  setAppCollaboratorConfig (d  * schema.ResourceData ) * AppCollaboratorConfig  {
198+ 	var  usersList  string 
199+ 
200+ 	if  v , ok  :=  d .GetOk ("users" ); ok  {
201+ 		for  _ , element  :=  range  v .(* schema.Set ).List () {
202+ 			elem  :=  element .(map [string ]interface {})
203+ 			usersList  +=  elem ["name" ].(string ) +  "," 
204+ 		}
205+ 	}
206+ 
207+ 	acc  :=  & AppCollaboratorConfig {
208+ 		owner :    d .Get ("owner" ).(string ),
209+ 		platform : d .Get ("platform" ).(string ),
210+ 		appID :    d .Get ("app_id" ).(string ),
211+ 		users :    usersList ,
212+ 	}
213+ 
214+ 	return  acc 
215+ }
0 commit comments