Skip to content

Commit

Permalink
chore: fix lint (#3232)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 authored Nov 12, 2024
1 parent f4c80cb commit 1d0fdbd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
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

0 comments on commit 1d0fdbd

Please sign in to comment.