From 85a6a7b9c15e0220ec0a25e4c511009adb59fc3e Mon Sep 17 00:00:00 2001 From: Gabriel MABILLE Date: Thu, 10 Jul 2025 09:24:30 +0200 Subject: [PATCH] `iam`: add description field to roles (#107888) * iam: add description field to roles * Openapi gen * Revert launch change --- apps/iam/kinds/v0alpha1/rolespec.cue | 1 + .../apis/iam/v0alpha1/corerole_spec_gen.go | 7 ++--- .../apis/iam/v0alpha1/globalrole_spec_gen.go | 7 ++--- .../pkg/apis/iam/v0alpha1/role_spec_gen.go | 7 ++--- .../pkg/apis/iam/v0alpha1/zz_openapi_gen.go | 27 ++++++++++++++++--- .../iam.grafana.app-v0alpha1.json | 15 +++++++++++ 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/apps/iam/kinds/v0alpha1/rolespec.cue b/apps/iam/kinds/v0alpha1/rolespec.cue index 845ae207c28..b7934f0174e 100644 --- a/apps/iam/kinds/v0alpha1/rolespec.cue +++ b/apps/iam/kinds/v0alpha1/rolespec.cue @@ -10,6 +10,7 @@ RoleSpec: { // Display name of the role title: string + description: string version: int group: string diff --git a/apps/iam/pkg/apis/iam/v0alpha1/corerole_spec_gen.go b/apps/iam/pkg/apis/iam/v0alpha1/corerole_spec_gen.go index eb2c1d52e40..ac0b41e1972 100644 --- a/apps/iam/pkg/apis/iam/v0alpha1/corerole_spec_gen.go +++ b/apps/iam/pkg/apis/iam/v0alpha1/corerole_spec_gen.go @@ -18,9 +18,10 @@ func NewCoreRolespecPermission() *CoreRolespecPermission { // +k8s:openapi-gen=true type CoreRoleSpec struct { // Display name of the role - Title string `json:"title"` - Version int64 `json:"version"` - Group string `json:"group"` + Title string `json:"title"` + Description string `json:"description"` + Version int64 `json:"version"` + Group string `json:"group"` // TODO: // delegatable?: bool // created? diff --git a/apps/iam/pkg/apis/iam/v0alpha1/globalrole_spec_gen.go b/apps/iam/pkg/apis/iam/v0alpha1/globalrole_spec_gen.go index 785d2d5724b..1ce8d65646f 100644 --- a/apps/iam/pkg/apis/iam/v0alpha1/globalrole_spec_gen.go +++ b/apps/iam/pkg/apis/iam/v0alpha1/globalrole_spec_gen.go @@ -18,9 +18,10 @@ func NewGlobalRolespecPermission() *GlobalRolespecPermission { // +k8s:openapi-gen=true type GlobalRoleSpec struct { // Display name of the role - Title string `json:"title"` - Version int64 `json:"version"` - Group string `json:"group"` + Title string `json:"title"` + Description string `json:"description"` + Version int64 `json:"version"` + Group string `json:"group"` // TODO: // delegatable?: bool // created? diff --git a/apps/iam/pkg/apis/iam/v0alpha1/role_spec_gen.go b/apps/iam/pkg/apis/iam/v0alpha1/role_spec_gen.go index f1a165dba4e..5a8185cd25c 100644 --- a/apps/iam/pkg/apis/iam/v0alpha1/role_spec_gen.go +++ b/apps/iam/pkg/apis/iam/v0alpha1/role_spec_gen.go @@ -18,9 +18,10 @@ func NewRolespecPermission() *RolespecPermission { // +k8s:openapi-gen=true type RoleSpec struct { // Display name of the role - Title string `json:"title"` - Version int64 `json:"version"` - Group string `json:"group"` + Title string `json:"title"` + Description string `json:"description"` + Version int64 `json:"version"` + Group string `json:"group"` // TODO: // delegatable?: bool // created? diff --git a/apps/iam/pkg/apis/iam/v0alpha1/zz_openapi_gen.go b/apps/iam/pkg/apis/iam/v0alpha1/zz_openapi_gen.go index 406834348e3..7a0703d53e3 100644 --- a/apps/iam/pkg/apis/iam/v0alpha1/zz_openapi_gen.go +++ b/apps/iam/pkg/apis/iam/v0alpha1/zz_openapi_gen.go @@ -186,6 +186,13 @@ func schema_pkg_apis_iam_v0alpha1_CoreRoleSpec(ref common.ReferenceCallback) com Format: "", }, }, + "description": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, "version": { SchemaProps: spec.SchemaProps{ Default: 0, @@ -215,7 +222,7 @@ func schema_pkg_apis_iam_v0alpha1_CoreRoleSpec(ref common.ReferenceCallback) com }, }, }, - Required: []string{"title", "version", "group", "permissions"}, + Required: []string{"title", "description", "version", "group", "permissions"}, }, }, Dependencies: []string{ @@ -740,6 +747,13 @@ func schema_pkg_apis_iam_v0alpha1_GlobalRoleSpec(ref common.ReferenceCallback) c Format: "", }, }, + "description": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, "version": { SchemaProps: spec.SchemaProps{ Default: 0, @@ -769,7 +783,7 @@ func schema_pkg_apis_iam_v0alpha1_GlobalRoleSpec(ref common.ReferenceCallback) c }, }, }, - Required: []string{"title", "version", "group", "permissions"}, + Required: []string{"title", "description", "version", "group", "permissions"}, }, }, Dependencies: []string{ @@ -1600,6 +1614,13 @@ func schema_pkg_apis_iam_v0alpha1_RoleSpec(ref common.ReferenceCallback) common. Format: "", }, }, + "description": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, "version": { SchemaProps: spec.SchemaProps{ Default: 0, @@ -1629,7 +1650,7 @@ func schema_pkg_apis_iam_v0alpha1_RoleSpec(ref common.ReferenceCallback) common. }, }, }, - Required: []string{"title", "version", "group", "permissions"}, + Required: []string{"title", "description", "version", "group", "permissions"}, }, }, Dependencies: []string{ diff --git a/pkg/tests/apis/openapi_snapshots/iam.grafana.app-v0alpha1.json b/pkg/tests/apis/openapi_snapshots/iam.grafana.app-v0alpha1.json index b1b2dc77570..6c3fae072bb 100644 --- a/pkg/tests/apis/openapi_snapshots/iam.grafana.app-v0alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/iam.grafana.app-v0alpha1.json @@ -2923,11 +2923,16 @@ "type": "object", "required": [ "title", + "description", "version", "group", "permissions" ], "properties": { + "description": { + "type": "string", + "default": "" + }, "group": { "type": "string", "default": "" @@ -3236,11 +3241,16 @@ "type": "object", "required": [ "title", + "description", "version", "group", "permissions" ], "properties": { + "description": { + "type": "string", + "default": "" + }, "group": { "type": "string", "default": "" @@ -3723,11 +3733,16 @@ "type": "object", "required": [ "title", + "description", "version", "group", "permissions" ], "properties": { + "description": { + "type": "string", + "default": "" + }, "group": { "type": "string", "default": ""