Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ Notable changes to Cloudfall. The format follows

### Fixed

- `migrate --env-file NAME=PATH` and `--data NAME=PATH` resolve a relative
path against the project again, as every other path does; since the
move to treaty they resolved against the current directory
- `migrate --build` and the `cloudfall-mcp` `build_artifact` tool read the
release from the engine's treaty envelope, under `data`. Since the engine
moved to treaty every build step failed with "artifact builder returned no
Expand Down
5 changes: 3 additions & 2 deletions sdk/src/cloudfall/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2078,12 +2078,13 @@ def options(self, fleet: Fleet) -> MigrateOptions:
plan_file=fleet.path(self.plan_file),
builds=_pairs(self.build, "build"),
releases=_pairs(self.release, "release"),
# Relative to the project, as every other path here is.
environment_files={
component: Path(value)
component: fleet.path(Path(value))
for component, value in _pairs(self.env_file, "env-file").items()
},
data_migrations={
database: Path(value)
database: fleet.path(Path(value))
for database, value in _pairs(self.data, "data").items()
},
execute=self.yes,
Expand Down
23 changes: 22 additions & 1 deletion sdk/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from pathlib import Path

import pytest
from cloudfall.app import app
from cloudfall.app import Fleet, MigrateArgs, app
from cloudfall.cli import main
from cloudfall.commands import CLI_COMMANDS
from cloudfall.resources import default_schema_directory
from cloudfall.validation import validate_config

ROOT = Path(__file__).parents[2]
EXAMPLES = ROOT / "config" / "examples"
COMPLIANT = ROOT / "config" / "tests" / "observed" / "compliant"
SCHEMAS = default_schema_directory()


def test_the_contract_marks_exactly_the_commands_treaty_runs() -> None:
Expand Down Expand Up @@ -84,3 +87,21 @@ def test_a_drift_report_keeps_the_order_the_checks_ran_in(
report = json.loads(capsys.readouterr().out)["data"]
assert code == 83
assert report["servers"][0]["checks"][0]["check"] == "server_type.id"


def test_migrate_resolves_env_and_data_files_against_the_project(
tmp_path: Path,
) -> None:
"""The argparse CLI ran migrate inside the project; relative paths meant it."""
fleet = Fleet(EXAMPLES, validate_config(EXAMPLES, SCHEMAS))
args = MigrateArgs(
env_file=("crm-backend=tmp/env/crm.env",),
data=(f"crm={tmp_path / 'source.url'}",),
)

options = args.options(fleet)

assert options.environment_files == {
"crm-backend": EXAMPLES / "tmp/env/crm.env"
}
assert options.data_migrations == {"crm": tmp_path / "source.url"}
Loading