From 2234cc0d88ee154fa670a3dd0170e21748348e35 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 8 Dec 2023 11:07:53 +0400 Subject: [PATCH 1/5] Fix FieldRule * `username` can also be a list, * `realm.name` is the field name, using an intermediate `realm` object does not work. * `metadata` is not a key: keys are of the form `metadata.key = value` --- output/schema/schema.json | 63 +++++++++---------- output/typescript/types.ts | 13 ++-- .../security/_types/RoleMappingRule.ts | 14 ++--- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index af1ae3d844..c0631d60df 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -171090,6 +171090,29 @@ "specLocation": "security/_types/CreatedStatus.ts#L20-L22" }, { + "attachedBehaviors": [ + "AdditionalProperties" + ], + "behaviors": [ + { + "generics": [ + { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + { + "kind": "user_defined_value" + } + ], + "type": { + "name": "AdditionalProperties", + "namespace": "_spec_utils" + } + } + ], "kind": "interface", "name": { "name": "FieldRule", @@ -171102,7 +171125,7 @@ "type": { "kind": "instance_of", "type": { - "name": "Name", + "name": "Names", "namespace": "_types" } } @@ -171130,25 +171153,18 @@ } }, { - "name": "metadata", - "required": false, - "type": { - "kind": "user_defined_value" - } - }, - { - "name": "realm", + "name": "realm.name", "required": false, "type": { "kind": "instance_of", "type": { - "name": "Realm", - "namespace": "security._types" + "name": "Name", + "namespace": "_types" } } } ], - "specLocation": "security/_types/RoleMappingRule.ts#L33-L42", + "specLocation": "security/_types/RoleMappingRule.ts#L34-L42", "variants": { "kind": "container" } @@ -171432,27 +171448,6 @@ ], "specLocation": "security/_types/Privileges.ts#L197-L199" }, - { - "kind": "interface", - "name": { - "name": "Realm", - "namespace": "security._types" - }, - "properties": [ - { - "name": "name", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Name", - "namespace": "_types" - } - } - } - ], - "specLocation": "security/_types/RoleMappingRule.ts#L44-L46" - }, { "kind": "interface", "name": { @@ -171884,7 +171879,7 @@ } } ], - "specLocation": "security/_types/RoleMappingRule.ts#L23-L31", + "specLocation": "security/_types/RoleMappingRule.ts#L24-L32", "variants": { "kind": "container" } diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 4bc6d799f3..fd94ad1e9a 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -16071,13 +16071,14 @@ export interface SecurityCreatedStatus { created: boolean } -export interface SecurityFieldRule { - username?: Name +export interface SecurityFieldRuleKeys { + username?: Names dn?: Names groups?: Names - metadata?: any - realm?: SecurityRealm + 'realm.name'?: Name } +export type SecurityFieldRule = SecurityFieldRuleKeys + & { [property: string]: any } export interface SecurityFieldSecurity { except?: Fields @@ -16106,10 +16107,6 @@ export interface SecurityManageUserPrivileges { applications: string[] } -export interface SecurityRealm { - name: Name -} - export interface SecurityRealmInfo { name: Name type: string diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index b373fb4eb0..7b143d2e39 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -17,6 +17,7 @@ * under the License. */ +import { AdditionalProperties } from '@spec_utils/behaviors' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' import { Name, Names } from '@_types/common' @@ -33,14 +34,11 @@ export class RoleMappingRule { /** * @variants container */ -export class FieldRule { - username?: Name +export class FieldRule + implements AdditionalProperties +{ + username?: Names dn?: Names groups?: Names - metadata?: UserDefinedValue - realm?: Realm -} - -export class Realm { - name: Name + 'realm.name'?: Name } From df65c1b063f8c28794f5bde3793864b8843015d5 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 13 Dec 2023 17:23:19 +0400 Subject: [PATCH 2/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurent Saint-Félix --- specification/security/_types/RoleMappingRule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index 7b143d2e39..ce1d553a9b 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -33,9 +33,9 @@ export class RoleMappingRule { /** * @variants container + * @non_exhaustive */ export class FieldRule - implements AdditionalProperties { username?: Names dn?: Names From 5b085745f01c43301a2399314c5b4dbece920a3e Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 13 Dec 2023 17:28:04 +0400 Subject: [PATCH 3/5] Run `make contrib` --- output/schema/schema.json | 28 ++----------------- output/typescript/types.ts | 4 +-- .../security/_types/RoleMappingRule.ts | 3 +- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index c0631d60df..620d897ad7 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -171090,29 +171090,6 @@ "specLocation": "security/_types/CreatedStatus.ts#L20-L22" }, { - "attachedBehaviors": [ - "AdditionalProperties" - ], - "behaviors": [ - { - "generics": [ - { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - }, - { - "kind": "user_defined_value" - } - ], - "type": { - "name": "AdditionalProperties", - "namespace": "_spec_utils" - } - } - ], "kind": "interface", "name": { "name": "FieldRule", @@ -171164,9 +171141,10 @@ } } ], - "specLocation": "security/_types/RoleMappingRule.ts#L34-L42", + "specLocation": "security/_types/RoleMappingRule.ts#L34-L44", "variants": { - "kind": "container" + "kind": "container", + "nonExhaustive": true } }, { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index fd94ad1e9a..2b6c7f1557 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -16071,14 +16071,12 @@ export interface SecurityCreatedStatus { created: boolean } -export interface SecurityFieldRuleKeys { +export interface SecurityFieldRule { username?: Names dn?: Names groups?: Names 'realm.name'?: Name } -export type SecurityFieldRule = SecurityFieldRuleKeys - & { [property: string]: any } export interface SecurityFieldSecurity { except?: Fields diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index ce1d553a9b..a27a652669 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -35,8 +35,7 @@ export class RoleMappingRule { * @variants container * @non_exhaustive */ -export class FieldRule -{ +export class FieldRule { username?: Names dn?: Names groups?: Names From 079a3c638cc99c7c8c2bc4ea26519c04f3f4e346 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 13 Dec 2023 19:17:29 +0400 Subject: [PATCH 4/5] Update RoleMappingRule.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurent Saint-Félix --- specification/security/_types/RoleMappingRule.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index a27a652669..b8b1f5422c 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -17,7 +17,6 @@ * under the License. */ -import { AdditionalProperties } from '@spec_utils/behaviors' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' import { Name, Names } from '@_types/common' From 9aaf75aa0dc4fcff5e3fa2b1d3554dd92d2eee98 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 3 Jan 2024 17:35:06 +0100 Subject: [PATCH 5/5] Address review comments --- specification/security/_types/RoleMappingRule.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index b8b1f5422c..85b52882a8 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -26,6 +26,9 @@ import { Name, Names } from '@_types/common' export class RoleMappingRule { any?: RoleMappingRule[] all?: RoleMappingRule[] + // `field` should have been defined as SingleKeyDictionary + // However, this was initially defined as a container with a limited number of variants, + // and was later made non_exhaustive to limit breaking changes. field?: FieldRule except?: RoleMappingRule } @@ -38,5 +41,4 @@ export class FieldRule { username?: Names dn?: Names groups?: Names - 'realm.name'?: Name }