Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.4:ARM
salt.28025
save-log-to-logfile-with-docker.build.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File save-log-to-logfile-with-docker.build.patch of Package salt.28025
From c70db2e50599339118c9bf00c69f5cd38ef220bb Mon Sep 17 00:00:00 2001 From: Vladimir Nadvornik <nadvornik@suse.cz> Date: Mon, 27 Jun 2022 17:00:58 +0200 Subject: [PATCH] Save log to logfile with docker.build --- salt/modules/dockermod.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index e6b81e7f09..1f871b40cf 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -3990,6 +3990,7 @@ def build( fileobj=None, dockerfile=None, buildargs=None, + logfile=None, ): """ .. versionchanged:: 2018.3.0 @@ -4043,6 +4044,9 @@ def build( buildargs A dictionary of build arguments provided to the docker build process. + logfile + Path to log file. Output from build is written to this file if not None. + **RETURN DATA** @@ -4117,6 +4121,20 @@ def build( stream_data = [] for line in response: stream_data.extend(salt.utils.json.loads(line, cls=DockerJSONDecoder)) + + if logfile: + try: + with salt.utils.files.fopen(logfile, "a") as f: + for item in stream_data: + try: + item_type = next(iter(item)) + except StopIteration: + continue + if item_type == "stream": + f.write(item[item_type]) + except OSError: + log.error("Unable to write logfile '%s'", logfile) + errors = [] # Iterate through API response and collect information for item in stream_data: -- 2.36.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor