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

Better API for container filesystem setup in Scenario #1430

Open
tonyandrewmeyer opened this issue Oct 10, 2024 · 0 comments
Open

Better API for container filesystem setup in Scenario #1430

tonyandrewmeyer opened this issue Oct 10, 2024 · 0 comments
Labels
feature New feature or request needs design needs more thought or spec testing Related to ops.testing

Comments

@tonyandrewmeyer
Copy link
Contributor

Right now, if you want to 'prepare' a container filesystem to e.g. simulate a config file being present before scenario runs, you have to mess with Mounts and create a temporary directory yourself:

    td = tempfile.TemporaryDirectory()
    conf_file = Path(td.name).joinpath(f"filename.yaml")
    conf_file.write_text("foobar")

    traefik_container = traefik_container.replace(mounts={
        "conf": Mount("/opt/traefik/", td.name)
    })

Wouldn't it be nice if you could simply grab the filesystem from the context and manipulate it directly like:

    file = traefik_container.get_filesystem(traefik_ctx).joinpath('filename.yaml')
    file.parent.mkdir(exist_ok=True)
    file.write_text('foobar')
    
    # continue with test

Issue with this is that when ops (scenario) sets up the container it expects a clean slate and will raise if any of the paths exist already or can't be deleted because they contain files.

Moved from canonical/ops-scenario#59

@tonyandrewmeyer tonyandrewmeyer added feature New feature or request needs design needs more thought or spec labels Oct 10, 2024
@benhoyt benhoyt added the testing Related to ops.testing label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request needs design needs more thought or spec testing Related to ops.testing
Projects
None yet
Development

No branches or pull requests

2 participants