SecretsManager: add secure value store (#106708)

* SecretsManager: add secure value model and sql templates

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
Co-authored-by: Dana Axinte <53751979+dana-axinte@users.noreply.github.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
Co-authored-by: PoorlyDefinedBehaviour <brunotj2015@hotmail.com>

* SecretsManager: secure value rest layer to use store

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
Co-authored-by: Dana Axinte <53751979+dana-axinte@users.noreply.github.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
Co-authored-by: PoorlyDefinedBehaviour <brunotj2015@hotmail.com>

* SecretsManager: temporary add actor prefix to decrypters

* Remove list securevalue by namefor now

---------

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
Co-authored-by: PoorlyDefinedBehaviour <brunotj2015@hotmail.com>
This commit is contained in:
Dana Axinte
2025-06-16 10:19:44 +01:00
committed by GitHub
co-authored by Matheus Macabu Leandro Deveikis PoorlyDefinedBehaviour
parent ffc16ee072
commit 6097841e67
52 changed files with 1909 additions and 20 deletions
@@ -0,0 +1,51 @@
INSERT INTO {{ .Ident "secret_secure_value" }} (
{{ .Ident "guid" }},
{{ .Ident "name" }},
{{ .Ident "namespace" }},
{{ .Ident "annotations" }},
{{ .Ident "labels" }},
{{ .Ident "created" }},
{{ .Ident "created_by" }},
{{ .Ident "updated" }},
{{ .Ident "updated_by" }},
{{ .Ident "status_phase" }},
{{ if .Row.Message.Valid }}
{{ .Ident "status_message" }},
{{ end }}
{{ .Ident "description" }},
{{ if .Row.Keeper.Valid }}
{{ .Ident "keeper" }},
{{ end }}
{{ if .Row.Decrypters.Valid }}
{{ .Ident "decrypters" }},
{{ end }}
{{ if .Row.Ref.Valid }}
{{ .Ident "ref" }},
{{ end }}
{{ .Ident "external_id" }}
) VALUES (
{{ .Arg .Row.GUID }},
{{ .Arg .Row.Name }},
{{ .Arg .Row.Namespace }},
{{ .Arg .Row.Annotations }},
{{ .Arg .Row.Labels }},
{{ .Arg .Row.Created }},
{{ .Arg .Row.CreatedBy }},
{{ .Arg .Row.Updated }},
{{ .Arg .Row.UpdatedBy }},
{{ .Arg .Row.Phase }},
{{ if .Row.Message.Valid }}
{{ .Arg .Row.Message.String }},
{{ end }}
{{ .Arg .Row.Description }},
{{ if .Row.Keeper.Valid }}
{{ .Arg .Row.Keeper.String }},
{{ end }}
{{ if .Row.Decrypters.Valid }}
{{ .Arg .Row.Decrypters.String }},
{{ end }}
{{ if .Row.Ref.Valid }}
{{ .Arg .Row.Ref.String }},
{{ end }}
{{ .Arg .Row.ExternalID }}
);
@@ -0,0 +1,4 @@
DELETE FROM {{ .Ident "secret_secure_value" }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Name }}
;
@@ -0,0 +1,22 @@
SELECT
{{ .Ident "guid" }},
{{ .Ident "name" }},
{{ .Ident "namespace" }},
{{ .Ident "annotations" }},
{{ .Ident "labels" }},
{{ .Ident "created" }},
{{ .Ident "created_by" }},
{{ .Ident "updated" }},
{{ .Ident "updated_by" }},
{{ .Ident "status_phase" }},
{{ .Ident "status_message" }},
{{ .Ident "description" }},
{{ .Ident "keeper" }},
{{ .Ident "decrypters" }},
{{ .Ident "ref" }},
{{ .Ident "external_id" }}
FROM
{{ .Ident "secret_secure_value" }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }}
ORDER BY {{ .Ident "updated" }} DESC
;
@@ -0,0 +1,11 @@
{{/* this query is used to validate the keeper update or creation */}}
SELECT
{{ .Ident "name" }},
{{ .Ident "keeper" }}
FROM
{{ .Ident "secret_secure_value" }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} IN ({{ .ArgList .UsedSecureValues }})
{{ .SelectFor "UPDATE" }}
;
@@ -0,0 +1,25 @@
SELECT
{{ .Ident "guid" }},
{{ .Ident "name" }},
{{ .Ident "namespace" }},
{{ .Ident "annotations" }},
{{ .Ident "labels" }},
{{ .Ident "created" }},
{{ .Ident "created_by" }},
{{ .Ident "updated" }},
{{ .Ident "updated_by" }},
{{ .Ident "status_phase" }},
{{ .Ident "status_message" }},
{{ .Ident "description" }},
{{ .Ident "keeper" }},
{{ .Ident "decrypters" }},
{{ .Ident "ref" }},
{{ .Ident "external_id" }}
FROM
{{ .Ident "secret_secure_value" }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Name }}
{{ if .IsForUpdate }}
{{ .SelectFor "UPDATE" }}
{{ end }}
;
@@ -0,0 +1,10 @@
SELECT
{{ .Ident "keeper" }},
{{ .Ident "decrypters" }},
{{ .Ident "ref" }},
{{ .Ident "external_id" }}
FROM
{{ .Ident "secret_secure_value" }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Name }}
;
@@ -0,0 +1,30 @@
UPDATE
{{ .Ident "secret_secure_value" }}
SET
{{ .Ident "guid" }} = {{ .Arg .Row.GUID }},
{{ .Ident "name" }} = {{ .Arg .Row.Name }},
{{ .Ident "namespace" }} = {{ .Arg .Row.Namespace }},
{{ .Ident "annotations" }} = {{ .Arg .Row.Annotations }},
{{ .Ident "labels" }} = {{ .Arg .Row.Labels }},
{{ .Ident "created" }} = {{ .Arg .Row.Created }},
{{ .Ident "created_by" }} = {{ .Arg .Row.CreatedBy }},
{{ .Ident "updated" }} = {{ .Arg .Row.Updated }},
{{ .Ident "updated_by" }} = {{ .Arg .Row.UpdatedBy }},
{{ .Ident "status_phase" }} = {{ .Arg .Row.Phase }},
{{ if .Row.Message.Valid }}
{{ .Ident "status_message" }} = {{ .Arg .Row.Message.String }},
{{ end }}
{{ .Ident "description" }} = {{ .Arg .Row.Description }},
{{ if .Row.Keeper.Valid }}
{{ .Ident "keeper" }} = {{ .Arg .Row.Keeper.String }},
{{ end }}
{{ if .Row.Decrypters.Valid }}
{{ .Ident "decrypters" }} = {{ .Arg .Row.Decrypters.String }},
{{ end }}
{{ if .Row.Ref.Valid }}
{{ .Ident "ref" }} = {{ .Arg .Row.Ref.String }},
{{ end }}
{{ .Ident "external_id" }} = {{ .Arg .Row.ExternalID }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Row.Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Row.Name }}
;
@@ -0,0 +1,7 @@
UPDATE
{{ .Ident "secret_secure_value" }}
SET
{{ .Ident "external_id" }} = {{ .Arg .ExternalID }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Name }}
;
@@ -0,0 +1,8 @@
UPDATE
{{ .Ident "secret_secure_value" }}
SET
{{ .Ident "status_phase" }} = {{ .Arg .Phase }},
{{ .Ident "status_message" }} = {{ .Arg .Message }}
WHERE {{ .Ident "namespace" }} = {{ .Arg .Namespace }} AND
{{ .Ident "name" }} = {{ .Arg .Name }}
;