@@ -403,37 +403,25 @@ func (r *TobikoReconciler) PrepareTobikoEnvVars(
403403 }
404404
405405 // Prepare custom data
406- customData := make (map [string ]string )
407- customData ["tobiko.conf" ] = instance .Spec .Config
408-
409- privateKeyData := make (map [string ]string )
410- privateKeyData ["id_ecdsa" ] = instance .Spec .PrivateKey
411-
412- publicKeyData := make (map [string ]string )
413- publicKeyData ["id_ecdsa.pub" ] = instance .Spec .PublicKey
406+ templateSpecs := []struct {
407+ infix string
408+ key string
409+ value string
410+ }{
411+ {"-tobiko-config-" , "tobiko.conf" , instance .Spec .Config },
412+ {"-tobiko-private-key-" , "id_ecdsa" , instance .Spec .PrivateKey },
413+ {"-tobiko-public-key-" , "id_ecdsa.pub" , instance .Spec .PublicKey },
414+ }
414415
415- cms := []util.Template {
416- {
417- Name : instance .Name + "tobiko-config" ,
418- Namespace : instance .Namespace ,
419- InstanceType : instance .Kind ,
420- Labels : labels ,
421- CustomData : customData ,
422- },
423- {
424- Name : instance .Name + "tobiko-private-key" ,
416+ cms := make ([]util.Template , 0 , len (templateSpecs ))
417+ for _ , spec := range templateSpecs {
418+ cms = append (cms , util.Template {
419+ Name : GetConfigMapName (instance , spec .infix , workflowStepIndex ),
425420 Namespace : instance .Namespace ,
426421 InstanceType : instance .Kind ,
427422 Labels : labels ,
428- CustomData : privateKeyData ,
429- },
430- {
431- Name : instance .Name + "tobiko-public-key" ,
432- Namespace : instance .Namespace ,
433- InstanceType : instance .Kind ,
434- Labels : labels ,
435- CustomData : publicKeyData ,
436- },
423+ CustomData : map [string ]string {spec .key : spec .value },
424+ })
437425 }
438426
439427 err := configmap .EnsureConfigMaps (ctx , helper , instance , cms , nil )
@@ -443,3 +431,8 @@ func (r *TobikoReconciler) PrepareTobikoEnvVars(
443431
444432 return envVars
445433}
434+
435+ // GetConfigMapName returns the name of the custom data ConfigMap for the given workflow step
436+ func GetConfigMapName (instance * testv1beta1.Tobiko , infix string , workflowStepIndex int ) string {
437+ return instance .Name + infix + strconv .Itoa (workflowStepIndex )
438+ }
0 commit comments