@@ -155,10 +155,12 @@ func setPackManifests(pack *models.V1PackValuesEntity, p map[string]interface{},
155155func updateProfiles (c * client.V1Client , d * schema.ResourceData ) error {
156156 log .Printf ("Updating profiles" )
157157 profiles , err := toAddonDeplProfiles (c , d )
158+ var variableEntity []* models.V1SpectroClusterVariableUpdateEntity
158159 if err != nil {
159160 oldProfile , _ := d .GetChange ("cluster_profile" )
160161 // When profile modification failed we are setting back the un applied version back to tf state
161162 _ = d .Set ("cluster_profile" , oldProfile )
163+
162164 return err
163165 }
164166 settings , err := toSpcApplySettings (d )
@@ -183,6 +185,32 @@ func updateProfiles(c *client.V1Client, d *schema.ResourceData) error {
183185 return err
184186 }
185187
188+ // Profile Variable Handling
189+ pVars := make ([]* models.V1SpectroClusterVariable , 0 )
190+ _ , newProfiles := d .GetChange ("cluster_profile" )
191+ for _ , newProfile := range newProfiles .([]interface {}) {
192+ p := newProfile .(map [string ]interface {})
193+ if pv , ok := p ["variables" ]; ok && pv != nil {
194+ variables := p ["variables" ].(map [string ]interface {})
195+ for key , value := range variables {
196+ pVars = append (pVars , & models.V1SpectroClusterVariable {
197+ Name : ptr .StringPtr (key ),
198+ Value : value .(string ),
199+ })
200+ }
201+ }
202+ variableEntity = append (variableEntity , & models.V1SpectroClusterVariableUpdateEntity {
203+ ProfileUID : ptr .StringPtr (p ["id" ].(string )),
204+ Variables : pVars ,
205+ })
206+
207+ }
208+ // Patching cluster profiles Variables
209+ err = c .UpdateClusterProfileVariableInCluster (d .Id (), variableEntity )
210+ if err != nil {
211+ return err
212+ }
213+
186214 return nil
187215}
188216
0 commit comments