Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 63 additions & 14 deletions internal/cli/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,72 @@ func reason(i detect.Install) string {
return i18n.T(key, "dir", i.Dir, "port", i.Port, "version", orStr(i.Version, i18n.T("detect.versionUnknown")))
}

// foundList is the text that lists the installations found, each one's reason under it.
// foundLine is an installation found on one line: what and where, and why it cannot be
// taken over after a colon when it cannot.
//
// Args:
//
// i: the installation.
//
// Returns:
//
// The line.
func foundLine(i detect.Install) string {
// one found on a port only says "No engine" already
if i.Adoptable() || i.Problem == detect.Unmanaged {
return describe(i)
}
return describe(i) + ": " + i18n.T("detect.short_"+i.Problem)
}

// foundAdvice is what to do about the installations that cannot be taken over: the advice
// of each reason (its lines after the first), each line once. One found on a port only has
// none: the screen's own help already says a new installation could clash with it.
//
// Args:
//
// found: the installations.
//
// Returns:
//
// The text.
func foundList(found []detect.Install) string {
// The lines, none when there is nothing to advise.
func foundAdvice(found []detect.Install) []string {
var lines []string
seen := map[string]bool{}
for _, i := range found {
lines = append(lines, "• "+describe(i))
if r := reason(i); r != "" {
for _, l := range strings.Split(r, "\n") {
lines = append(lines, " "+l)
if i.Adoptable() || i.Problem == detect.Unmanaged {
continue
}
parts := strings.Split(reason(i), "\n")
for _, l := range parts[1:] {
if l = strings.TrimSpace(l); l != "" && !seen[l] {
seen[l] = true
lines = append(lines, l)
}
}
}
return lines
}

// foundList is the text that lists the installations found, one line each, then what to do
// about those that cannot be taken over.
//
// Args:
//
// found: the installations.
//
// Returns:
//
// The text.
func foundList(found []detect.Install) string {
var lines []string
for _, i := range found {
lines = append(lines, "• "+foundLine(i))
}
if advice := foundAdvice(found); len(advice) > 0 {
lines = append(lines, "")
lines = append(lines, advice...)
}
return strings.Join(lines, "\n")
}

Expand Down Expand Up @@ -153,8 +200,8 @@ func offerFound(ctx context.Context, f Flags, found []detect.Install, alongside
var opts []ui.Option
def := "stop"
for n, i := range found {
// one that cannot be taken over is not an option : the list above says why
if !i.Adoptable() {
opts = append(opts, ui.Option{Label: i18n.T("detect.cannot", "what", describe(i)), Value: "no:" + strconv.Itoa(n), Disabled: true})
continue
}
if def == "stop" {
Expand Down Expand Up @@ -290,15 +337,17 @@ func statusFound(ctx context.Context, st *state.State) int {
ui.Heading(i18n.T("detect.unmanagedTitle"))
takeable := false
for _, i := range others {
ui.Line("• " + describe(i))
if r := reason(i); r != "" {
for _, l := range strings.Split(r, "\n") {
ui.Muted(" " + l)
}
} else {
ui.Line("• " + foundLine(i))
if i.Adoptable() {
takeable = true
}
}
if advice := foundAdvice(others); len(advice) > 0 {
ui.Blank()
for _, l := range advice {
ui.Muted(l)
}
}
if takeable && st == nil {
ui.Blank()
ui.Muted(i18n.T("detect.statusAdopt"))
Expand Down
16 changes: 12 additions & 4 deletions internal/i18n/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,28 +272,27 @@
"native.notReady": "El servei {unit} no s'ha iniciat.\nReviseu-ne el registre: journalctl -u {unit}",
"native.noBundle": "AnsibleForms {version} no té cap paquet per a aquest servidor.\nInstal·lar sense contenidors requereix AnsibleForms 7.3.0 o posterior.",
"native.data": "Baixant els formularis, playbooks i configuració inicials",
"detect.looking": "Cercant un AnsibleForms ja present en aquest servidor",
"detect.looking": "Cercant un AnsibleForms ja instal·lat en aquest servidor",
"detect.engine_kubernetes": "Kubernetes",
"detect.engine_systemd": "serveis systemd",
"detect.engine_none": "Sense motor",
"detect.versionUnknown": "versió desconeguda",
"detect.stopped": "aturat",
"detect.databaseMode": "mode base de dades",
"detect.found": "AnsibleForms ja és en aquest servidor, però aquest instal·lador encara no el gestiona:",
"detect.found": "AnsibleForms ja està instal·lat en aquest servidor, però aquest instal·lador encara no el gestiona:",
"detect.foundHelp": "Feu-vos-en càrrec per actualitzar-lo des d'aquí.\nUna segona instal·lació al costat podria xocar en ports, base de dades o carpetes.",
"detect.foundHelpNone": "L'instal·lador no el pot actualitzar: vegeu el motiu a dalt.\nUna segona instal·lació al costat podria xocar en ports, base de dades o carpetes.",
"detect.choose": "Què voleu fer?",
"detect.adopt": "Fer-se'n càrrec i actualitzar: {what}",
"detect.adoptHint": "L'instal·lador recorda on és i com s'executa, i després l'actualitza.\nPrimer fa una còpia de la base de dades i pot tornar enrere.",
"detect.cannot": "No es pot actualitzar des d'aquí: {what}",
"detect.alongside": "Instal·lar igualment un nou AnsibleForms al costat",
"detect.alongsideHint": "Una instal·lació a part, amb la seva pròpia carpeta, ports i base de dades.\nLa trobada es deixa tal com és.",
"detect.alongsideHelp": "Un segon AnsibleForms necessita els seus propis ports, carpeta i base de dades.\nL'instal·lador rebutja una carpeta o noms de contenidor en ús, però no ho pot comprovar tot.",
"detect.alongsideConfirm": "Voleu instal·lar un segon AnsibleForms en aquest servidor?",
"detect.alongsideGo": "Instal·la igualment",
"detect.stop": "Atura",
"detect.stopHint": "No es canvia res.",
"detect.unattended": "AnsibleForms ja és en aquest servidor i l'instal·lador no el gestiona.\nExecuteu l'instal·lador sense --yes per triar què fer.\nSi només se'n troba un, ansibleforms-installer upgrade --yes se'n fa càrrec i l'actualitza.",
"detect.unattended": "AnsibleForms ja està instal·lat en aquest servidor i l'instal·lador no el gestiona.\nExecuteu l'instal·lador sense --yes per triar què fer.\nSi només se'n troba un, ansibleforms-installer upgrade --yes se'n fa càrrec i l'actualitza.",
"detect.cannotAdopt": "S'ha trobat AnsibleForms en aquest servidor, però l'instal·lador no el pot actualitzar: vegeu el motiu a dalt.",
"detect.adoptReview": "L'instal·lador recordarà aquesta instal·lació a {file}:",
"detect.adoptCompose": "L'actualització copia primer la base de dades, docker-compose.yml i .env.\nDesprés substitueix docker-compose.yml pel del repositori ansibleforms/docker.\nEl .env conserva tots els valors; s'hi afegeixen les claus que la nova versió necessita. La carpeta de dades es conserva.",
Expand All @@ -316,6 +315,15 @@
"detect.why_unknownVersion": "No s'ha pogut llegir la seva versió.\nInicieu-lo perquè respongui al seu port i torneu a executar l'instal·lador.",
"detect.why_unmanaged": "AnsibleForms {version} respon al port {port}, però cap motor no el gestiona (executat des del codi o a mà).\nL'instal·lador no el pot actualitzar. Una nova instal·lació podria xocar amb els seus ports o la seva base de dades.",
"detect.why_unmanagedRunner": "Un RTE d'AnsibleForms respon al port {port}, però cap motor no el gestiona (executat des del codi o a mà).\nL'instal·lador no el pot actualitzar. Una nova instal·lació podria xocar amb el seu port.",
"detect.short_notCompose": "no es va iniciar amb Docker Compose",
"detect.short_noComposeFile": "no se'n poden llegir els fitxers de compose",
"detect.short_notRepoLayout": "el seu fitxer compose no és el d'ansibleforms/docker",
"detect.short_externalDb": "la seva base de dades és fora del projecte compose",
"detect.short_runnerLayout": "aquest Runner no el va instal·lar l'instal·lador",
"detect.short_nativeLayout": "la seva carpeta no segueix l'estructura de l'instal·lador",
"detect.short_noHelm": "no és una release del chart Helm d’ansibleforms",
"detect.short_unknownVersion": "no se’n pot llegir la versió",
"detect.short_unmanaged": "cap motor no el gestiona",
"migrate.gone": "El contenidor RTE del Runner de {dir} ja no hi és, així que no es poden llegir el nom ni el testimoni del seu runner.\nTorneu-lo a iniciar, o instal·leu un Runner nou i aproveu-lo a AnsibleForms.",
"migrate.intro": "Aquest Runner funciona en mode base de dades (7.2): el seu RTE té les dades de la base de dades d'AnsibleForms.\nL'actualització el passa a un mode de socket i treu aquestes dades. Continua sent el runner {name}: el nou RTE entra amb el testimoni del runner, i AnsibleForms mou el runner sol, sense aprovació.",
"migrate.nameHelp": "El nom del seu runner a Connexions > Runners, el que aquest RTE va registrar.\nEl nou RTE entra amb aquest nom (RTE_NAME).",
Expand Down
16 changes: 12 additions & 4 deletions internal/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,28 +272,27 @@
"native.notReady": "Der Dienst {unit} ist nicht gestartet.\nPrüfen Sie sein Log: journalctl -u {unit}",
"native.noBundle": "Für AnsibleForms {version} gibt es kein Paket für diesen Server.\nOhne Container ist AnsibleForms 7.3.0 oder neuer erforderlich.",
"native.data": "Lade die Start-Formulare, Playbooks und Einstellungen herunter",
"detect.looking": "Suche nach einem AnsibleForms, das schon auf diesem Server läuft",
"detect.looking": "Suche nach einem AnsibleForms, das schon auf diesem Server installiert ist",
"detect.engine_kubernetes": "Kubernetes",
"detect.engine_systemd": "systemd-Dienste",
"detect.engine_none": "Keine Engine",
"detect.versionUnknown": "Version unbekannt",
"detect.stopped": "gestoppt",
"detect.databaseMode": "Datenbankmodus",
"detect.found": "AnsibleForms ist schon auf diesem Server, wird aber noch nicht von diesem Installer verwaltet:",
"detect.found": "AnsibleForms ist schon auf diesem Server installiert, wird aber noch nicht von diesem Installer verwaltet:",
"detect.foundHelp": "Übernehmen Sie es, um es von hier aus zu aktualisieren.\nEine zweite Installation daneben könnte bei Ports, Datenbank oder Ordnern kollidieren.",
"detect.foundHelpNone": "Der Installer kann es nicht aktualisieren: der Grund steht oben.\nEine zweite Installation daneben könnte bei Ports, Datenbank oder Ordnern kollidieren.",
"detect.choose": "Was möchten Sie tun?",
"detect.adopt": "Übernehmen und aktualisieren: {what}",
"detect.adoptHint": "Der Installer merkt sich, wo es liegt und wie es läuft, und aktualisiert es dann.\nEr sichert zuerst die Datenbank und kann zurückrollen.",
"detect.cannot": "Kann von hier aus nicht aktualisiert werden: {what}",
"detect.alongside": "Trotzdem ein neues AnsibleForms daneben installieren",
"detect.alongsideHint": "Eine eigene Installation, mit eigenem Ordner, eigenen Ports und eigener Datenbank.\nDie gefundene bleibt, wie sie ist.",
"detect.alongsideHelp": "Ein zweites AnsibleForms braucht eigene Ports, einen eigenen Ordner und eine eigene Datenbank.\nDer Installer lehnt belegte Ordner und Containernamen ab, kann aber nicht alles prüfen.",
"detect.alongsideConfirm": "Ein zweites AnsibleForms auf diesem Server installieren?",
"detect.alongsideGo": "Trotzdem installieren",
"detect.stop": "Abbrechen",
"detect.stopHint": "Nichts wird geändert.",
"detect.unattended": "AnsibleForms ist schon auf diesem Server und wird nicht vom Installer verwaltet.\nStarten Sie den Installer ohne --yes, um zu wählen, was geschehen soll.\nWird nur eines gefunden, übernimmt und aktualisiert es ansibleforms-installer upgrade --yes.",
"detect.unattended": "AnsibleForms ist schon auf diesem Server installiert und wird nicht vom Installer verwaltet.\nStarten Sie den Installer ohne --yes, um zu wählen, was geschehen soll.\nWird nur eines gefunden, übernimmt und aktualisiert es ansibleforms-installer upgrade --yes.",
"detect.cannotAdopt": "AnsibleForms wurde auf diesem Server gefunden, aber der Installer kann es nicht aktualisieren: der Grund steht oben.",
"detect.adoptReview": "Der Installer merkt sich diese Installation in {file}:",
"detect.adoptCompose": "Die Aktualisierung sichert zuerst die Datenbank, docker-compose.yml und .env.\nDann ersetzt sie docker-compose.yml durch die des Repositorys ansibleforms/docker.\nDie .env behält jeden Wert; die Schlüssel, die die neue Version braucht, werden ergänzt. Der Datenordner bleibt.",
Expand All @@ -316,6 +315,15 @@
"detect.why_unknownVersion": "Seine Version konnte nicht gelesen werden.\nStarten Sie es, damit es auf seinem Port antwortet, und führen Sie den Installer erneut aus.",
"detect.why_unmanaged": "AnsibleForms {version} antwortet auf Port {port}, aber keine Engine verwaltet es (aus dem Quellcode oder von Hand gestartet).\nDer Installer kann es nicht aktualisieren. Eine neue Installation könnte mit seinen Ports oder seiner Datenbank kollidieren.",
"detect.why_unmanagedRunner": "Ein AnsibleForms-RTE antwortet auf Port {port}, aber keine Engine verwaltet es (aus dem Quellcode oder von Hand gestartet).\nDer Installer kann es nicht aktualisieren. Eine neue Installation könnte mit seinem Port kollidieren.",
"detect.short_notCompose": "nicht mit Docker Compose gestartet",
"detect.short_noComposeFile": "seine Compose-Dateien sind nicht lesbar",
"detect.short_notRepoLayout": "seine Compose-Datei ist nicht die von ansibleforms/docker",
"detect.short_externalDb": "seine Datenbank liegt außerhalb des Compose-Projekts",
"detect.short_runnerLayout": "dieser Runner wurde nicht vom Installer eingerichtet",
"detect.short_nativeLayout": "sein Ordner hat nicht den Aufbau des Installers",
"detect.short_noHelm": "kein Release des ansibleforms-Helm-Charts",
"detect.short_unknownVersion": "seine Version ist nicht lesbar",
"detect.short_unmanaged": "keine Engine verwaltet es",
"migrate.gone": "Der RTE-Container des Runners in {dir} ist weg, daher können Name und Token seines Runners nicht gelesen werden.\nStarten Sie ihn wieder, oder installieren Sie einen neuen Runner und geben Sie ihn in AnsibleForms frei.",
"migrate.intro": "Dieser Runner läuft im Datenbankmodus (7.2): Sein RTE hat die Datenbankeinstellungen von AnsibleForms.\nDie Aktualisierung stellt ihn auf einen Socket-Modus um und entfernt diese Einstellungen. Er bleibt der Runner {name}: Das neue RTE meldet sich mit dem Token des Runners an, und AnsibleForms stellt den Runner selbst um, ohne Freigabe.",
"migrate.nameHelp": "Der Name seines Runners unter Verbindungen > Runner, unter dem sich dieses RTE registriert hat.\nDas neue RTE meldet sich unter diesem Namen an (RTE_NAME).",
Expand Down
16 changes: 12 additions & 4 deletions internal/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,28 +272,27 @@
"native.notReady": "The service {unit} did not start.\nSee its log: journalctl -u {unit}",
"native.noBundle": "AnsibleForms {version} has no bundle for this server.\nInstalling without containers needs AnsibleForms 7.3.0 or later.",
"native.data": "Downloading the starting forms, playbooks and settings",
"detect.looking": "Looking for an AnsibleForms already on this server",
"detect.looking": "Looking for an AnsibleForms already installed on this server",
"detect.engine_kubernetes": "Kubernetes",
"detect.engine_systemd": "systemd services",
"detect.engine_none": "No engine",
"detect.versionUnknown": "version unknown",
"detect.stopped": "stopped",
"detect.databaseMode": "database mode",
"detect.found": "AnsibleForms is already on this server, but this installer does not manage it yet:",
"detect.found": "AnsibleForms is already installed on this server, but this installer does not manage it yet:",
"detect.foundHelp": "Take it over to upgrade it from here.\nA second installation beside it could clash on ports, the database or folders.",
"detect.foundHelpNone": "The installer cannot upgrade it: see why above.\nA second installation beside it could clash on ports, the database or folders.",
"detect.choose": "What do you want to do?",
"detect.adopt": "Take over and upgrade: {what}",
"detect.adoptHint": "The installer remembers where it is and how it runs, then upgrades it.\nIt backs up the database first and can roll back.",
"detect.cannot": "Cannot be upgraded from here: {what}",
"detect.alongside": "Install a new AnsibleForms beside it anyway",
"detect.alongsideHint": "A separate installation, with its own folder, ports and database.\nThe one found is left as it is.",
"detect.alongsideHelp": "A second AnsibleForms needs its own ports, folder and database.\nThe installer refuses a folder or container names in use, but it cannot check everything.",
"detect.alongsideConfirm": "Install a second AnsibleForms on this server?",
"detect.alongsideGo": "Install anyway",
"detect.stop": "Stop",
"detect.stopHint": "Nothing is changed.",
"detect.unattended": "AnsibleForms is already on this server and the installer does not manage it.\nRun the installer without --yes to choose what to do.\nWhen only one is found, ansibleforms-installer upgrade --yes takes it over and upgrades it.",
"detect.unattended": "AnsibleForms is already installed on this server and the installer does not manage it.\nRun the installer without --yes to choose what to do.\nWhen only one is found, ansibleforms-installer upgrade --yes takes it over and upgrades it.",
"detect.cannotAdopt": "AnsibleForms was found on this server, but the installer cannot upgrade it: see why above.",
"detect.adoptReview": "The installer will remember this installation in {file}:",
"detect.adoptCompose": "The upgrade backs up the database, docker-compose.yml and .env first.\nIt then replaces docker-compose.yml with the one of the ansibleforms/docker repository.\nThe .env keeps every value; the keys the new version needs are added. The data folder is kept.",
Expand All @@ -316,6 +315,15 @@
"detect.why_unknownVersion": "Its version could not be read.\nStart it so it answers on its port, then run the installer again.",
"detect.why_unmanaged": "AnsibleForms {version} answers on port {port}, but no engine manages it (run from source or by hand).\nThe installer cannot upgrade it. A new installation could clash with its ports or its database.",
"detect.why_unmanagedRunner": "An AnsibleForms RTE answers on port {port}, but no engine manages it (run from source or by hand).\nThe installer cannot upgrade it. A new installation could clash with its port.",
"detect.short_notCompose": "not started with Docker Compose",
"detect.short_noComposeFile": "its compose files cannot be read",
"detect.short_notRepoLayout": "its compose file is not the ansibleforms/docker one",
"detect.short_externalDb": "its database is outside its compose project",
"detect.short_runnerLayout": "this Runner was not set up by the installer",
"detect.short_nativeLayout": "its folder is not in the installer's layout",
"detect.short_noHelm": "not a release of the ansibleforms Helm chart",
"detect.short_unknownVersion": "its version cannot be read",
"detect.short_unmanaged": "no engine manages it",
"migrate.gone": "The RTE container of the Runner in {dir} is gone, so its runner's name and token cannot be read.\nStart it again, or install a new Runner and approve it in AnsibleForms.",
"migrate.intro": "This Runner runs in database mode (7.2): its RTE holds the database settings of AnsibleForms.\nThe upgrade moves it to a socket mode and drops those settings. It stays the runner {name}: the new RTE signs in with the runner's token, and AnsibleForms moves the runner itself, without an approval.",
"migrate.nameHelp": "The name of its runner under Connections > Runners, the one this RTE registered itself as.\nThe new RTE signs in under this name (RTE_NAME).",
Expand Down
Loading
Loading