IAM: Create Service Account API and legacy store impl (#110411)

* wip

* IAM: Create Service Account

* Add dual writer

* Update openapi_test.go

* Add integration tests

* Add sql tests

* Add Role to SA spec, add validation, add DBTime, add tests

* Format, update test

* Fixes

* Add check for External

* Address feedback

* Update tests

* Address feedback

* make gen-go

* Simplify a bit

* Fixes

* make update-workspace

* Update pkg/registry/apis/iam/serviceaccount/store.go

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* Address feedback, add test for generateName

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Misi
2025-09-08 14:31:32 +02:00
committed by GitHub
co-authored by Ryan McKinley
parent 8a28381278
commit badea8bc37
46 changed files with 1961 additions and 198 deletions
@@ -0,0 +1,7 @@
INSERT INTO `grafana`.`user`
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
@@ -0,0 +1,7 @@
INSERT INTO `grafana`.`user`
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM `grafana`.`user` as u JOIN `grafana`.`org_user` as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM `grafana`.`user` as u JOIN `grafana`.`org_user` as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM `grafana`.`user` as u JOIN `grafana`.`org_user` as o ON u.id = o.user_id
@@ -0,0 +1,7 @@
INSERT INTO "grafana"."user"
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
@@ -0,0 +1,7 @@
INSERT INTO "grafana"."user"
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id
@@ -0,0 +1,7 @@
INSERT INTO "grafana"."user"
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
@@ -0,0 +1,7 @@
INSERT INTO "grafana"."user"
(uid, version, login, email, name, org_id, is_admin, is_disabled, email_verified,
is_provisioned, is_service_account, salt, rands, created, updated, last_seen_at)
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id
@@ -3,6 +3,7 @@ SELECT
u.uid,
u.name,
u.is_disabled,
o.role,
u.created,
u.updated
FROM "grafana"."user" as u JOIN "grafana"."org_user" as o ON u.id = o.user_id