diff --git a/internal/dashboard/__snapshots__/workspace_handler_test.snap b/internal/dashboard/__snapshots__/workspace_handler_test.snap index cb66e94f..1bdc7b9a 100644 --- a/internal/dashboard/__snapshots__/workspace_handler_test.snap +++ b/internal/dashboard/__snapshots__/workspace_handler_test.snap @@ -584,7 +584,10 @@ SnapShot = """ \"metadata\": { \"name\": \"ws1\", \"namespace\": \"cosmo-user-admin-user\", - \"creationTimestamp\": null + \"creationTimestamp\": null, + \"annotations\": { + \"workspace.cosmo-workspace.github.io/last-stopped-at\": \"MASKED\" + } }, \"spec\": { \"template\": { @@ -643,7 +646,10 @@ SnapShot = """ \"metadata\": { \"name\": \"ws1\", \"namespace\": \"cosmo-user-normal-user\", - \"creationTimestamp\": null + \"creationTimestamp\": null, + \"annotations\": { + \"workspace.cosmo-workspace.github.io/last-started-at\": \"MASKED\" + } }, \"spec\": { \"template\": { diff --git a/pkg/snap/object_snapshot.go b/pkg/snap/object_snapshot.go index 3f448ab3..c1ffce55 100644 --- a/pkg/snap/object_snapshot.go +++ b/pkg/snap/object_snapshot.go @@ -26,10 +26,12 @@ func UserSnapshot(in *cosmov1alpha1.User) *cosmov1alpha1.User { obj.Status.Addons[i] = v } sort.Slice(obj.Status.Addons, func(i, j int) bool { - return obj.Status.Addons[i].Kind < obj.Status.Addons[j].Kind - }) - sort.Slice(obj.Status.Addons, func(i, j int) bool { - return obj.Status.Addons[i].Name < obj.Status.Addons[j].Name + x, y := obj.Status.Addons[i], obj.Status.Addons[j] + if x.Kind != y.Kind { + return x.Kind < y.Kind + } else { + return x.Name < y.Name + } }) return obj @@ -47,10 +49,12 @@ func InstanceSnapshot(in cosmov1alpha1.InstanceObject) cosmov1alpha1.InstanceObj obj.GetStatus().LastApplied[i] = v } sort.Slice(obj.GetStatus().LastApplied, func(i, j int) bool { - return obj.GetStatus().LastApplied[i].Kind < obj.GetStatus().LastApplied[j].Kind - }) - sort.Slice(obj.GetStatus().LastApplied, func(i, j int) bool { - return obj.GetStatus().LastApplied[i].Name < obj.GetStatus().LastApplied[j].Name + x, y := obj.GetStatus().LastApplied[i], obj.GetStatus().LastApplied[j] + if x.Kind != y.Kind { + return x.Kind < y.Kind + } else { + return x.Name < y.Name + } }) obj.GetStatus().TemplateResourceVersion = "" @@ -93,4 +97,13 @@ func RemoveDynamicFields(o client.Object) { ownerRefs[i] = v } o.SetOwnerReferences(ownerRefs) + + if ann := o.GetAnnotations(); ann != nil { + if _, ok := ann[cosmov1alpha1.WorkspaceAnnKeyLastStartedAt]; ok { + ann[cosmov1alpha1.WorkspaceAnnKeyLastStartedAt] = "MASKED" + } + if _, ok := ann[cosmov1alpha1.WorkspaceAnnKeyLastStoppedAt]; ok { + ann[cosmov1alpha1.WorkspaceAnnKeyLastStoppedAt] = "MASKED" + } + } }