Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-heetch committed Jun 26, 2024
1 parent 22170e0 commit 6001864
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 40 deletions.
2 changes: 1 addition & 1 deletion reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (s *Service) ListApps(ctx context.Context, q *apiclient.ListAppsRequest) (*

defer io.Close(closer)

apps, err := discovery.Discover(ctx, gitClient.Root(), gitClient.Root(), q.EnabledSourceTypes, s.initConstants.CMPTarExcludedGlobs, s.initConstants.CMPTarIncludedGlobs)
apps, err := discovery.Discover(ctx, gitClient.Root(), gitClient.Root(), q.EnabledSourceTypes, s.initConstants.CMPTarExcludedGlobs, s.initConstants.CMPTarIncludedGlobs, []string{})
if err != nil {
return nil, fmt.Errorf("error discovering applications: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ func TestGenerateNullList(t *testing.T) {
}

func TestIdentifyAppSourceTypeByAppDirWithKustomizations(t *testing.T) {
sourceType, err := GetAppSourceType(context.Background(), &argoappv1.ApplicationSource{}, "./testdata/kustomization_yaml", "./testdata", "testapp", map[string]bool{}, []string{}, []string{})
sourceType, err := GetAppSourceType(context.Background(), &argoappv1.ApplicationSource{}, "./testdata/kustomization_yaml", "./testdata", "testapp", map[string]bool{}, []string{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, argoappv1.ApplicationSourceTypeKustomize, sourceType)

Expand Down
4 changes: 2 additions & 2 deletions util/app/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Discover(ctx context.Context, appPath, repoPath string, enableGenerateManif
apps := make(map[string]string)

// Check if it is CMP
conn, _, err := DetectConfigManagementPlugin(ctx, appPath, repoPath, "", env, tarExcludedGlobs)
conn, _, err := DetectConfigManagementPlugin(ctx, appPath, repoPath, "", env, tarExcludedGlobs, tarIncludedGlobs)
if err == nil {
// Found CMP
io.Close(conn)
Expand Down Expand Up @@ -68,7 +68,7 @@ func Discover(ctx context.Context, appPath, repoPath string, enableGenerateManif
}

func AppType(ctx context.Context, appPath, repoPath string, enableGenerateManifests map[string]bool, tarExcludedGlobs, tarIncludedGlobs, env []string) (string, error) {
apps, err := Discover(ctx, appPath, repoPath, enableGenerateManifests, tarExcludedGlobs, env)
apps, err := Discover(ctx, appPath, repoPath, enableGenerateManifests, tarExcludedGlobs, tarIncludedGlobs, env)
if err != nil {
return "", err
}
Expand Down
40 changes: 7 additions & 33 deletions util/app/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,26 @@ import (
)

func TestDiscover(t *testing.T) {
apps, err := Discover(context.Background(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{})
<<<<<<< HEAD
apps, err := Discover(context.Background(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{}, []string{})
require.NoError(t, err)
=======
assert.NoError(t, err)
>>>>>>> f35a7ddf4 (add plugin tar inclusion)
assert.Equal(t, map[string]string{
"foo": "Kustomize",
"baz": "Helm",
}, apps)
}

func TestAppType(t *testing.T) {
appType, err := AppType(context.Background(), "./testdata/foo", "./testdata", map[string]bool{}, []string{}, []string{})
<<<<<<< HEAD
appType, err := AppType(context.Background(), "./testdata/foo", "./testdata", map[string]bool{}, []string{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Kustomize", appType)

appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", map[string]bool{}, []string{}, []string{})
appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", map[string]bool{}, []string{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Helm", appType)

appType, err = AppType(context.Background(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{})
appType, err = AppType(context.Background(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{}, []string{})
require.NoError(t, err)
=======
assert.NoError(t, err)
assert.Equal(t, "Kustomize", appType)

appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", map[string]bool{}, []string{}, []string{})
assert.NoError(t, err)
assert.Equal(t, "Helm", appType)

appType, err = AppType(context.Background(), "./testdata", "./testdata", map[string]bool{}, []string{}, []string{})
assert.NoError(t, err)
>>>>>>> f35a7ddf4 (add plugin tar inclusion)
assert.Equal(t, "Directory", appType)
}

Expand All @@ -54,27 +39,16 @@ func TestAppType_Disabled(t *testing.T) {
string(v1alpha1.ApplicationSourceTypeKustomize): false,
string(v1alpha1.ApplicationSourceTypeHelm): false,
}
appType, err := AppType(context.Background(), "./testdata/foo", "./testdata", enableManifestGeneration, []string{}, []string{})
<<<<<<< HEAD
appType, err := AppType(context.Background(), "./testdata/foo", "./testdata", enableManifestGeneration, []string{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)

appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", enableManifestGeneration, []string{}, []string{})
appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", enableManifestGeneration, []string{}, []string{}, []string{})
require.NoError(t, err)
assert.Equal(t, "Directory", appType)

appType, err = AppType(context.Background(), "./testdata", "./testdata", enableManifestGeneration, []string{}, []string{})
appType, err = AppType(context.Background(), "./testdata", "./testdata", enableManifestGeneration, []string{}, []string{}, []string{})
require.NoError(t, err)
=======
assert.NoError(t, err)
assert.Equal(t, "Directory", appType)

appType, err = AppType(context.Background(), "./testdata/baz", "./testdata", enableManifestGeneration, []string{}, []string{})
assert.NoError(t, err)
assert.Equal(t, "Directory", appType)

appType, err = AppType(context.Background(), "./testdata", "./testdata", enableManifestGeneration, []string{}, []string{})
assert.NoError(t, err)
>>>>>>> f35a7ddf4 (add plugin tar inclusion)
assert.Equal(t, "Directory", appType)
}
6 changes: 3 additions & 3 deletions util/io/files/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestTgz(t *testing.T) {
prepareRead(f)
files, err := read(f.file)
require.NoError(t, err)
assert.Len(t, 15, files)
assert.Len(t, files, 15)
assert.Contains(t, files, "applicationset/latest/kustomization.yaml")
assert.Contains(t, files, "applicationset/stable/kustomization.yaml")
})
Expand All @@ -99,7 +99,7 @@ func TestTgz(t *testing.T) {
prepareRead(f)
files, err := read(f.file)
require.NoError(t, err)
assert.Len(t, 13, files)
assert.Len(t, files, 13)
assert.Contains(t, files, "applicationset/stable/kustomization.yaml")
})

Expand Down Expand Up @@ -207,7 +207,7 @@ func TestUntgz(t *testing.T) {
// then
require.NoError(t, err)
names := readFiles(t, destDir)
assert.Len(t, 16, names)
assert.Len(t, names, 16)
assert.Contains(t, names, "README.md")
assert.Contains(t, names, "applicationset/latest/kustomization.yaml")
assert.Contains(t, names, "applicationset/stable/kustomization.yaml")
Expand Down

0 comments on commit 6001864

Please sign in to comment.