mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s/Dashboard: Set generation from version (#99142)
This commit is contained in:
parent
a0d1a197e3
commit
7c04247d6f
@ -263,6 +263,7 @@ func (a *dashboardSqlAccess) scanRow(rows *sql.Rows) (*dashboardRow, error) {
|
||||
meta.SetCreatedBy(getUserID(createdBy, createdByID))
|
||||
meta.SetUpdatedBy(getUserID(updatedBy, updatedByID))
|
||||
meta.SetDeprecatedInternalID(dashboard_id) //nolint:staticcheck
|
||||
meta.SetGeneration(version)
|
||||
|
||||
if deleted.Valid {
|
||||
meta.SetDeletionTimestamp(ptr.To(metav1.NewTime(deleted.Time)))
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
@ -60,6 +61,12 @@ func runDashboardTest(t *testing.T, helper *apis.K8sTestHelper) {
|
||||
obj, err = client.Resource.Get(ctx, created, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, created, obj.GetName())
|
||||
require.Equal(t, int64(1), obj.GetGeneration())
|
||||
|
||||
wrap, err := utils.MetaAccessor(obj)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, wrap.GetRepositoryName()) // no SQL repo stub
|
||||
require.Equal(t, helper.Org1.Admin.Identity.GetUID(), wrap.GetCreatedBy())
|
||||
|
||||
// Commented out because the dynamic client does not like lists as sub-resource
|
||||
// // Check that it now appears in the history
|
||||
|
@ -23,6 +23,8 @@ export interface ObjectMeta {
|
||||
namespace?: string;
|
||||
// Resource version will increase (not sequentially!) with any change to the saved value
|
||||
resourceVersion: string;
|
||||
// Incremented by the server when the value of spec changes
|
||||
generation?: number;
|
||||
// The first time this was saved
|
||||
creationTimestamp: string;
|
||||
// General resource annotations -- including the common grafana.app values
|
||||
|
Loading…
Reference in New Issue
Block a user