@@ -37,7 +37,6 @@ func Cmd() *cobra.Command {
3737 CmdUpdate (),
3838 CmdRegenerate (),
3939 CmdCredentials (),
40- CmdPasswd (),
4140 CmdDelete (),
4241 CmdStatus (),
4342 CmdList (),
@@ -105,28 +104,6 @@ func CmdCredentials() *cobra.Command {
105104 return cmd
106105}
107106
108- // CmdPasswd returns a CLI command
109- func CmdPasswd () * cobra.Command {
110- cmd := & cobra.Command {
111- Use : "passwd <noobaa-account-name>" ,
112- Short : "reset password for noobaa account" ,
113- Run : RunPasswd ,
114- }
115- cmd .Flags ().String (
116- "old-password" , "" ,
117- `Old Password for authentication - the best practice is to **omit this flag**, in that case the CLI will prompt to prompt and read it securely from the terminal to avoid leaking secrets in the shell history` ,
118- )
119- cmd .Flags ().String (
120- "new-password" , "" ,
121- `New Password for authentication - the best practice is to **omit this flag**, in that case the CLI will prompt to prompt and read it securely from the terminal to avoid leaking secrets in the shell history` ,
122- )
123- cmd .Flags ().String (
124- "retype-new-password" , "" ,
125- `Retype new Password for authentication - the best practice is to **omit this flag**, in that case the CLI will prompt to prompt and read it securely from the terminal to avoid leaking secrets in the shell history` ,
126- )
127- return cmd
128- }
129-
130107// CmdDelete returns a CLI command
131108func CmdDelete () * cobra.Command {
132109 cmd := & cobra.Command {
@@ -285,8 +262,16 @@ func RunUpdate(cmd *cobra.Command, args []string) {
285262 noobaaAccount .Name = name
286263 noobaaAccount .Namespace = options .Namespace
287264
288- isResourceBackingStore := checkResourceBackingStore (newDefaultResource )
289- isResourceNamespaceStore := checkResourceNamespaceStore (newDefaultResource )
265+ sysClient , err := system .Connect (true )
266+ if err != nil {
267+ log .Fatalf ("❌ failed to run RPC call: %s" , err )
268+ }
269+
270+ _ , err = sysClient .NBClient .ReadPoolAPI (nb.ReadPoolParams {Name : newDefaultResource })
271+ isResourceBackingStore := err == nil
272+
273+ _ , err = sysClient .NBClient .ReadNamespaceResourceAPI (nb.ReadNamespaceResourceParams {Name : newDefaultResource })
274+ isResourceNamespaceStore := err == nil
290275
291276 if isResourceBackingStore && isResourceNamespaceStore {
292277 log .Fatalf (`❌ got BackingStore and NamespaceStore %q in namespace %q` ,
@@ -436,53 +421,6 @@ func RunCredentials(cmd *cobra.Command, args []string) {
436421 }
437422}
438423
439- // RunPasswd runs a CLI command
440- func RunPasswd (cmd * cobra.Command , args []string ) {
441- log := util .Logger ()
442-
443- if len (args ) != 1 || args [0 ] == "" {
444- log .Fatalf (`❌ Missing expected arguments: <noobaa-account-name> %s` , cmd .UsageString ())
445- }
446-
447- name := args [0 ]
448-
449- oldPassword := util .GetFlagStringOrPromptPassword (cmd , "old-password" )
450- newPassword := util .GetFlagStringOrPromptPassword (cmd , "new-password" )
451- retypeNewPassword := util .GetFlagStringOrPromptPassword (cmd , "retype-new-password" )
452-
453- secret := util .KubeObject (bundle .File_deploy_internal_secret_empty_yaml ).(* corev1.Secret )
454-
455- if name == "admin@noobaa.io" {
456- secret .Name = "noobaa-admin"
457- } else {
458- secret .Name = fmt .Sprintf ("noobaa-account-%s" , name )
459- }
460- secret .Namespace = options .Namespace
461- if ! util .KubeCheck (secret ) {
462- log .Fatalf (`❌ Could not find secret: %s, will not reset password` , secret .Name )
463- }
464-
465- if oldPassword != secret .StringData ["password" ] {
466- log .Fatalf (`❌ Password is incorrect, aborting.` )
467- }
468-
469- err := ResetPassword (name , oldPassword , newPassword , retypeNewPassword )
470- if err != nil {
471- log .Fatalf (`❌ Could not reset password for %q: %v` , name , err )
472- }
473-
474- secret .StringData = map [string ]string {}
475- secret .StringData ["password" ] = newPassword
476-
477- //If we will not be able to update the secret we will print the credentials as they allready been changed by the RPC
478- if ! util .KubeUpdate (secret ) {
479- log .Fatalf (`❌ Failed to update the secret %s with the new password, please write it down.` , secret .Name )
480- }
481-
482- log .Printf ("✅ Successfully reset the password for the account %q" , name )
483-
484- }
485-
486424// RunDelete runs a CLI command
487425func RunDelete (cmd * cobra.Command , args []string ) {
488426
@@ -877,47 +815,6 @@ func ValidateAccessKeys(accessKeys nb.S3AccessKeys) {
877815 }
878816}
879817
880- // ResetPassword reset noobaa account password
881- func ResetPassword (name string , oldPassword string , newPassword string , retypeNewPassword string ) error {
882- sysClient , err := system .Connect (true )
883- if err != nil {
884- return err
885- }
886-
887- PasswordResstrictions (oldPassword , newPassword , retypeNewPassword )
888-
889- err = sysClient .NBClient .ResetPasswordAPI (nb.ResetPasswordParams {
890- Email : name ,
891- VerificationPassword : nb .MaskedString (oldPassword ),
892- Password : nb .MaskedString (newPassword ),
893- })
894- if err != nil {
895- return err
896- }
897-
898- return nil
899- }
900-
901- // PasswordResstrictions checks for all kind of password restrictions
902- func PasswordResstrictions (oldPassword string , newPassword string , retypeNewPassword string ) {
903- log := util .Logger ()
904-
905- //Checking that we did not get the same password as the old one
906- if newPassword == oldPassword {
907- log .Fatalf (`❌ The password cannot match the old password, aborting.` )
908- }
909-
910- //Checking that we got the same password twice
911- if newPassword != retypeNewPassword {
912- log .Fatalf (`❌ The password and is not matching the retype, aborting.` )
913- }
914-
915- //TODO... This is the place for adding more restrictions
916- // length of password
917- // charecters
918-
919- }
920-
921818// checkResourceBackingStore checks if a resourceName exists and if BackingStore
922819func checkResourceBackingStore (resourceName string ) bool {
923820 // check that a backing store exists
0 commit comments