Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing localization strings #246

Merged
merged 1 commit into from
Apr 17, 2024
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
2 changes: 1 addition & 1 deletion check_localizable
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

grep -r . --include '*.go' --exclude '*_test.go' -n -e 'fmt\.Errorf("[^"]\+"' -e 'errors.New("[^"]\+"' -e '\(Fatal\|Error\|Info\|Warn\)()\(.Err(err)\?\).Msgf\?("'
grep -r . --include '*.go' --exclude '*_test.go' -n -e 'fmt\.Errorf("[^"]\+"' -e 'errors.New("[^"]\+"' -e '\(Fatal\|Error\|Info\|Warn\)()\(\.Err(err)\)\?\.Msgf\?("' -e '\.Flags()\.\(String\|Int\|Bool\)\(Slice\)\?\(Var\)\?P\?([^)]\+, \+"[^"]\+")'

if test $? -eq 0; then
echo "Fix the non localizable strings"
Expand Down
6 changes: 3 additions & 3 deletions mgradm/cmd/gpg/add/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command {
},
}

gpgAddKeyCmd.Flags().BoolP("force", "f", false, "Run the import")
gpgAddKeyCmd.Flags().BoolP("force", "f", false, L("Run the import"))
utils.AddBackendFlag(gpgAddKeyCmd)
return gpgAddKeyCmd
}
Expand Down Expand Up @@ -104,14 +104,14 @@ func gpgAddKeys(globalFlags *types.GlobalFlags, flags *gpgAddFlags, cmd *cobra.C
gpgAddCmd = append(gpgAddCmd, containerKeyPath)
}

log.Info().Msgf("Running: %s", strings.Join(gpgAddCmd, " "))
log.Info().Msgf(L("Running: %s"), strings.Join(gpgAddCmd, " "))
if err := adm_utils.ExecCommand(zerolog.InfoLevel, cnx, gpgAddCmd...); err != nil {
return fmt.Errorf(L("failed to run import key: %s"), err)
}

//this is for running import-suma-build-keys, who import customer-build-keys.gpg
uyuniUpdateCmd := []string{"systemctl", "restart", "uyuni-update-config"}
log.Info().Msgf("Running: %s", strings.Join(uyuniUpdateCmd, " "))
log.Info().Msgf(L("Running: %s"), strings.Join(uyuniUpdateCmd, " "))
if err := adm_utils.ExecCommand(zerolog.InfoLevel, cnx, uyuniUpdateCmd...); err != nil {
return fmt.Errorf(L("failed to restart uyuni-update-config: %s"), err)
}
Expand Down
2 changes: 1 addition & 1 deletion mgradm/cmd/install/podman/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func waitForSystemStart(cnx *shared.Connection, image string, flags *podmanInsta
return err
}

log.Info().Msg("Waiting for the server to start...")
log.Info().Msg(L("Waiting for the server to start..."))
if err := shared_podman.EnableService(shared_podman.ServerService); err != nil {
return fmt.Errorf(L("cannot enable service: %s"), err)
}
Expand Down
2 changes: 1 addition & 1 deletion mgradm/cmd/status/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func kubernetesStatus(
return fmt.Errorf(L("failed to get deployment status: %s"), err)
}
if status.Replicas != status.ReadyReplicas {
log.Warn().Msgf("Some replicas are not ready: %d / %d", status.ReadyReplicas, status.Replicas)
log.Warn().Msgf(L("Some replicas are not ready: %d / %d"), status.ReadyReplicas, status.Replicas)
}

if status.AvailableReplicas == 0 {
Expand Down
4 changes: 2 additions & 2 deletions mgradm/shared/kubernetes/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func installSslIssuers(helmFlags *cmd_utils.HelmFlags, sslFlags *cmd_utils.SslCe
return []string{}, fmt.Errorf(L("cannot install cert manager: %s"), err)
}

log.Info().Msg("Creating SSL certificate issuer")
log.Info().Msg(L("Creating SSL certificate issuer"))
crdsDir, err := os.MkdirTemp("", "mgradm-*")
if err != nil {
return []string{}, fmt.Errorf(L("failed to create temporary directory: %s"), err)
Expand Down Expand Up @@ -149,7 +149,7 @@ func extractCaCertToConfig() {
log.Info().Msg(L("Extracting CA certificate to a configmap"))
// Skip extracting if the configmap is already present
out, err := utils.RunCmdOutput(zerolog.DebugLevel, "kubectl", "get", "configmap", "uyuni-ca", jsonPath)
log.Info().Msgf("CA cert: %s", string(out))
log.Info().Msgf(L("CA cert: %s"), string(out))
if err == nil && len(out) > 0 {
log.Info().Msg(L("uyuni-ca configmap already existing, skipping extraction"))
return
Expand Down
6 changes: 3 additions & 3 deletions mgradm/shared/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GenerateSystemdService(tz string, image string, debug bool, podmanArgs []st
return fmt.Errorf(L("cannot setup network: %s"), err)
}

log.Info().Msg("Enabling system service")
log.Info().Msg(L("Enabling system service"))
data := templates.PodmanServiceTemplateData{
Volumes: utils.ServerVolumeMounts,
NamePrefix: "uyuni",
Expand Down Expand Up @@ -135,7 +135,7 @@ func UpdateSslCertificate(cnx *shared.Connection, chain *ssl.CaChain, serverPair
}

// The services need to be restarted
log.Info().Msg("Restarting services after updating the certificate")
log.Info().Msg(L("Restarting services after updating the certificate"))
return utils.RunCmdStdMapping(zerolog.DebugLevel, "podman", "exec", podman.ServerContainerName, "spacewalk-service", "restart")
}

Expand Down Expand Up @@ -197,7 +197,7 @@ func RunMigration(serverImage string, pullPolicy string, sshAuthSocket string, s
return "", "", "", err
}

log.Info().Msg("Migrating server")
log.Info().Msg(L("Migrating server"))
if err := RunContainer("uyuni-migration", preparedImage, extraArgs,
[]string{"/var/lib/uyuni-tools/migrate.sh"}); err != nil {
return "", "", "", fmt.Errorf(L("cannot run uyuni migration container: %s"), err)
Expand Down
29 changes: 15 additions & 14 deletions mgradm/shared/utils/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/uyuni-project/uyuni-tools/mgradm/shared/ssl"
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
"github.com/uyuni-project/uyuni-tools/shared/types"
"github.com/uyuni-project/uyuni-tools/shared/utils"
)
Expand Down Expand Up @@ -45,36 +46,36 @@ func (f *SslCertFlags) UseExisting() bool {
// Checks that all the required flags are passed if using 3rd party certificates.
func (f *SslCertFlags) CheckParameters() {
if !f.UseExisting() && (f.Server.Cert != "" || f.Server.Key != "" || f.Ca.Root != "") {
log.Fatal().Msg("Server certificate, key and root CA need to be all provided")
log.Fatal().Msg(L("Server certificate, key and root CA need to be all provided"))
}
}

// AddHelmInstallFlag add Helm install flags to a command.
func AddHelmInstallFlag(cmd *cobra.Command) {
defaultChart := fmt.Sprintf("oci://%s/server-helm", utils.DefaultNamespace)

cmd.Flags().String("helm-uyuni-namespace", "default", "Kubernetes namespace where to install uyuni")
cmd.Flags().String("helm-uyuni-chart", defaultChart, "URL to the uyuni helm chart")
cmd.Flags().String("helm-uyuni-version", "", "Version of the uyuni helm chart")
cmd.Flags().String("helm-uyuni-values", "", "Path to a values YAML file to use for Uyuni helm install")
cmd.Flags().String("helm-certmanager-namespace", "cert-manager", "Kubernetes namespace where to install cert-manager")
cmd.Flags().String("helm-certmanager-chart", "", "URL to the cert-manager helm chart. To be used for offline installations")
cmd.Flags().String("helm-certmanager-version", "", "Version of the cert-manager helm chart")
cmd.Flags().String("helm-certmanager-values", "", "Path to a values YAML file to use for cert-manager helm install")
cmd.Flags().String("helm-uyuni-namespace", "default", L("Kubernetes namespace where to install uyuni"))
cmd.Flags().String("helm-uyuni-chart", defaultChart, L("URL to the uyuni helm chart"))
cmd.Flags().String("helm-uyuni-version", "", L("Version of the uyuni helm chart"))
cmd.Flags().String("helm-uyuni-values", "", L("Path to a values YAML file to use for Uyuni helm install"))
cmd.Flags().String("helm-certmanager-namespace", "cert-manager", L("Kubernetes namespace where to install cert-manager"))
cmd.Flags().String("helm-certmanager-chart", "", L("URL to the cert-manager helm chart. To be used for offline installations"))
cmd.Flags().String("helm-certmanager-version", "", L("Version of the cert-manager helm chart"))
cmd.Flags().String("helm-certmanager-values", "", L("Path to a values YAML file to use for cert-manager helm install"))
}

// AddimageFlag add Image flags to a command.
func AddImageFlag(cmd *cobra.Command) {
cmd.Flags().String("image", defaultImage, "Image")
cmd.Flags().String("tag", utils.DefaultTag, "Tag Image")
cmd.Flags().String("image", defaultImage, L("Image"))
cmd.Flags().String("tag", utils.DefaultTag, L("Tag Image"))

utils.AddPullPolicyFlag(cmd)
}

// AddMigrationImageFlag add Migration Image flags to a command.
func AddMigrationImageFlag(cmd *cobra.Command) {
cmd.Flags().String("migration-image", "", "Migration image")
cmd.Flags().String("migration-tag", utils.DefaultTag, "Migration image tag")
cmd.Flags().String("migration-image", "", L("Migration image"))
cmd.Flags().String("migration-tag", utils.DefaultTag, L("Migration image tag"))
cmd.Flags().String("migration-pullPolicy", "IfNotPresent",
"set whether to pull the migrattion images or not. The value can be one of 'Never', 'IfNotPresent' or 'Always'")
L("set whether to pull the migrattion images or not. The value can be one of 'Never', 'IfNotPresent' or 'Always'"))
}
4 changes: 2 additions & 2 deletions mgradm/shared/utils/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func ReadContainerData(scriptDir string) (string, string, string, error) {

// RunMigration execute the migration script.
func RunMigration(cnx *shared.Connection, tmpPath string, scriptName string) error {
log.Info().Msg("Migrating server")
log.Info().Msg(L("Migrating server"))
err := ExecCommand(zerolog.InfoLevel, cnx, "/var/lib/uyuni-tools/"+scriptName)
if err != nil {
return fmt.Errorf(L("error running the migration script: %s"), err)
Expand Down Expand Up @@ -193,7 +193,7 @@ func RunningImage(cnx *shared.Connection, containerName string) (string, error)
args := []string{"get", "pods", kubernetes.ServerFilter, "-o", "jsonpath={.items[0].spec.containers[0].image}"}
image, err := utils.RunCmdOutput(zerolog.DebugLevel, "kubectl", args...)

log.Info().Msgf("image is: %s", image)
log.Info().Msgf(L("Image is: %s"), image)
if err != nil {
return "", err
}
Expand Down
8 changes: 4 additions & 4 deletions shared/podman/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ type PodmanMountFlags struct {

// AddPodmanInstallFlag add the podman arguments to a command.
func AddPodmanInstallFlag(cmd *cobra.Command) {
cmd.Flags().StringSlice("podman-arg", []string{}, "Extra arguments to pass to podman")
cmd.Flags().StringSlice("podman-arg", []string{}, L("Extra arguments to pass to podman"))

cmd.Flags().String("podman-mount-cache", "", "Path to custom /var/cache volume")
cmd.Flags().String("podman-mount-postgresql", "", "Path to custom /var/lib/pgsql volume")
cmd.Flags().String("podman-mount-spacewalk", "", "Path to custom /var/spacewalk volume")
cmd.Flags().String("podman-mount-cache", "", L("Path to custom /var/cache volume"))
cmd.Flags().String("podman-mount-postgresql", "", L("Path to custom /var/lib/pgsql volume"))
cmd.Flags().String("podman-mount-spacewalk", "", L("Path to custom /var/spacewalk volume"))
}

// EnablePodmanSocket enables the podman socket.
Expand Down