Skip to content

Migrate paas-charm to use ops.charm_dir instead of os.getcwd #166

@swetha1654

Description

@swetha1654

Bug Description

Currently, applications using the paas charm framework cannot run scenario tests due to the explanation provided by @tonyandrewmeyer in hockeypuck-k8s-operator:

The paas_charm code assumes (somewhat reasonably) that the current working directory is the charm root, but that's not the case with ops[testing]. In testing, we create a temporary directory for the charm root (this minimises the chances that tests mess with the actual code/tests) and write the metadata there. However, we don't currently set the working directory to the charm root, so the paas_charm code is looking for the YAML files in the repo root, rather than in the temporary charm root.

While the charm tech is working on fixing this in ops, they also recommended fixing the paas-charm code to use charm_dir as the directory that holds config.yaml rather than os.getcwd() or even use load_config, which provides more-or-less the same functionality that paas_charm is implementing.

To Reproduce

Please run the unit tests in the PR locally to see why scenario tests are failing.

Environment

Relevant log output

-

Additional context

No response

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