dump plugin: add option to capture current env

This patch adds the option --resolve-env to the dump plugin.
When enabled, all variables in the 'env' section of the kas config file
are set to the captured value (at time of executing the dump plugin).

This helps to debug build issues on CI runners by precisely capturing
the relevant environment.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer 2022-12-11 08:30:33 +01:00 committed by Jan Kiszka
parent 33250866ec
commit 20a69016da

View File

@ -105,6 +105,9 @@ class Dump(Checkout):
parser.add_argument('--resolve-refs',
action='store_true',
help='Replace floating refs with exact SHAs')
parser.add_argument('--resolve-env',
action='store_true',
help='Set env defaults to captured env value')
def run(self, args):
args.skip += [
@ -128,6 +131,9 @@ class Dump(Checkout):
if r.refspec:
config_expanded['repos'][r.name]['refspec'] = r.revision
if args.resolve_env and 'env' in config_expanded:
config_expanded['env'] = ctx.config.get_environment()
if args.format == 'json':
json.dump(config_expanded, sys.stdout, indent=args.indent)
sys.stdout.write('\n')