mirror of
https://github.com/lukaszraczylo/kubemirror.git
synced 2026-06-10 23:09:14 +00:00
Fix transformer handling logic and improve content hashing
This commit is contained in:
+28
-2
@@ -51,19 +51,37 @@ func extractContent(obj runtime.Object) (interface{}, error) {
|
||||
|
||||
// extractSecretContent extracts content from a Secret.
|
||||
func extractSecretContent(secret *corev1.Secret) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
content := map[string]interface{}{
|
||||
"type": string(secret.Type),
|
||||
"data": secret.Data,
|
||||
"stringData": secret.StringData,
|
||||
}
|
||||
|
||||
// Include transform annotation in hash so changes to transformation rules trigger updates
|
||||
if secret.Annotations != nil {
|
||||
if transform, exists := secret.Annotations[constants.AnnotationTransform]; exists {
|
||||
content["transform"] = transform
|
||||
}
|
||||
}
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
// extractConfigMapContent extracts content from a ConfigMap.
|
||||
func extractConfigMapContent(cm *corev1.ConfigMap) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
content := map[string]interface{}{
|
||||
"data": cm.Data,
|
||||
"binaryData": cm.BinaryData,
|
||||
}
|
||||
|
||||
// Include transform annotation in hash so changes to transformation rules trigger updates
|
||||
if cm.Annotations != nil {
|
||||
if transform, exists := cm.Annotations[constants.AnnotationTransform]; exists {
|
||||
content["transform"] = transform
|
||||
}
|
||||
}
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
// extractUnstructuredContent extracts content from an unstructured resource (CRDs, etc.).
|
||||
@@ -100,6 +118,14 @@ func extractUnstructuredContent(obj runtime.Object) (interface{}, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Include transform annotation in hash so changes to transformation rules trigger updates
|
||||
annotations := uCopy.GetAnnotations()
|
||||
if annotations != nil {
|
||||
if transform, exists := annotations[constants.AnnotationTransform]; exists {
|
||||
content["transform"] = transform
|
||||
}
|
||||
}
|
||||
|
||||
return content, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user