@@ -92,9 +92,14 @@ func (impl *PluginInputVariableParserImpl) HandleCopyContainerImagePluginInputVa
92
92
dockerImageTag = pluginTriggerImageSplit [len (pluginTriggerImageSplit )- 1 ]
93
93
}
94
94
95
- registryRepoMapping := impl .getRegistryRepoMapping (DestinationInfo )
95
+ registryRepoMapping , err := impl .getRegistryRepoMapping (DestinationInfo )
96
+ if err != nil {
97
+ impl .logger .Errorw ("error in getting registry repo mapping" , "DestinationInfo" , DestinationInfo , "err" , err )
98
+ return nil , nil , err
99
+ }
96
100
registryCredentials , err = impl .getRegistryDetails (registryRepoMapping , sourceImageDockerRegistry )
97
101
if err != nil {
102
+ impl .logger .Errorw ("error in getting registry details" , "err" , err )
98
103
return nil , nil , err
99
104
}
100
105
registryDestinationImageMap = impl .getRegistryDestinationImageMapping (registryRepoMapping , dockerImageTag , registryCredentials )
@@ -108,7 +113,7 @@ func (impl *PluginInputVariableParserImpl) HandleCopyContainerImagePluginInputVa
108
113
return registryDestinationImageMap , registryCredentials , nil
109
114
}
110
115
111
- func (impl * PluginInputVariableParserImpl ) getRegistryRepoMapping (destinationInfo string ) map [string ][]string {
116
+ func (impl * PluginInputVariableParserImpl ) getRegistryRepoMapping (destinationInfo string ) ( map [string ][]string , error ) {
112
117
/*
113
118
creating map with registry as key and list of repositories in that registry where we need to copy image
114
119
destinationInfo format (each registry detail is separated by new line) :
@@ -119,6 +124,11 @@ func (impl *PluginInputVariableParserImpl) getRegistryRepoMapping(destinationInf
119
124
destinationRegistryRepoDetails := strings .Split (destinationInfo , "\n " )
120
125
for _ , detail := range destinationRegistryRepoDetails {
121
126
registryRepoSplit := strings .Split (detail , "|" )
127
+ if len (registryRepoSplit ) != 2 {
128
+ impl .logger .Errorw ("invalid destination info format" , "destinationInfo" , destinationInfo )
129
+ // skipping for invalid format
130
+ return destinationRegistryRepositoryMap , errors .New ("invalid destination info format. Please provide it in <registry-1> | <repo1>,<repo2>" )
131
+ }
122
132
registryName := strings .Trim (registryRepoSplit [0 ], EMPTY_STRING )
123
133
repositoryValuesSplit := strings .Split (registryRepoSplit [1 ], "," )
124
134
var repositories []string
@@ -128,7 +138,7 @@ func (impl *PluginInputVariableParserImpl) getRegistryRepoMapping(destinationInf
128
138
}
129
139
destinationRegistryRepositoryMap [registryName ] = repositories
130
140
}
131
- return destinationRegistryRepositoryMap
141
+ return destinationRegistryRepositoryMap , nil
132
142
}
133
143
134
144
func (impl * PluginInputVariableParserImpl ) getRegistryDetails (destinationRegistryRepositoryMap map [string ][]string , sourceRegistry string ) (map [string ]bean2.RegistryCredentials , error ) {
0 commit comments