Skip to content

Commit

Permalink
Update diff
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Sep 14, 2024
1 parent 06ed371 commit 72ba863
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
annotations:
compute.functionmesh.io/pause-rollout: "false"
name: function-download-sample
namespace: default
spec:
Expand Down
2 changes: 2 additions & 0 deletions .ci/tests/integration/cases/java-function-vpa/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
annotations:
compute.functionmesh.io/pause-rollout: "true"
name: function-sample-vpa
namespace: default
spec:
Expand Down
2 changes: 2 additions & 0 deletions .ci/tests/integration/cases/java-function/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
annotations:
compute.functionmesh.io/pause-rollout: "true"
name: function-sample
namespace: default
spec:
Expand Down
2 changes: 2 additions & 0 deletions .ci/tests/integration/cases/java-log-config/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
annotations:
compute.functionmesh.io/pause-rollout: "true"
name: java-log-config
namespace: default
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
annotations:
compute.functionmesh.io/pause-rollout: "false"
name: java-log-format-json
namespace: default
spec:
Expand Down
11 changes: 6 additions & 5 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/strategicpatch"
Expand Down Expand Up @@ -2377,9 +2376,11 @@ func makeFilebeatContainer(volumeMounts []corev1.VolumeMount, envVar []corev1.En
}
}

func CreateDiff(orj, modified runtime.Object) (string, error) {
orjCopy := orj.DeepCopyObject()
modifiedCopy := modified.DeepCopyObject()
func CreateDiff(orj, modified *appsv1.StatefulSet) (string, error) {
orjCopy := orj.DeepCopyObject().(*appsv1.StatefulSet)
modifiedCopy := modified.DeepCopyObject().(*appsv1.StatefulSet)
modifiedCopy.Status = orjCopy.Status
modifiedCopy.ObjectMeta = orjCopy.ObjectMeta

orjData, err := json.Marshal(orjCopy)
if err != nil {
Expand All @@ -2389,7 +2390,7 @@ func CreateDiff(orj, modified runtime.Object) (string, error) {
if err != nil {
return "", fmt.Errorf("marshal modified %w", err)
}
patch, err := strategicpatch.CreateTwoWayMergePatch(orjData, modifiedData, orj)
patch, err := strategicpatch.CreateTwoWayMergePatch(orjData, modifiedData, orjCopy)
if err != nil {
return "", fmt.Errorf("create diff %w", err)
}
Expand Down

0 comments on commit 72ba863

Please sign in to comment.