@@ -22,7 +22,6 @@ package component
2222import (
2323 "fmt"
2424 "reflect"
25- "strings"
2625
2726 "golang.org/x/crypto/bcrypt"
2827 "golang.org/x/exp/maps"
@@ -219,25 +218,12 @@ func (t *componentAccountTransformer) buildPassword(ctx *componentTransformConte
219218 password = []byte (factory .GetRestorePassword (ctx .SynthesizeComponent ))
220219 }
221220 if len (password ) == 0 {
222- return t .generatePassword (account ), nil
221+ password , err := common .GeneratePasswordByConfig (account .PasswordGenerationPolicy )
222+ return []byte (password ), err
223223 }
224224 return password , nil
225225}
226226
227- func (t * componentAccountTransformer ) generatePassword (account synthesizedSystemAccount ) []byte {
228- config := account .PasswordGenerationPolicy
229- passwd , _ := common .GeneratePassword ((int )(config .Length ), (int )(config .NumDigits ), (int )(config .NumSymbols ), config .Seed )
230- switch config .LetterCase {
231- case appsv1 .UpperCases :
232- passwd = strings .ToUpper (passwd )
233- case appsv1 .LowerCases :
234- passwd = strings .ToLower (passwd )
235- case appsv1 .MixedCases :
236- passwd , _ = common .EnsureMixedCase (passwd , config .Seed )
237- }
238- return []byte (passwd )
239- }
240-
241227func (t * componentAccountTransformer ) buildAccountSecretWithPassword (ctx * componentTransformContext ,
242228 synthesizeComp * component.SynthesizedComponent , account synthesizedSystemAccount , password []byte ) (* corev1.Secret , error ) {
243229 secretName := constant .GenerateAccountSecretName (synthesizeComp .ClusterName , synthesizeComp .Name , account .Name )
0 commit comments