K8s/Unified: Consolidate generation logic in apistore client (#102260)
This commit is contained in:
@@ -3,8 +3,6 @@ package generic
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -14,6 +12,8 @@ import (
|
||||
"k8s.io/apiserver/pkg/storage"
|
||||
"k8s.io/apiserver/pkg/storage/names"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
)
|
||||
|
||||
type genericStrategy struct {
|
||||
@@ -81,20 +81,6 @@ func (g *genericStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime
|
||||
} else {
|
||||
_ = newMeta.SetStatus(status)
|
||||
}
|
||||
|
||||
spec, err := newMeta.GetSpec()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
oldSpec, err := oldMeta.GetSpec()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !apiequality.Semantic.DeepEqual(spec, oldSpec) {
|
||||
newMeta.SetGeneration(oldMeta.GetGeneration() + 1)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *genericStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
|
||||
Reference in New Issue
Block a user