Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration-based Datasource Management #71

Open
josephbirkner opened this issue Jul 5, 2024 · 0 comments
Open

Configuration-based Datasource Management #71

josephbirkner opened this issue Jul 5, 2024 · 0 comments
Assignees
Milestone

Comments

@josephbirkner
Copy link
Contributor

josephbirkner commented Jul 5, 2024

Currently, the only way to attach datasources to mapget via configuration is by passing -d or -e arguments for connecting with remote datasources. However, it is currently not possible to configure a datasource which runs in the same process as the mapget server.

For this purpose, mapget shall support a YAML-based settings format, where datasources can be configured side-by-side with zswag HTTP credentials. A sample entry may look like this:

sources:
  - type: SmartLayerTileService
    url: https://api.nds.live/island1/openapi.json
    id: NDS.Live Island 1
http-settings:
  - scope: api.nds.live
    api-key: ...

To make this work, mapget needs to support registering derived datasource constructors for certain datasource types. To this end, a function mapget::registerDataSourceType will be introduced. E.g.

mapget::registerDataSourceType(
  "SmartLayerTileService",
  [](YAML::Node const& config) -> std::shared_ptr<LiveDataSource> {
    if (!config.has("url"))
      throw std::runtime_error("SmartLayerTileService requires a `url` config entry!");
    auto mapId = config.has("id") ? config["id"] : "";
    return LiveSource(config["url"], config["id"]);
  })

The YAML-based config file format will replace the current TOML-based one. Additionally, a mapget service running with such a config file will watch it for changes. If it changes, the service will be restarted internally. Furthermore, mapget will support GET /config and POST /config endpoints if started with --expose-config. This will allow a client (such as erdblick) to offer a GUI for editing the datasource configuration. We can reduce this privilege to a narrow subset of users by adding a check such as --expose-config-require-header OAUTH_ROLE=administrator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant