@@ -648,18 +648,12 @@ Collection<Container> getInitContainers(Map<String, String> kubernetesDeployerPr
648648 }
649649
650650 private @ Nullable Container initContainerFromProperties (Map <String , String > kubeProps , String propertyKey ) {
651- String name = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".name" );
652- name = StringUtils .hasText (name ) ? name : PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".containerName" );
653- String image = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".image" );
654- image = StringUtils .hasText (image ) ? image : PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".imageName" );
655-
651+ String name = getFirstProperty (kubeProps , propertyKey , ".name" , ".containerName" );
652+ String image = getFirstProperty (kubeProps , propertyKey , ".image" , ".imageName" );
656653 if (StringUtils .hasText (name ) && StringUtils .hasText (image )) {
657- String commandStr = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".command" );
658- commandStr = StringUtils .hasText (commandStr ) ? commandStr : PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".commands" );
654+ String commandStr = getFirstProperty (kubeProps , propertyKey , ".command" , ".commands" );
659655 List <String > commands = StringUtils .hasText (commandStr ) ? Arrays .asList (commandStr .split ("," )) : Collections .emptyList ();
660- String envString = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".env" );
661- envString = StringUtils .hasText (envString ) ? envString : PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".environmentVariables" );
662-
656+ String envString = getFirstProperty (kubeProps , propertyKey , ".env" , ".environmentVariables" );
663657 List <VolumeMount > vms = this .getInitContainerVolumeMounts (kubeProps , propertyKey );
664658 return new ContainerBuilder ()
665659 .withName (name )
@@ -672,6 +666,16 @@ Collection<Container> getInitContainers(Map<String, String> kubernetesDeployerPr
672666 return null ;
673667 }
674668
669+ public static String getFirstProperty (Map <String , String > kubeProps , String baseKey , String ... suffixes ) {
670+ for (String suffix : suffixes ) {
671+ String value = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , baseKey + suffix );
672+ if (StringUtils .hasText (value )) {
673+ return value ;
674+ }
675+ }
676+ return null ;
677+ }
678+
675679 private Container containerFromProps (InitContainer initContainerProps ) {
676680 return new ContainerBuilder ()
677681 .withName (initContainerProps .getName ())
0 commit comments