// calculateHashValue returns a hash value string for the ApplicationSet spec
calculateHashValue returns a hash value string for the ApplicationSet spec
// calculateHashValue returns a hash value string for the ApplicationSet spec
func (r *ProgressiveSyncReconciler) calculateHashedSpec(ctx context.Context, ps *syncv1alpha1.ProgressiveSync) (string, error) {
	key := client.ObjectKeyFromObject(ps)
	latest := syncv1alpha1.ProgressiveSync{}
	if err := r.Client.Get(ctx, key, &latest); err != nil {
		r.Log.Error(err, "Failed to retrieve the ProgressiveSync object while calculating the hash value")
		return "", err
	}
	appSet := applicationset.ApplicationSet{}
	if err := r.Client.Get(ctx, client.ObjectKey{Namespace: r.ArgoNamespace, Name: latest.Spec.SourceRef.Name}, &appSet); err != nil {
		r.Log.Error(err, "Failed to retrieve the ApplicationSet object")
		return "", err
	}
	appSetSpecInBytes, err := json.Marshal(appSet.Spec)
	if err != nil {
		r.Log.Error(err, "Failed to encode the ApplicanSet spec")
		return "", err
	}
	hashedSpecInBytes := md5.Sum(appSetSpecInBytes)
	hashedSpec := hex.EncodeToString(hashedSpecInBytes[:])
	r.Log.Info("Successfully calculate the hash value of the Spec")
	return hashedSpec, nil
}
func ( r * ProgressiveSyncReconciler ) calculateHashedSpec ( ctx context . Context , ps * syncv1alpha1 . ProgressiveSync ) ( string , error ) { key := client . ObjectKeyFromObject ( ps ) latest := syncv1alpha1 . ProgressiveSync { } if err := r . Client . Get ( ctx , key , & latest ) ; err != nil { r . Log . Error ( err , " " ) return " " , err } appSet := applicationset . ApplicationSet { } if err := r . Client . Get ( ctx , client . ObjectKey { Namespace : r . ArgoNamespace , Name : latest . Spec . SourceRef . Name } , & appSet ) ; err != nil { r . Log . Error ( err , " " ) return " " , err } appSetSpecInBytes , err := json . Marshal ( appSet . Spec ) if err != nil { r . Log . Error ( err , " " ) return " " , err } hashedSpecInBytes := md5 . Sum ( appSetSpecInBytes ) hashedSpec := hex . EncodeToString ( hashedSpecInBytes [ : ] ) r . Log . Info ( " " ) return hashedSpec , nil }
calculateHashValue returns a hash value string for the ApplicationSet spec
calculateHashValue returns a hash value string for the ApplicationSet spec