diff --git a/.golangci.yml b/.golangci.yml index 5efa94293..d4ce856de 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,6 +6,43 @@ linters-settings: stylecheck: dot-import-whitelist: - github.com/uyuni-project/uyuni-tools/shared/l10n + initialisms: + # Default + - ACL + - API + - ASCII + - CPU + - DNS + - EOF + - GUID + - HTML + - HTTP + - HTTPS + - ID + - IP + - JSON + - RPC + - SLA + - SMTP + - SQL + - SSH + - TCP + - TLS + - TTL + - UDP + - UI + - GID + - UID + - UUID + - URI + - URL + - UTF8 + - VM + - XML + - RTP + - DB + # Added + - SCC gofmt: simplify: true gocyclo: diff --git a/mgradm/cmd/inspect/inspect_test.go b/mgradm/cmd/inspect/inspect_test.go index 681af276a..e62d7263a 100644 --- a/mgradm/cmd/inspect/inspect_test.go +++ b/mgradm/cmd/inspect/inspect_test.go @@ -21,14 +21,14 @@ func TestParamsParsing(t *testing.T) { } args = append(args, flagstests.ImageFlagsTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) // Test function asserting that the args are properly parsed tester := func(globalFlags *types.GlobalFlags, flags *inspectFlags, cmd *cobra.Command, args []string, ) error { flagstests.AssertImageFlag(t, cmd, &flags.Image) - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) if utils.KubernetesBuilt { testutils.AssertEquals(t, "Error parsing --backend", "kubectl", flags.Backend) } diff --git a/mgradm/cmd/install/kubernetes/utils.go b/mgradm/cmd/install/kubernetes/utils.go index 07680af5d..0febe51c5 100644 --- a/mgradm/cmd/install/kubernetes/utils.go +++ b/mgradm/cmd/install/kubernetes/utils.go @@ -68,7 +68,7 @@ func installForKubernetes(globalFlags *types.GlobalFlags, helmArgs = append(helmArgs, sslArgs...) // Create a secret using SCC credentials if any are provided - helmArgs, err = shared_kubernetes.AddSccSecret(helmArgs, flags.Helm.Uyuni.Namespace, &flags.Scc) + helmArgs, err = shared_kubernetes.AddSCCSecret(helmArgs, flags.Helm.Uyuni.Namespace, &flags.SCC) if err != nil { return err } diff --git a/mgradm/cmd/install/podman/utils.go b/mgradm/cmd/install/podman/utils.go index 039856eab..a8b1a7cda 100644 --- a/mgradm/cmd/install/podman/utils.go +++ b/mgradm/cmd/install/podman/utils.go @@ -55,7 +55,7 @@ func installForPodman( return err } - authFile, cleaner, err := shared_podman.PodmanLogin(hostData, flags.Scc) + authFile, cleaner, err := shared_podman.PodmanLogin(hostData, flags.SCC) if err != nil { return utils.Errorf(err, L("failed to login to registry.suse.com")) } diff --git a/mgradm/cmd/install/shared/flags.go b/mgradm/cmd/install/shared/flags.go index 49f28fb43..fd1a67af5 100644 --- a/mgradm/cmd/install/shared/flags.go +++ b/mgradm/cmd/install/shared/flags.go @@ -50,7 +50,7 @@ type InstallFlags struct { DB DBFlags ReportDB DBFlags Ssl cmd_utils.InstallSSLFlags - Scc types.SCCCredentials + SCC types.SCCCredentials Debug DebugFlags Image types.ImageFlags `mapstructure:",squash"` Coco cmd_utils.CocoFlags diff --git a/mgradm/cmd/install/shared/shared.go b/mgradm/cmd/install/shared/shared.go index 0f0196e8e..9a7659d1a 100644 --- a/mgradm/cmd/install/shared/shared.go +++ b/mgradm/cmd/install/shared/shared.go @@ -140,8 +140,8 @@ func generateSetupScript(flags *InstallFlags, fqdn string, extraEnv map[string]s "EXTERNALDB_PROVIDER": flags.DB.Provider, "ISS_PARENT": flags.IssParent, "ACTIVATE_SLP": "N", // Deprecated, will be removed soon - "SCC_USER": flags.Scc.User, - "SCC_PASS": flags.Scc.Password, + "SCC_USER": flags.SCC.User, + "SCC_PASS": flags.SCC.Password, } if flags.Mirror != "" { env["MIRROR_PATH"] = "/mirror" diff --git a/mgradm/cmd/migrate/kubernetes/kubernetes_test.go b/mgradm/cmd/migrate/kubernetes/kubernetes_test.go index c1fa9b4e4..6eb509176 100644 --- a/mgradm/cmd/migrate/kubernetes/kubernetes_test.go +++ b/mgradm/cmd/migrate/kubernetes/kubernetes_test.go @@ -24,7 +24,7 @@ func TestParamsParsing(t *testing.T) { } args = append(args, flagstests.MirrorFlagTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.ImageFlagsTestArgs...) args = append(args, flagstests.DBUpdateImageFlagTestArgs...) args = append(args, flagstests.CocoFlagsTestArgs...) @@ -37,7 +37,7 @@ func TestParamsParsing(t *testing.T) { ) error { testutils.AssertTrue(t, "Prepare not set", flags.Prepare) flagstests.AssertMirrorFlag(t, cmd, flags.Mirror) - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) flagstests.AssertImageFlag(t, cmd, &flags.Image) flagstests.AssertDBUpgradeImageFlag(t, cmd, &flags.DBUpgradeImage) flagstests.AssertCocoFlag(t, cmd, &flags.Coco) diff --git a/mgradm/cmd/migrate/kubernetes/utils.go b/mgradm/cmd/migrate/kubernetes/utils.go index 078dab9eb..f4efca941 100644 --- a/mgradm/cmd/migrate/kubernetes/utils.go +++ b/mgradm/cmd/migrate/kubernetes/utils.go @@ -78,7 +78,7 @@ func migrateToKubernetes( helmArgs := []string{} // Create a secret using SCC credentials if any are provided - helmArgs, err = shared_kubernetes.AddSccSecret(helmArgs, flags.Helm.Uyuni.Namespace, &flags.Scc) + helmArgs, err = shared_kubernetes.AddSCCSecret(helmArgs, flags.Helm.Uyuni.Namespace, &flags.SCC) if err != nil { return err } diff --git a/mgradm/cmd/migrate/podman/podman_test.go b/mgradm/cmd/migrate/podman/podman_test.go index 3d03d4485..b4e9dc483 100644 --- a/mgradm/cmd/migrate/podman/podman_test.go +++ b/mgradm/cmd/migrate/podman/podman_test.go @@ -21,7 +21,7 @@ func TestParamsParsing(t *testing.T) { } args = append(args, flagstests.MirrorFlagTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.ImageFlagsTestArgs...) args = append(args, flagstests.DBUpdateImageFlagTestArgs...) args = append(args, flagstests.CocoFlagsTestArgs...) @@ -34,7 +34,7 @@ func TestParamsParsing(t *testing.T) { ) error { testutils.AssertTrue(t, "Prepare not set", flags.Prepare) flagstests.AssertMirrorFlag(t, cmd, flags.Mirror) - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) flagstests.AssertImageFlag(t, cmd, &flags.Image) flagstests.AssertDBUpgradeImageFlag(t, cmd, &flags.DBUpgradeImage) flagstests.AssertCocoFlag(t, cmd, &flags.Coco) diff --git a/mgradm/cmd/migrate/shared/flags.go b/mgradm/cmd/migrate/shared/flags.go index e86a2e2e0..75b5e402d 100644 --- a/mgradm/cmd/migrate/shared/flags.go +++ b/mgradm/cmd/migrate/shared/flags.go @@ -20,7 +20,7 @@ type MigrateFlags struct { User string Mirror string HubXmlrpc utils.HubXmlrpcFlags - Scc types.SCCCredentials + SCC types.SCCCredentials } // AddMigrateFlags add migration flags to a command. diff --git a/mgradm/cmd/upgrade/kubernetes/kubernetes_test.go b/mgradm/cmd/upgrade/kubernetes/kubernetes_test.go index 02de59ef3..86e9b9fd5 100644 --- a/mgradm/cmd/upgrade/kubernetes/kubernetes_test.go +++ b/mgradm/cmd/upgrade/kubernetes/kubernetes_test.go @@ -22,7 +22,7 @@ func TestParamsParsing(t *testing.T) { args = append(args, flagstests.DBUpdateImageFlagTestArgs...) args = append(args, flagstests.CocoFlagsTestArgs...) args = append(args, flagstests.HubXmlrpcFlagsTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.ServerHelmFlagsTestArgs...) // Test function asserting that the args are properly parsed diff --git a/mgradm/cmd/upgrade/podman/podman_test.go b/mgradm/cmd/upgrade/podman/podman_test.go index 8d3791a1f..3ba5fd9c7 100644 --- a/mgradm/cmd/upgrade/podman/podman_test.go +++ b/mgradm/cmd/upgrade/podman/podman_test.go @@ -20,7 +20,7 @@ func TestParamsParsing(t *testing.T) { args = append(args, flagstests.DBUpdateImageFlagTestArgs...) args = append(args, flagstests.CocoFlagsTestArgs...) args = append(args, flagstests.HubXmlrpcFlagsTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.PodmanFlagsTestArgs...) // Test function asserting that the args are properly parsed @@ -31,7 +31,7 @@ func TestParamsParsing(t *testing.T) { flagstests.AssertDBUpgradeImageFlag(t, cmd, &flags.DBUpgradeImage) flagstests.AssertCocoFlag(t, cmd, &flags.Coco) flagstests.AssertHubXmlrpcFlag(t, cmd, &flags.HubXmlrpc) - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) flagstests.AssertPodmanInstallFlags(t, cmd, &flags.Podman) return nil } diff --git a/mgrpxy/cmd/install/kubernetes/kubernetes.go b/mgrpxy/cmd/install/kubernetes/kubernetes.go index c4f9634c3..fbb906705 100644 --- a/mgrpxy/cmd/install/kubernetes/kubernetes.go +++ b/mgrpxy/cmd/install/kubernetes/kubernetes.go @@ -16,7 +16,7 @@ import ( type kubernetesProxyInstallFlags struct { pxy_utils.ProxyImageFlags `mapstructure:",squash"` Helm kubernetes.HelmFlags - Scc types.SCCCredentials + SCC types.SCCCredentials } func newCmd(globalFlags *types.GlobalFlags, run utils.CommandFunc[kubernetesProxyInstallFlags]) *cobra.Command { diff --git a/mgrpxy/cmd/install/kubernetes/kubernetes_test.go b/mgrpxy/cmd/install/kubernetes/kubernetes_test.go index 5c11c772f..b14a8822a 100644 --- a/mgrpxy/cmd/install/kubernetes/kubernetes_test.go +++ b/mgrpxy/cmd/install/kubernetes/kubernetes_test.go @@ -20,7 +20,7 @@ func TestParamsParsing(t *testing.T) { args = append(args, flagstests.ImageProxyFlagsTestArgs...) args = append(args, flagstests.ProxyHelmFlagsTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) // Test function asserting that the args are properly parsed tester := func(globalFlags *types.GlobalFlags, flags *kubernetesProxyInstallFlags, @@ -28,7 +28,7 @@ func TestParamsParsing(t *testing.T) { ) error { flagstests.AssertProxyImageFlags(t, cmd, &flags.ProxyImageFlags) flagstests.AssertProxyHelmFlags(t, cmd, &flags.Helm) - flagstests.AssertSccFlag(t, cmd, &flags.Scc) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) return nil } diff --git a/mgrpxy/cmd/install/kubernetes/utils.go b/mgrpxy/cmd/install/kubernetes/utils.go index 00f296a24..5c3e1f3a7 100644 --- a/mgrpxy/cmd/install/kubernetes/utils.go +++ b/mgrpxy/cmd/install/kubernetes/utils.go @@ -57,7 +57,7 @@ func installForKubernetes(globalFlags *types.GlobalFlags, } helmArgs := []string{"--set", "ingress=" + clusterInfos.Ingress} - helmArgs, err = shared_kubernetes.AddSccSecret(helmArgs, flags.Helm.Proxy.Namespace, &flags.Scc) + helmArgs, err = shared_kubernetes.AddSCCSecret(helmArgs, flags.Helm.Proxy.Namespace, &flags.SCC) if err != nil { return err } diff --git a/mgrpxy/cmd/install/podman/podman_test.go b/mgrpxy/cmd/install/podman/podman_test.go index 1370e4a2b..f178c7328 100644 --- a/mgrpxy/cmd/install/podman/podman_test.go +++ b/mgrpxy/cmd/install/podman/podman_test.go @@ -21,7 +21,7 @@ func TestParamsParsing(t *testing.T) { } args = append(args, flagstests.ImageProxyFlagsTestArgs...) args = append(args, flagstests.PodmanFlagsTestArgs...) - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) // Test function asserting that the args are properly parsed tester := func(globalFlags *types.GlobalFlags, flags *podman.PodmanProxyFlags, @@ -29,7 +29,7 @@ func TestParamsParsing(t *testing.T) { ) error { flagstests.AssertProxyImageFlags(t, cmd, &flags.ProxyImageFlags) flagstests.AssertPodmanInstallFlags(t, cmd, &flags.Podman) - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) return nil } diff --git a/mgrpxy/cmd/support/ptf/podman/podman_test.go b/mgrpxy/cmd/support/ptf/podman/podman_test.go index 7afb4c9ab..2461d5d4d 100644 --- a/mgrpxy/cmd/support/ptf/podman/podman_test.go +++ b/mgrpxy/cmd/support/ptf/podman/podman_test.go @@ -21,14 +21,14 @@ func TestParamsParsing(t *testing.T) { "--user", "sccuser", } - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.ImageProxyFlagsTestArgs...) // Test function asserting that the args are properly parsed tester := func(globalFlags *types.GlobalFlags, flags *podmanPTFFlags, cmd *cobra.Command, args []string, ) error { - flagstests.AssertSccFlag(t, cmd, &flags.UpgradeFlags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.UpgradeFlags.SCC) flagstests.AssertProxyImageFlags(t, cmd, &flags.UpgradeFlags.ProxyImageFlags) testutils.AssertEquals(t, "Error parsing --ptf", "ptf123", flags.PTFId) testutils.AssertEquals(t, "Error parsing --test", "test123", flags.TestID) diff --git a/mgrpxy/cmd/upgrade/podman/podman_test.go b/mgrpxy/cmd/upgrade/podman/podman_test.go index a48faed89..8b8a8fb9c 100644 --- a/mgrpxy/cmd/upgrade/podman/podman_test.go +++ b/mgrpxy/cmd/upgrade/podman/podman_test.go @@ -18,7 +18,7 @@ import ( func TestParamsParsing(t *testing.T) { args := []string{} - args = append(args, flagstests.SccFlagTestArgs...) + args = append(args, flagstests.SCCFlagTestArgs...) args = append(args, flagstests.ImageProxyFlagsTestArgs...) args = append(args, flagstests.PodmanFlagsTestArgs...) @@ -26,7 +26,7 @@ func TestParamsParsing(t *testing.T) { tester := func(globalFlags *types.GlobalFlags, flags *podman.PodmanProxyFlags, cmd *cobra.Command, args []string, ) error { - flagstests.AssertSccFlag(t, cmd, &flags.SCC) + flagstests.AssertSCCFlag(t, cmd, &flags.SCC) flagstests.AssertPodmanInstallFlags(t, cmd, &flags.Podman) flagstests.AssertProxyImageFlags(t, cmd, &flags.ProxyImageFlags) return nil diff --git a/shared/kubernetes/kubernetes.go b/shared/kubernetes/kubernetes.go index af087f81d..74df1ec66 100644 --- a/shared/kubernetes/kubernetes.go +++ b/shared/kubernetes/kubernetes.go @@ -192,8 +192,8 @@ data: return nil } -// AddSccSecret creates a secret holding the SCC credentials and adds it to the helm args. -func AddSccSecret(helmArgs []string, namespace string, scc *types.SCCCredentials) ([]string, error) { +// AddSCCSecret creates a secret holding the SCC credentials and adds it to the helm args. +func AddSCCSecret(helmArgs []string, namespace string, scc *types.SCCCredentials) ([]string, error) { if scc.User != "" && scc.Password != "" { secretName := "scc-credentials" if err := createDockerSecret( diff --git a/shared/podman/hostinspector.go b/shared/podman/hostinspector.go index bf7b75884..3c7ff3579 100644 --- a/shared/podman/hostinspector.go +++ b/shared/podman/hostinspector.go @@ -40,8 +40,8 @@ func NewHostInspector(scriptDir string) HostInspector { // HostInspectData are the data returned by the host inspector. type HostInspectData struct { - SccUsername string `mapstructure:"scc_username"` - SccPassword string `mapstructure:"scc_password"` + SCCUsername string `mapstructure:"scc_username"` + SCCPassword string `mapstructure:"scc_password"` HasUyuniServer bool `mapstructure:"has_uyuni_server"` } diff --git a/shared/podman/hostinspector_test.go b/shared/podman/hostinspector_test.go index dc806c033..35005bef0 100644 --- a/shared/podman/hostinspector_test.go +++ b/shared/podman/hostinspector_test.go @@ -52,7 +52,7 @@ has_uyuni_server=true t.Fatalf("Unexpected error: %s", err) } - testutils.AssertEquals(t, "Invalid SCC username", "myuser", actual.SccUsername) - testutils.AssertEquals(t, "Invalid SCC password", "mysecret", actual.SccPassword) + testutils.AssertEquals(t, "Invalid SCC username", "myuser", actual.SCCUsername) + testutils.AssertEquals(t, "Invalid SCC password", "mysecret", actual.SCCPassword) testutils.AssertTrue(t, "HasUyuniServer should be true", actual.HasUyuniServer) } diff --git a/shared/podman/login.go b/shared/podman/login.go index 929629507..bd69f26ea 100644 --- a/shared/podman/login.go +++ b/shared/podman/login.go @@ -19,8 +19,8 @@ import ( // // It returns an authentication file, a cleanup function and an error. func PodmanLogin(hostData *HostInspectData, scc types.SCCCredentials) (string, func(), error) { - sccUser := hostData.SccUsername - sccPassword := hostData.SccPassword + sccUser := hostData.SCCUsername + sccPassword := hostData.SCCPassword if scc.User != "" && scc.Password != "" { log.Info().Msg(L("SCC credentials parameters will be used. SCC credentials from host will be ignored.")) sccUser = scc.User diff --git a/shared/testutils/flagstests/mgradm_install.go b/shared/testutils/flagstests/mgradm_install.go index 6ed4242ad..b46234374 100644 --- a/shared/testutils/flagstests/mgradm_install.go +++ b/shared/testutils/flagstests/mgradm_install.go @@ -49,7 +49,7 @@ var InstallFlagsTestArgs = func() []string { } args = append(args, MirrorFlagTestArgs...) - args = append(args, SccFlagTestArgs...) + args = append(args, SCCFlagTestArgs...) args = append(args, ImageFlagsTestArgs...) args = append(args, CocoFlagsTestArgs...) args = append(args, HubXmlrpcFlagsTestArgs...) @@ -94,7 +94,7 @@ func AssertInstallFlags(t *testing.T, cmd *cobra.Command, flags *shared.InstallF testutils.AssertEquals(t, "Error parsing --admin-lastName", "adminlast", flags.Admin.LastName) testutils.AssertEquals(t, "Error parsing --organization", "someorg", flags.Organization) AssertMirrorFlag(t, cmd, flags.Mirror) - AssertSccFlag(t, cmd, &flags.Scc) + AssertSCCFlag(t, cmd, &flags.SCC) AssertImageFlag(t, cmd, &flags.Image) AssertCocoFlag(t, cmd, &flags.Coco) AssertHubXmlrpcFlag(t, cmd, &flags.HubXmlrpc) diff --git a/shared/testutils/flagstests/scc.go b/shared/testutils/flagstests/scc.go index 5880680c0..30c8cf99f 100644 --- a/shared/testutils/flagstests/scc.go +++ b/shared/testutils/flagstests/scc.go @@ -12,14 +12,14 @@ import ( "github.com/uyuni-project/uyuni-tools/shared/types" ) -// SccFlagTestArgs is the expected values for AssertSccFlag. -var SccFlagTestArgs = []string{ +// SCCFlagTestArgs is the expected values for AssertSccFlag. +var SCCFlagTestArgs = []string{ "--scc-user", "mysccuser", "--scc-password", "mysccpass", } -// AssertSccFlag checks that all SCC flags are parsed correctly. -func AssertSccFlag(t *testing.T, cmd *cobra.Command, flags *types.SCCCredentials) { +// AssertSCCFlag checks that all SCC flags are parsed correctly. +func AssertSCCFlag(t *testing.T, cmd *cobra.Command, flags *types.SCCCredentials) { testutils.AssertEquals(t, "Error parsing --scc-user", "mysccuser", flags.User) testutils.AssertEquals(t, "Error parsing --scc-password", "mysccpass", flags.Password) }