Secrets: Save owner reference fields in secure value db table (#108905)

* Secrets: Save owner reference fields in secure value db table

* Save api group and version separately
This commit is contained in:
Matheus Macabu
2025-07-31 10:42:19 +02:00
committed by GitHub
parent 66bebe94e0
commit 80d7892d6a
19 changed files with 243 additions and 67 deletions
+38 -30
View File
@@ -177,21 +177,25 @@ func TestSecureValueQueries(t *testing.T) {
Data: &createSecureValue{
SQLTemplate: mocks.NewTestingSQLTemplate(),
Row: &secureValueDB{
GUID: "abc",
Name: "name",
Namespace: "ns",
Annotations: `{"x":"XXXX"}`,
Labels: `{"a":"AAA", "b", "BBBB"}`,
Created: 1234,
CreatedBy: "user:ryan",
Updated: 5678,
UpdatedBy: "user:cameron",
Version: 1,
Description: "description",
Keeper: toNullString(nil),
Decrypters: toNullString(nil),
Ref: toNullString(nil),
ExternalID: "extId",
GUID: "abc",
Name: "name",
Namespace: "ns",
Annotations: `{"x":"XXXX"}`,
Labels: `{"a":"AAA", "b", "BBBB"}`,
Created: 1234,
CreatedBy: "user:ryan",
Updated: 5678,
UpdatedBy: "user:cameron",
Version: 1,
Description: "description",
Keeper: toNullString(nil),
Decrypters: toNullString(nil),
Ref: toNullString(nil),
ExternalID: "extId",
OwnerReferenceAPIGroup: toNullString(nil),
OwnerReferenceAPIVersion: toNullString(nil),
OwnerReferenceKind: toNullString(nil),
OwnerReferenceName: toNullString(nil),
},
},
},
@@ -200,21 +204,25 @@ func TestSecureValueQueries(t *testing.T) {
Data: &createSecureValue{
SQLTemplate: mocks.NewTestingSQLTemplate(),
Row: &secureValueDB{
GUID: "abc",
Name: "name",
Namespace: "ns",
Annotations: `{"x":"XXXX"}`,
Labels: `{"a":"AAA", "b", "BBBB"}`,
Created: 1234,
CreatedBy: "user:ryan",
Updated: 5678,
UpdatedBy: "user:cameron",
Version: 1,
Description: "description",
Keeper: toNullString(ptr.To("keeper_test")),
Decrypters: toNullString(ptr.To("decrypters_test")),
Ref: toNullString(ptr.To("ref_test")),
ExternalID: "extId",
GUID: "abc",
Name: "name",
Namespace: "ns",
Annotations: `{"x":"XXXX"}`,
Labels: `{"a":"AAA", "b", "BBBB"}`,
Created: 1234,
CreatedBy: "user:ryan",
Updated: 5678,
UpdatedBy: "user:cameron",
Version: 1,
Description: "description",
Keeper: toNullString(ptr.To("keeper_test")),
Decrypters: toNullString(ptr.To("decrypters_test")),
Ref: toNullString(ptr.To("ref_test")),
ExternalID: "extId",
OwnerReferenceAPIGroup: toNullString(ptr.To("prometheus.datasource.grafana.app")),
OwnerReferenceAPIVersion: toNullString(ptr.To("v0alpha1")),
OwnerReferenceKind: toNullString(ptr.To("DataSource")),
OwnerReferenceName: toNullString(ptr.To("prom-config")),
},
},
},