K8s/Unified: Consolidate generation logic in apistore client (#102260)

This commit is contained in:
Ryan McKinley
2025-03-21 10:45:25 +02:00
committed by GitHub
parent 996ff7d65e
commit 2e2b5942c8
9 changed files with 237 additions and 56 deletions
@@ -4,12 +4,13 @@ import (
"context"
"testing"
"github.com/grafana/grafana/pkg/apiserver/registry/generic"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/apis/example"
"github.com/grafana/grafana/pkg/apiserver/registry/generic"
)
func TestPrepareForUpdate(t *testing.T) {
@@ -69,37 +70,6 @@ func TestPrepareForUpdate(t *testing.T) {
},
},
},
{
name: "increment generation if spec changes",
newObj: &example.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "default",
Generation: 1,
},
Spec: example.PodSpec{
NodeSelector: map[string]string{"foo": "baz"},
},
Status: example.PodStatus{
Phase: example.PodPhase("Running"),
},
},
oldObj: oldObj.DeepCopy(),
expectedGen: 2,
expectedObj: &example.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "default",
Generation: 2,
},
Spec: example.PodSpec{
NodeSelector: map[string]string{"foo": "baz"},
},
Status: example.PodStatus{
Phase: example.PodPhase("Running"),
},
},
},
}
for _, tc := range testCases {