WIP: feat: translation support
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
See #483
This commit is contained in:
@ -2,12 +2,12 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
@ -16,10 +16,10 @@ import (
|
||||
)
|
||||
|
||||
var AppRemoveCommand = &cobra.Command{
|
||||
Use: "remove <domain> [flags]",
|
||||
Aliases: []string{"rm"},
|
||||
Short: "Remove all app data, locally and remotely",
|
||||
Long: `Remove everything related to an app which is already undeployed.
|
||||
Use: i18n.G("remove <domain> [flags]"),
|
||||
Aliases: []string{i18n.G("rm")},
|
||||
Short: i18n.G("Remove all app data, locally and remotely"),
|
||||
Long: i18n.G(`Remove everything related to an app which is already undeployed.
|
||||
|
||||
By default, it will prompt for confirmation before proceeding. All secrets,
|
||||
volumes and the local app env file will be deleted.
|
||||
@ -34,8 +34,8 @@ Please note, if you delete the local app env file without removing volumes and
|
||||
secrets first, Abra will *not* be able to help you remove them afterwards.
|
||||
|
||||
To delete everything without prompt, use the "--force/-f" or the "--no-input/n"
|
||||
flag.`,
|
||||
Example: " abra app remove 1312.net",
|
||||
flag.`),
|
||||
Example: i18n.G(" abra app remove 1312.net"),
|
||||
Args: cobra.ExactArgs(1),
|
||||
ValidArgsFunction: func(
|
||||
cmd *cobra.Command,
|
||||
@ -47,16 +47,16 @@ flag.`,
|
||||
app := internal.ValidateApp(args)
|
||||
|
||||
if !internal.Force && !internal.NoInput {
|
||||
log.Warnf("ALERTA ALERTA: deleting %s data and config (local/remote)", app.Name)
|
||||
log.Warn(i18n.G("ALERTA ALERTA: deleting %s data and config (local/remote)", app.Name))
|
||||
|
||||
response := false
|
||||
prompt := &survey.Confirm{Message: "are you sure?"}
|
||||
prompt := &survey.Confirm{Message: i18n.G("are you sure?")}
|
||||
if err := survey.AskOne(prompt, &response); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !response {
|
||||
log.Fatal("aborting as requested")
|
||||
log.Fatal(i18n.G("aborting as requested"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ flag.`,
|
||||
log.Fatal(err)
|
||||
}
|
||||
if deployMeta.IsDeployed {
|
||||
log.Fatalf("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name)
|
||||
log.Fatal(i18n.G("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name))
|
||||
}
|
||||
|
||||
fs, err := app.Filters(false, false)
|
||||
@ -86,12 +86,12 @@ flag.`,
|
||||
|
||||
if len(configNames) > 0 {
|
||||
if err := client.RemoveConfigs(cl, context.Background(), configNames, internal.Force); err != nil {
|
||||
log.Fatalf("removing configs failed: %s", err)
|
||||
log.Fatal(i18n.G("removing configs failed: %s", err))
|
||||
}
|
||||
|
||||
log.Infof("%d config(s) removed successfully", len(configNames))
|
||||
log.Info(i18n.G("%d config(s) removed successfully", len(configNames)))
|
||||
} else {
|
||||
log.Info("no configs to remove")
|
||||
log.Info(i18n.G("no configs to remove"))
|
||||
}
|
||||
|
||||
secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: fs})
|
||||
@ -113,10 +113,10 @@ flag.`,
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Info(fmt.Sprintf("secret: %s removed", name))
|
||||
log.Info(i18n.G("secret: %s removed", name))
|
||||
}
|
||||
} else {
|
||||
log.Info("no secrets to remove")
|
||||
log.Info(i18n.G("no secrets to remove"))
|
||||
}
|
||||
|
||||
fs, err = app.Filters(false, true)
|
||||
@ -133,28 +133,28 @@ flag.`,
|
||||
if len(volumeNames) > 0 {
|
||||
err := client.RemoveVolumes(cl, context.Background(), volumeNames, internal.Force, 5)
|
||||
if err != nil {
|
||||
log.Fatalf("removing volumes failed: %s", err)
|
||||
log.Fatal(i18n.G("removing volumes failed: %s", err))
|
||||
}
|
||||
|
||||
log.Infof("%d volume(s) removed successfully", len(volumeNames))
|
||||
log.Info(i18n.G("%d volume(s) removed successfully", len(volumeNames)))
|
||||
} else {
|
||||
log.Info("no volumes to remove")
|
||||
log.Info(i18n.G("no volumes to remove"))
|
||||
}
|
||||
|
||||
if err = os.Remove(app.Path); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("file: %s removed", app.Path))
|
||||
log.Info(i18n.G("file: %s removed", app.Path))
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
AppRemoveCommand.Flags().BoolVarP(
|
||||
&internal.Force,
|
||||
"force",
|
||||
"f",
|
||||
i18n.G("force"),
|
||||
i18n.G("f"),
|
||||
false,
|
||||
"perform action without further prompt",
|
||||
i18n.G("perform action without further prompt"),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user