Skip to content

indexdata/replace-module-descriptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

replace-module-descriptor

This is a stand-alone Node script, using no NPM modules, for Okapi-based FOLIO systems. It replaces the module descriptor for a specfied module. This is necessary when changing a module's routing or permissions. (It is the only way to bring new permissions into existence or to change the definitions of existing permissions).

To do this in the general case, it is necessary to:

  • Disabling the current version of the module for all tenants that have it enabled
  • Deleting the old module descriptor
  • Inserting the new module descriptor
  • Enabling the tenants for the new version of the module.

But because this is needed in development rather than production environments, where typically only a single tenant is required, thw present version simplifies by only disabling/re-enabling the module for a single specified tenant.

replace-module-descriptor takes all its Okapi information from the environment:

  • OKAPI_URL
  • OKAPI_TENANT
  • OKAPI_USER
  • OKAPI_PASSWORD (or OKAPI_PW for compatibility with okapi-curl

Usage is simple: there is a -v option to cause verbose output, and the only command-line argument is the name of the file containing the new module descriptor. So for example:

$ env OKAPI_URL=http://localhost:9130 OKAPI_TENANT=diku OKAPI_USER=diku_admin OKAPI_PW=swordfish \
	./replace-module-descriptor -v ../mod-cyclops/target/ModuleDescriptor.json 
[log] Reading ../mod-cyclops/target/ModuleDescriptor.json
[log] Parsing module descriptor as JSON
[log] New module: name 'mod-cyclops' from ID mod-cyclops-0.0.1
[log] Logging in as diku_admin
[log] Finding old enabled module in tenant diku
[log] Disabling old module mod-cyclops-0.0.1 for tenant diku
[log] Removing old module descriptor mod-cyclops-0.0.1
[log] Inserting new module descriptor mod-cyclops-0.0.1
[log] Enabling old module mod-cyclops-0.0.1 for tenant diku
$ 

replace-module-descriptor exits with status zero if all is well. It exits with different non-zero statuses for various error conditions, emitting a message for each:

  • 1: not all required environment variables are set
  • 2: command-line usage is incorrect
  • 3: login could not be performed
  • 4: existing enabled version of module could not be found for the tenant
  • 5: multiple enabled versions of the module for the tenant (probably impossible)
  • 6: could not disable the old version of the module for the tenant
  • 7: could not remove the old version of the module
  • 8 :could not insert the new version of the module
  • 9: could not enable the new version of the module for the tenant

Author: Mike Taylor mike@indexdata.com

Licence: Apache 2.0 (open source)

About

Replace an old verson of a module's descriptor with a new version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors