@@ -97,7 +97,7 @@ func GetChangesForApply(smgr statemanager.Manager, cfg *configmanager.Config) (c
9797 // 3. generate changes for each tool
9898 for _ , batch := range batchesOfTools {
9999 for _ , tool := range batch {
100- state := smgr .GetState (statemanager .StateKeyGenerateFunc ( & tool ))
100+ state := smgr .GetState (statemanager .GenerateStateKeyByToolNameAndInstanceID ( tool . Name , tool . InstanceID ))
101101
102102 if state == nil {
103103 // tool not in the state, create, no need to Read resource before Create
@@ -142,7 +142,7 @@ func GetChangesForApply(smgr statemanager.Manager, cfg *configmanager.Config) (c
142142 }
143143
144144 // delete the tool from the temporary state map since it's already been processed above
145- tmpStatesMap .Delete (statemanager .StateKeyGenerateFunc ( & tool ))
145+ tmpStatesMap .Delete (statemanager .GenerateStateKeyByToolNameAndInstanceID ( tool . Name , tool . InstanceID ))
146146 }
147147 }
148148
@@ -177,7 +177,7 @@ func GetChangesForDelete(smgr statemanager.Manager, cfg *configmanager.Config, i
177177 batch := batchesOfTools [i ]
178178 for _ , tool := range batch {
179179 if ! isForceDelete {
180- state := smgr .GetState (statemanager .StateKeyGenerateFunc ( & tool ))
180+ state := smgr .GetState (statemanager .GenerateStateKeyByToolNameAndInstanceID ( tool . Name , tool . InstanceID ))
181181 if state == nil {
182182 continue
183183 }
@@ -220,7 +220,7 @@ func GetChangesForDestroy(smgr statemanager.Manager, isForceDestroy bool) (chang
220220 batch := batchesOfTools [i ]
221221 for _ , tool := range batch {
222222 if ! isForceDestroy {
223- state := smgr .GetState (statemanager .StateKeyGenerateFunc ( & tool ))
223+ state := smgr .GetState (statemanager .GenerateStateKeyByToolNameAndInstanceID ( tool . Name , tool . InstanceID ))
224224 if state == nil {
225225 continue
226226 }
@@ -264,7 +264,7 @@ func topologicalSortChangesInBatch(changes []*Change) ([][]*Change, error) {
264264 // for each tool in the batch, find the change that matches it
265265 for _ , tool := range batch {
266266 // only add the change that has the tool match with it
267- if change , ok := changesKeyMap [tool .Key ()]; ok {
267+ if change , ok := changesKeyMap [tool .KeyWithNameAndInstanceID ()]; ok {
268268 changesOneBatch = append (changesOneBatch , change )
269269 }
270270 }
@@ -285,9 +285,9 @@ func getToolsFromChanges(changes []*Change) []configmanager.Tool {
285285
286286 // get tools from changes avoiding duplicated tools
287287 for _ , change := range changes {
288- if _ , ok := toolsKeyMap [change .Tool .Key ()]; ! ok {
288+ if _ , ok := toolsKeyMap [change .Tool .KeyWithNameAndInstanceID ()]; ! ok {
289289 tools = append (tools , * change .Tool )
290- toolsKeyMap [change .Tool .Key ()] = struct {}{}
290+ toolsKeyMap [change .Tool .KeyWithNameAndInstanceID ()] = struct {}{}
291291 }
292292 }
293293
@@ -297,7 +297,7 @@ func getToolsFromChanges(changes []*Change) []configmanager.Tool {
297297func getChangesKeyMap (changes []* Change ) map [string ]* Change {
298298 changesKeyMap := make (map [string ]* Change )
299299 for _ , change := range changes {
300- changesKeyMap [change .Tool .Key ()] = change
300+ changesKeyMap [change .Tool .KeyWithNameAndInstanceID ()] = change
301301 }
302302 return changesKeyMap
303303}
0 commit comments