@@ -30,12 +30,15 @@ func parseLabelsFromConfig(configMap map[string]any) []string {
3030 return nil
3131}
3232
33- // parseStringFromConfig is a generic helper that extracts and validates a string value from a config map
33+ // extractStringFromMap is a generic helper that extracts and validates a string value from a map
3434// Returns the string value, or empty string if not present or invalid
35- func parseStringFromConfig (configMap map [string ]any , key string ) string {
36- if value , exists := configMap [key ]; exists {
35+ // If log is provided, it will log the extracted value for debugging
36+ func extractStringFromMap (m map [string ]any , key string , log * logger.Logger ) string {
37+ if value , exists := m [key ]; exists {
3738 if valueStr , ok := value .(string ); ok {
38- configHelpersLog .Printf ("Parsed %s from config: %s" , key , valueStr )
39+ if log != nil {
40+ log .Printf ("Parsed %s from config: %s" , key , valueStr )
41+ }
3942 return valueStr
4043 }
4144 }
@@ -45,13 +48,13 @@ func parseStringFromConfig(configMap map[string]any, key string) string {
4548// parseTitlePrefixFromConfig extracts and validates title-prefix from a config map
4649// Returns the title prefix string, or empty string if not present or invalid
4750func parseTitlePrefixFromConfig (configMap map [string ]any ) string {
48- return parseStringFromConfig (configMap , "title-prefix" )
51+ return extractStringFromMap (configMap , "title-prefix" , configHelpersLog )
4952}
5053
5154// parseTargetRepoFromConfig extracts the target-repo value from a config map.
5255// Returns the target repository slug as a string, or empty string if not present or invalid.
5356// This function does not perform any special handling or validation for wildcard values ("*");
5457// callers are responsible for validating the returned value as needed.
5558func parseTargetRepoFromConfig (configMap map [string ]any ) string {
56- return parseStringFromConfig (configMap , "target-repo" )
59+ return extractStringFromMap (configMap , "target-repo" , configHelpersLog )
5760}
0 commit comments