@@ -852,13 +852,15 @@ func CustomizeServiceAccount(sa *corev1.ServiceAccount, ba common.BaseComponent,
852852 sa .Labels = ba .GetLabels ()
853853 sa .Annotations = MergeMaps (sa .Annotations , ba .GetAnnotations ())
854854
855- psr := ba .GetStatus ().GetReferences ()[common .StatusReferencePullSecretName ]
855+ psr := strings . TrimSpace ( ba .GetStatus ().GetReferences ()[common .StatusReferencePullSecretName ])
856856 pullSecrets := Set (DecodeStringToList (psr ))
857857 crPullSecrets := []string {}
858+ crPullSecretString := ""
858859 if ba .GetPullSecret () != nil {
859- crPullSecrets = Set (DecodeStringToList (* ba .GetPullSecret ()))
860+ crPullSecretString = strings .TrimSpace (* ba .GetPullSecret ())
861+ crPullSecrets = Set (DecodeStringToList (crPullSecretString ))
860862 }
861- if psr != "" && (ba .GetPullSecret () == nil || * ba . GetPullSecret () != psr ) {
863+ if psr != "" && (ba .GetPullSecret () == nil || crPullSecretString != psr ) {
862864 // There is a reference to a pull secret but it doesn't match the one
863865 // from the CR (which is empty or different)
864866 // so delete the refered pull secret from the service account
@@ -1996,7 +1998,15 @@ func EncodeListToString(arr []string) string {
19961998
19971999// Decodes a comma-separated into a string list
19982000func DecodeStringToList (commaSeparatedString string ) []string {
1999- return strings .Split (string (commaSeparatedString ), "," )
2001+ commaSeparatedString = strings .TrimSpace (commaSeparatedString )
2002+ if commaSeparatedString == "" {
2003+ return []string {}
2004+ }
2005+ arr := strings .Split (string (commaSeparatedString ), "," )
2006+ for i := range len (arr ) {
2007+ arr [i ] = strings .TrimSpace (arr [i ])
2008+ }
2009+ return arr
20002010}
20012011
20022012// Returns true if set A and B are equivalent
0 commit comments