From 481f0a1282add78c75c7e3f320698b5a1b9eb887 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 12 Aug 2021 14:54:46 +0200 Subject: [PATCH] fix(getConfig): custom metadata (#3047) * fix(getConfig): custom metadata when re-using getConfig it is now possible to provide a custom metadata resolver * clean up coding --- cmd/getConfig.go | 5 ++++- cmd/piper.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/getConfig.go b/cmd/getConfig.go index 59288baa6..ae0f698f4 100644 --- a/cmd/getConfig.go +++ b/cmd/getConfig.go @@ -240,7 +240,10 @@ func resolveMetadata() (config.StepData, error) { } } else { if configOptions.stepName != "" { - metadataMap := GetAllStepMetadata() + if GeneralConfig.MetaDataResolver == nil { + GeneralConfig.MetaDataResolver = GetAllStepMetadata + } + metadataMap := GeneralConfig.MetaDataResolver() var ok bool metadata, ok = metadataMap[configOptions.stepName] if !ok { diff --git a/cmd/piper.go b/cmd/piper.go index 500ee780a..91230d2a2 100644 --- a/cmd/piper.go +++ b/cmd/piper.go @@ -41,6 +41,7 @@ type GeneralConfigOptions struct { VaultNamespace string VaultPath string HookConfig HookConfiguration + MetaDataResolver func() map[string]config.StepData } // HookConfiguration contains the configuration for supported hooks, so far Sentry and Splunk are supported.