threefoldtecharchive / jumpscaleX_threebot

Apache License 2.0
0 stars 3 forks source link

Conflict in / location in packages [unstable] #475

Open grimpy opened 4 years ago

grimpy commented 4 years ago

Now that we made /admin also register / we have a conflict when running the explorer.

We want to solve this in a generic way. Proposal is to only ever register the / location under the name root this way in worst case packages are overwriting the root not causing conflict on lapis itself

Now we want admin package to be a bit smart if root location is registered with another value then what admin expects it should leave it alone to allow to overrule the / of admin

Please add documentation for this behaviour

abom commented 4 years ago

Couldn't do this as the current schema for locations need to be updated, and this would introduce breaking changes.

With current schema of jumpscale.openresty.location, you will get a collection of locations, were you need to add locations to this instance as locations_static, locations_spa...etc, so ensuring only one object with name = "root" can be overwritten is not easy here, as anyone can add another type of locations, and this type cannot be searched like models, it's just a sub-object.

       @url = jumpscale.openresty.location
        name** = (S)
        path = "/sandbox/var/web/default" (S)
        locations_static = (LO) !jumpscale.openresty.location_static
        locations_proxy = (LO) !jumpscale.openresty.location_proxy
        locations_lapis = (LO) !jumpscale.openresty.location_lapis
        locations_custom = (LO) !jumpscale.openresty.location_custom
        locations_spa = (LO) !jumpscale.openresty.location_static
        mother_id** = 0 (I)

        @url = jumpscale.openresty.location_static
        name = "" (S)
        path_url = "/"
        path_location = ""
        index = "index.html"
        use_jumpscale_weblibs = false (B)
        is_auth = false (B)
        force_https = false (B)

        @url = jumpscale.openresty.location_proxy
        name = "" (S)
        path_url = ""
        ipaddr_dest = (S)
        port_dest = (I)
        path_dest = "" (S)
        type = "http,websocket" (E)
        scheme = "http,https,ws,wss" (E)
        is_auth = false (B)
        force_https = false (B)

        @url = jumpscale.openresty.location_lapis
        name = ""
        path_url = ""
        path_location = ""
        is_auth = false (B)
        force_https = false (B)

        @url = jumpscale.openresty.location_custom
        name = ""
        config = ""
        is_auth = false (B)
        force_https = false (B)

I thought of a single schema without sub-locations which include all possible fields and an extra type field to know this location of which type, in this case, each package can do something like the following to overwrite it:

website = ...
locations = ...
location = locations.get("root")
location.type = "static"
location.path_url = "/"
location.path_location = "/path/to/html/files"
...
abom commented 4 years ago

For now, i moved admin root location to another website/server config (https://github.com/threefoldtech/jumpscaleX_threebot/commit/71caa2d33110795b66e313c7343674f3db83c27e).

This will resolve the conflict problem where other packages include default website config (default website is the one we get using get_from_port()).

But still, this does not resolve the problem on local hosts while testing, as we cannot check if the current website has a root location in a proper way, and other packages cannot overwrite this location, see previous comment.

xmonader commented 4 years ago

I moved to 10.5 and will open an issue for / in admin package to use its own website :)