meshcloud / unipipe-service-broker

GitOps Open Service Broker - exposes service instances and bindings as files in a git repository
Apache License 2.0
14 stars 11 forks source link

unipipe CLI expects the instances/ folder to be under '.' (current folder) #121

Closed xaviatwork closed 1 year ago

xaviatwork commented 1 year ago

When running the unipipe transform command, --registry-of-handlers accepts an arbitrary path, but the second parameter, which AFAIK is the path to the instances/ folder, makes unipipe transform fail:

$ unipipe transform --registry-of-handlers handlers/handlers.js testPath/looongPath
Loading handlers as javascript via eval() from handlers/handlers.js.
loaded handler modules {
  "de686eaa-<REDACTED>": DisconnectedHandler { name: "DisconnectedHandler" },
  "e482790b-<REDACTED>": FWHandler { name: "FW Handler" },
  "e79fa125-<REDACTED>": FWHandler { name: "FW Handler" },
  "0bf6186b-<REDACTED>": ConnectedHandler { name: "ConnectedHandler" }
}
- instance id: 7bc6410e-<REDACTED> | definition id: de686eaa-<REDACTED> -> DisconnectedHandler
validator passed
error: Uncaught (in promise) NotFound: No such file or directory (os error 2), open './instances/7bc6410e-<REDACTED>/status.yml'
    at async writeFile (deno:runtime/js/40_write_file.js:37:7)

If the instances/ folder is present in the current directory, then it works (even if the location of the handler.js file is at an arbitrary path:

$ unipipe transform --registry-of-handlers handlers/handlers.js .
Loading handlers as javascript via eval() from handlers/handlers.js.
loaded handler modules {
  "de686eaa-<REDACTED>": DisconnectedHandler { name: "DisconnectedHandler" },
  "e482790b-<REDACTED>": FWHandler { name: "FW Handler" },
  "e79fa125-<REDACTED>": FWHandler { name: "FW Handler" },
  "0bf6186b-<REDACTED>": ConnectedHandler { name: "ConnectedHandler" }
}
- instance id: 7bc6410e-<REDACTED> | definition id: de686eaa-<REDACTED> -> DisconnectedHandler
validator passed
Status has been written to complete delete.
- instance id: 3d01d084-<REDACTED> | definition id: de686eaa-<REDACTED> -> DisconnectedHandler
validator passed
Status has been written to complete delete.

I am using unipipe CLI version 1.7.6.

xaviatwork commented 1 year ago

Nevermind... The function writeStatusToAllowTenantBinding(service) in the handlers.js file seems the one not handling the path properly:

const write = Deno.writeTextFile(`./instances/${service.instance.serviceInstanceId}/status.yml`