diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22ea750052..2e4b30ffe6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v5.0.0 hooks: - id: check-added-large-files args: ["--maxkb=1024"] diff --git a/src/internal/gitea/gitea.go b/src/internal/gitea/gitea.go index 48bfdfaae1..c2cad8b907 100644 --- a/src/internal/gitea/gitea.go +++ b/src/internal/gitea/gitea.go @@ -32,7 +32,11 @@ func NewClient(endpoint, username, password string) (*Client, error) { if err != nil { return nil, err } - transport := http.DefaultTransport.(*http.Transport).Clone() + transport, ok := http.DefaultTransport.(*http.Transport) + if !ok { + return nil, errors.New("could not get default transport") + } + transport = transport.Clone() transport.MaxIdleConnsPerHost = transport.MaxIdleConns httpClient := &http.Client{ Timeout: 10 * time.Second, diff --git a/src/pkg/cluster/injector_test.go b/src/pkg/cluster/injector_test.go index dde50f5bab..5925923afd 100644 --- a/src/pkg/cluster/injector_test.go +++ b/src/pkg/cluster/injector_test.go @@ -45,7 +45,9 @@ func TestInjector(t *testing.T) { gvk := delAction.Resource.GroupVersion().WithKind("ConfigMap") list, err := cs.Tracker().List(gvr, gvk, delAction.Namespace) require.NoError(t, err) - for _, cm := range list.(*corev1.ConfigMapList).Items { + cmList, ok := list.(*corev1.ConfigMapList) + require.True(t, ok) + for _, cm := range cmList.Items { v, ok := cm.Labels["zarf-injector"] if !ok { continue diff --git a/src/pkg/message/credentials.go b/src/pkg/message/credentials.go index a0fc97537c..998fa41283 100644 --- a/src/pkg/message/credentials.go +++ b/src/pkg/message/credentials.go @@ -136,15 +136,15 @@ func PrintCredentialUpdates(oldState *types.ZarfState, newState *types.ZarfState pterm.Println() } -func compareStrings(old string, new string, secret bool) string { - if new == old { +func compareStrings(curent string, updated string, secret bool) string { + if updated == curent { if secret { return "**sanitized** (unchanged)" } - return fmt.Sprintf("%s (unchanged)", old) + return fmt.Sprintf("%s (unchanged)", curent) } if secret { return fmt.Sprintf("%s -> %s", pterm.FgRed.Sprint("**existing (sanitized)**"), pterm.FgGreen.Sprint("**replacement (sanitized)**")) } - return fmt.Sprintf("%s -> %s", pterm.FgRed.Sprint(old), pterm.FgGreen.Sprint(new)) + return fmt.Sprintf("%s -> %s", pterm.FgRed.Sprint(curent), pterm.FgGreen.Sprint(updated)) } diff --git a/src/test/e2e/03_deprecations_test.go b/src/test/e2e/03_deprecations_test.go index a20684c2ad..cc1dc33759 100644 --- a/src/test/e2e/03_deprecations_test.go +++ b/src/test/e2e/03_deprecations_test.go @@ -91,5 +91,5 @@ func TestDeprecatedSetAndPackageVariables(t *testing.T) { before: - cmd: echo "Zarf-The-Axolotl" ` - require.Equal(t, expectedYaml, string(b)) + require.YAMLEq(t, expectedYaml, string(b)) } diff --git a/src/test/e2e/08_create_differential_test.go b/src/test/e2e/08_create_differential_test.go index 35be26761f..eaccdb259f 100644 --- a/src/test/e2e/08_create_differential_test.go +++ b/src/test/e2e/08_create_differential_test.go @@ -67,7 +67,7 @@ func TestCreateDifferential(t *testing.T) { } require.Len(t, actualGitRepos, 4, "zarf.yaml from the differential package does not contain the correct number of repos") for _, expectedRepo := range expectedGitRepos { - require.Contains(t, actualGitRepos, expectedRepo, fmt.Sprintf("unable to find expected repo %s", expectedRepo)) + require.Contains(t, actualGitRepos, expectedRepo, "unable to find expected repo %s", expectedRepo) } /* Validate we have ONLY the images we expect to have */ @@ -77,6 +77,6 @@ func TestCreateDifferential(t *testing.T) { } require.Len(t, actualImages, 2, "zarf.yaml from the differential package does not contain the correct number of images") for _, expectedImage := range expectedImages { - require.Contains(t, actualImages, expectedImage, fmt.Sprintf("unable to find expected image %s", expectedImage)) + require.Contains(t, actualImages, expectedImage, "unable to find expected image %s", expectedImage) } } diff --git a/src/test/e2e/22_git_and_gitops_test.go b/src/test/e2e/22_git_and_gitops_test.go index 90eb715259..ad20629cf9 100644 --- a/src/test/e2e/22_git_and_gitops_test.go +++ b/src/test/e2e/22_git_and_gitops_test.go @@ -88,9 +88,15 @@ func testGitServerReadOnly(ctx context.Context, t *testing.T, gitURL string) { require.NoError(t, err) permissionsMap, ok := bodyMap["permissions"].(map[string]interface{}) require.True(t, ok, "permissions key is not of right type") - require.False(t, permissionsMap["admin"].(bool)) - require.False(t, permissionsMap["push"].(bool)) - require.True(t, permissionsMap["pull"].(bool)) + admin, ok := permissionsMap["admin"].(bool) + require.True(t, ok) + require.False(t, admin) + push, ok := permissionsMap["push"].(bool) + require.True(t, ok) + require.False(t, push) + pull, ok := permissionsMap["pull"].(bool) + require.True(t, ok) + require.True(t, pull) } func testGitServerTagAndHash(ctx context.Context, t *testing.T, gitURL string) {