mirror of https://github.com/fluxcd/cli-utils.git
				
				
				
			fix: Always apply status when merging or replacing
The refactor to include `Apply` and `ApplyWithPrune` interface methods in `Storage` caused a regression where status is not alway applied. This commit ensures that the status is always applied.
This commit is contained in:
		
							parent
							
								
									c29e1ab60c
								
							
						
					
					
						commit
						24aa255005
					
				| 
						 | 
				
			
			@ -144,6 +144,13 @@ func (cic *ClusterClient) Merge(localInv Info, objs object.ObjMetadataSet, dryRu
 | 
			
		|||
		return pruneIds, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Update not required when all objects in inventory are the same and
 | 
			
		||||
	// status does not need to be updated. If status is stored, always update the
 | 
			
		||||
	// inventory to store the latest status.
 | 
			
		||||
	if objs.Equal(clusterObjs) && cic.statusPolicy == StatusPolicyNone {
 | 
			
		||||
		return pruneIds, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if dryRun.ClientOrServerDryRun() {
 | 
			
		||||
		klog.V(4).Infof("dry-run create inventory object: not created")
 | 
			
		||||
		return pruneIds, nil
 | 
			
		||||
| 
						 | 
				
			
			@ -176,13 +183,18 @@ func (cic *ClusterClient) Replace(localInv Info, objs object.ObjMetadataSet, sta
 | 
			
		|||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !objs.Equal(clusterObjs) {
 | 
			
		||||
		klog.V(4).Infof("replace cluster inventory: %s/%s", clusterInv.GetNamespace(), clusterInv.GetName())
 | 
			
		||||
		klog.V(4).Infof("replace cluster inventory %d objects", len(objs))
 | 
			
		||||
	// Update not required when all objects in inventory are the same and
 | 
			
		||||
	// status does not need to be updated. If status is stored, always update the
 | 
			
		||||
	// inventory to store the latest status.
 | 
			
		||||
	if objs.Equal(clusterObjs) && cic.statusPolicy == StatusPolicyNone {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		if err := wrappedInv.ApplyWithPrune(cic.dc, cic.mapper, cic.statusPolicy, objs); err != nil {
 | 
			
		||||
			return fmt.Errorf("failed to write updated inventory to cluster: %w", err)
 | 
			
		||||
		}
 | 
			
		||||
	klog.V(4).Infof("replace cluster inventory: %s/%s", clusterInv.GetNamespace(), clusterInv.GetName())
 | 
			
		||||
	klog.V(4).Infof("replace cluster inventory %d objects", len(objs))
 | 
			
		||||
 | 
			
		||||
	if err := wrappedInv.ApplyWithPrune(cic.dc, cic.mapper, cic.statusPolicy, objs); err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to write updated inventory to cluster: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue