PB-50163 - Go-Cli : schema-driven resource type support#67
PB-50163 - Go-Cli : schema-driven resource type support#67cedricherzog-passbolt wants to merge 11 commits intopassbolt:v5from
Conversation
|
I had a look, I don't think the Resource wrapper should be separate fields for username, description, password and so on. We already have a Problem with the description which sometimes becomes the Note with v5. We can have generic access functions which could work with any resource type and we can check if the requested Field exists in the Jsonschema from the Server allowing for custom resource types. Adding functions which get the often used fields and return an error if they don't exist can still be done this way. This also eliminates all of ensureBasicFieldsParsed Since we don't need to have specific logic for resource Types. Any thought? |
ed308f2 to
4cb2643
Compare
eba171e to
0abefb9
Compare
0abefb9 to
055b66f
Compare
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
055b66f to
5cefc88
Compare
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
…ardless of v4/v5 schema differences Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Signed-off-by: Cédric HERZOG <cedric.herzog@passbolt.com>
Summary
Replace hardcoded per-type structs and switch statements with a generic,
schema-driven approach using
map[string]anyfor metadata and secret data.This enables support for any resource type automatically (including
v5-custom-fieldsfrom Passbolt 5.3) without touching SDK code.IsSecretString(),IsV5(),HasSecretField(),HasMetadataField()schema introspection methods on
ResourceTypeResourcewrapper to usemetadataFields/secretFieldsmapsinstead of discrete fields, with generic accessors (
MetadataFields(),SecretFields(),MetadataField(),SecretField())CreateResourceGeneric(ctx, c, slug, folderParentID, metadataFields, secretFields)and
UpdateResourceGeneric(ctx, c, resourceID, metadataUpdates, secretUpdates)GetResourceFromDataWithOptionsto eliminate the 8-branchswitch, now uses
Metadata != ""for v4/v5 detection andIsSecretString()for secret format detectionvalidateSecretDatawithIsSecretString()v5-custom-fieldsfallback schemaSecretDataTypeV5Default,ResourceMetadataTypeV5Default, etc.), keep onlySecret,SecretDataTOTP, and encryption/decryption functionsExisting public functions (
CreateResource,UpdateResource,GetResource,GetResourceFromData) are preserved as wrappers that delegate to thenew generic implementations.