generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch logs from inside the build instance (#87)
* feat: fetch logs from inside the build instance One could argue that this a bugfix since this was missing behavior from the existing craft tools. Regardless, this commit updates the instance() method in the default ProviderService to fetch the logfile from inside the build instance once its done. The contents of this file are then emitted so that they can end up in the logs of the "outer" instance. Fixes #59
- Loading branch information
Showing
6 changed files
with
219 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file is part of craft_application. | ||
# | ||
# Copyright 2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Utility functions and helpers related to path handling.""" | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from craft_application import AppMetadata | ||
|
||
|
||
def get_managed_logpath(app: AppMetadata) -> pathlib.PosixPath: | ||
"""Get the path to the logfile inside a build instance. | ||
Note that this always returns a PosixPath, as it refers to a path inside of | ||
a Linux-based build instance. | ||
""" | ||
return pathlib.PosixPath( | ||
f"/tmp/{app.name}.log" # noqa: S108 - only applies inside managed instance. | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file is part of craft-application. | ||
# | ||
# Copyright 2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""Tests for internal path utilities.""" | ||
import pathlib | ||
|
||
from craft_application import util | ||
|
||
|
||
def test_get_managed_logpath(app_metadata): | ||
logpath = util.get_managed_logpath(app_metadata) | ||
|
||
assert isinstance(logpath, pathlib.PosixPath) | ||
assert str(logpath) == "/tmp/testcraft.log" |