@@ -648,14 +648,10 @@ Collection<Container> getInitContainers(Map<String, String> kubernetesDeployerPr
648
648
}
649
649
650
650
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" );
656
653
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" );
659
655
List <String > commands = StringUtils .hasText (commandStr ) ? Arrays .asList (commandStr .split ("," )) : Collections .emptyList ();
660
656
String envString = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".env" );
661
657
envString = StringUtils .hasText (envString ) ? envString : PropertyParserUtils .getDeploymentPropertyValue (kubeProps , propertyKey + ".environmentVariables" );
@@ -672,6 +668,16 @@ Collection<Container> getInitContainers(Map<String, String> kubernetesDeployerPr
672
668
return null ;
673
669
}
674
670
671
+ public static String getFirstProperty (Map <String , String > kubeProps , String baseKey , String ... suffixes ) {
672
+ for (String suffix : suffixes ) {
673
+ String value = PropertyParserUtils .getDeploymentPropertyValue (kubeProps , baseKey + suffix );
674
+ if (StringUtils .hasText (value )) {
675
+ return value ;
676
+ }
677
+ }
678
+ return null ;
679
+ }
680
+
675
681
private Container containerFromProps (InitContainer initContainerProps ) {
676
682
return new ContainerBuilder ()
677
683
.withName (initContainerProps .getName ())
0 commit comments