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

chore: fix lint #3232

Merged
merged 1 commit into from
Nov 12, 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
6 changes: 5 additions & 1 deletion src/internal/gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/cluster/injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/pkg/message/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion src/test/e2e/03_deprecations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
4 changes: 2 additions & 2 deletions src/test/e2e/08_create_differential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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)
}
}
12 changes: 9 additions & 3 deletions src/test/e2e/22_git_and_gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down