Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[cli] By default, update sub to high storage & expiry

Neeraj Guptab164b0df21f3
diff --git a/cli/cmd/admin.go b/cli/cmd/admin.go
index 153736624c..7836528787 100644
--- a/cli/cmd/admin.go
+++ b/cli/cmd/admin.go
@@ -6,6 +6,7 @@ import (
"github.com/ente-io/cli/pkg/model"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
+ "strings"
)
var _adminCmd = &cobra.Command{
@@ -57,6 +58,7 @@ var _updateFreeUserStorage = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
recoverWithLog()
var flags = &model.AdminActionForUser{}
+ noLimit := false
cmd.Flags().VisitAll(func(f *pflag.Flag) {
if f.Name == "admin-user" {
flags.AdminEmail = f.Value.String()
@@ -64,8 +66,11 @@ var _updateFreeUserStorage = &cobra.Command{
if f.Name == "user" {
flags.UserEmail = f.Value.String()
}
+ if f.Name == "no-limit" {
+ noLimit = strings.ToLower(f.Value.String()) == "true"
+ }
})
- return ctrl.UpdateFreeStorage(context.Background(), *flags)
+ return ctrl.UpdateFreeStorage(context.Background(), *flags, noLimit)
},
}
@@ -79,5 +84,7 @@ func init() {
_disable2faCmd.Flags().StringP("user", "u", "", "The email of the user to disable 2FA for. (required)")
_updateFreeUserStorage.Flags().StringP("admin-user", "a", "", "The email of the admin user. (required)")
_updateFreeUserStorage.Flags().StringP("user", "u", "", "The email of the user to update subscription for. (required)")
+ // add a flag with no value --no-limit
+ _updateFreeUserStorage.Flags().String("no-limit", "True", "Set the storage limit to 100TB unlimited with 100 year expiry")
_adminCmd.AddCommand(_userDetailsCmd, _disable2faCmd, _updateFreeUserStorage)
}
diff --git a/cli/config.yaml.example b/cli/config.yaml.example
index efd92c545c..a004036568 100644
--- a/cli/config.yaml.example
+++ b/cli/config.yaml.example
@@ -4,7 +4,7 @@
# - $ENTE_CLI_CONFIG_PATH/config.yaml
endpoint:
- api: "https://api.ente.io"
+ api: "http://localhost:8080"
log:
- http: false # log http requests and responses
\ No newline at end of file
+ http: false # log status code & time taken by requests
diff --git a/cli/pkg/admin_actions.go b/cli/pkg/admin_actions.go
index 74152e5c54..c9ec006675 100644
--- a/cli/pkg/admin_actions.go
+++ b/cli/pkg/admin_actions.go
@@ -24,7 +24,7 @@ func (c *ClICtrl) GetUserId(ctx context.Context, params model.AdminActionForUser
return nil
}
-func (c *ClICtrl) UpdateFreeStorage(ctx context.Context, params model.AdminActionForUser) error {
+func (c *ClICtrl) UpdateFreeStorage(ctx context.Context, params model.AdminActionForUser, noLimit bool) error {
accountCtx, err := c.buildAdminContext(ctx, params.AdminEmail)
if err != nil {
return err
@@ -33,6 +33,16 @@ func (c *ClICtrl) UpdateFreeStorage(ctx context.Context, params model.AdminActio
if err != nil {
return err
}
+ if noLimit {
+ // set storage to 100TB and expiry to + 100 years
+ err := c.Client.UpdateFreePlanSub(accountCtx, userDetails, 100*1024*1024*1024*1024, time.Now().AddDate(100, 0, 0).UnixMicro())
+ if err != nil {
+ return err
+ } else {
+ fmt.Println("Successfully updated storage and expiry date for user")
+ }
+ return nil
+ }
storageSize, err := internal.GetStorageSize("Enter a storage size (e.g.'5MB', '10GB', '2Tb'): ")
if err != nil {
log.Fatalf("Error: %v", err)