Skip to content

[testing] method for obtaining files from simulated FS #2202

@sed-i

Description

@sed-i

Currently, obtaining files from a simulated FS involves a bit of boilerplate:

out = ctx.run(ctx.on.update_status(), state)

# Currently, need both ctx and container to obtain fs
container = out.get_container("grafana")
fs = container.get_filesystem(ctx)

# Collect files
dashboards_dir = fs / "etc" / "grafana" / "provisioning" / "dashboards"
dashboard_files = list(dashboards_dir.glob("juju_*.json"))
dashboards = {f.name: f.read_text() for f in dashboard_files}

It would be handy if we could for example

dashboards = container.read_glob(ctx, "/etc/grafana/provisioning/dashboards", "juju_*.json")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions