How to push permissions to Scratch environment

How to push permissions to Scratch environment

To update permissions for a module on a Scratch environment we need to register a module descriptor in okapi. This is how you do this:

  1. Create a descriptor file on your machine (I will call it descriptor.json) with following content:
    Replace following placeholders:
    moduleName - name property in package.json without "@folio/"

    moduleVersion - version of module. It's a bit of a hack to get it - go to module's page in npm-folioci (for example https://repository.folio.org/service/rest/repository/browse/npm-folioci/%40folio/eholdings/), find the latest version number and use it as version.

    moduleDescription - description property in package.json

    requires - list of required interfaces. Can also be found in package.json

    permissionSets - list of UI permissions. Can be found in package.json

    { "id": "folio_moduleName-moduleVersion", "name": "moduleDescription", "requires": [ { "id": "interfaceId", "version": "interfaceVersion" } ], "optional": [], "permissionSets": [ { "permissionName": "module.eholdings.enabled", "displayName": "UI: eHoldings module is enabled", "subPermissions": [ "kb-ebsco.all", "tags.all" ], "visible": false },
    ... ] }





  2. Run the following command to push the descriptor to okapi

    curl -sL -w '\n' -D - -X POST -H "Content-type: application/json" -d @/descriptor.json $OKAPI_URL/_/proxy/modules?check=false



    Replace $OKAPI_URL with okapi url of scratch environment

    If you get an error saying that version already exists - change patch of moduleVersion to something else like "0000001"


  3. Run the following command to enable module for tenant (again, replace moduleName and moduleVersion placeholders from descriptor)
    curl -w '\n' -X POST -d '[ { "id" : "folio_moduleName-moduleVersion" , "action" : "enable" } ]' $OKAPI_URL/_/proxy/tenants/diku/install

  4. Run bootstrap script

    docker run --rm -e TENANT_ID=diku -e ADMIN_USER=diku_admin -e ADMIN_PASSWORD=admin -e OKAPI_URL=$OKAPI_URL docker.dev.folio.org/bootstrap-superuser