Skip to content

[Feature]: GDAL Configuration File (gdalrc) I/O #13

Description

@jimbrig

GDAL Configuration File (gdalrc) I/O

Formal, exported I/O for the GDAL configuration file format, as part of the configuration system (#8).

Why

  • GDAL reads the config file once, at driver registration - i.e. before this package can act. The file is therefore a discovery/provenance input in-process, but it is also the only lossless out-of-process serialization of a full gdal_config value: path-bound VSI credentials cannot be expressed as CLI --config flags at all (only [credentials] or in-process VSISetPathSpecificOption() carry them).
  • Reading a gdalrc should yield the package's value classes directly, so a file round-trips into the same machinery as everything else.

Grammar (GDAL >= 3.3 / 3.5 / 3.6)

[directives]
ignore-env-vars=yes            # GDAL >= 3.6: env vars ignored in favor of [configoptions]

[configoptions]
GDAL_NUM_THREADS=ALL_CPUS      # loaded into the in-memory store at GDAL init

[credentials]                  # GDAL >= 3.5: path-bound VSI options
[.private_bucket]              # relative subsection, first key must be `path`
path=/vsis3/my_private_bucket
AWS_SECRET_ACCESS_KEY=...
AWS_ACCESS_KEY_ID=...

API

  • gdal_config_file_read(path) -> classed gdal_config_file: configoptions as a gdal_config_opts, directives as a named vector, credentials as a list of gdal_vsi_opts with their vsi_path bound (from the subsection path key).
  • as_gdal_config.gdal_config_file() -> a gdal_config value (configoptions + credentials), closing the loop: read a gdalrc, apply it in-process via gdal_config_set().
  • gdal_config_file_write(x, path) -> the inverse; the faithful serialization target for a full gdal_config (config channel -> [configoptions], path-bound VSI channel -> [credentials] subsections). Secrets are written as-is by design (it is a credentials file); printing remains redacted.
  • gdal_config_file() (discovery, exists) returns the parsed object for the file GDAL actually loaded (GDAL_CONFIG_FILE envvar, then ~/.gdal/gdalrc), cached at package load for sitrep provenance ([Feature]: gdal_config_sitrep() - Configuration Situational Report #12).

Parser implementation: tidy line-classification (tibble + stringr + tidyr::fill for section/subsection context) rather than an imperative accumulator loop; gdalrc-specific rather than generic ini (the [.subsection] + path binding rules are format-specific).

Related

#8 (parent design), #12 (sitrep provenance), #14 (Phase 2: --optfile writer is the sibling serialization for algorithm arguments)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions