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 0355820
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 49 deletions.
2 changes: 1 addition & 1 deletion cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
command.Flags().StringVar(&revision, "revision", "", "Compare live app to a particular revision")
command.Flags().StringVar(&localRepoRoot, "local-repo-root", "/", "Path to the repository root. Used together with --local allows setting the repository root")
command.Flags().BoolVar(&serverSideGenerate, "server-side-generate", false, "Used with --local, this will send your manifests to the server for diffing")
command.Flags().StringArrayVar(&localIncludes, "local-include", []string{"**/*.yaml", "**/*.yml", "**/*.json"}, "Used with --server-side-generate, specify patterns of filenames to send. It does support glob patterns")
command.Flags().StringArrayVar(&localIncludes, "local-include", []string{"**/*.yaml", "**/*.yml", "**/*.json"}, "Used with --server-side-generate, specify patterns of filenames to send. It does support glob patterns")
command.Flags().StringVarP(&appNamespace, "app-namespace", "N", "", "Only render the difference in namespace")
command.Flags().StringArrayVar(&revisions, "revisions", []string{}, "Show manifests at specific revisions for source position in source-positions")
command.Flags().Int64SliceVar(&sourcePositions, "source-positions", []int64{}, "List of source positions. Default is empty array. Counting start at 1.")
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/commands/argocd_app_diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ argocd app diff APPNAME [flags]
-h, --help help for diff
--ignore-normalizer-jq-execution-timeout duration Set ignore normalizer JQ execution timeout (default 1s)
--local string Compare live app to a local manifests
--local-include stringArray Used with --server-side-generate, specify patterns of filenames to send. It does support glob patterns (default [**/*.yaml,**/*.yml,**/*.json])
--local-include stringArray Used with --server-side-generate, specify patterns of filenames to send. It does support glob patterns (default [**/*.yaml,**/*.yml,**/*.json])
--local-repo-root string Path to the repository root. Used together with --local allows setting the repository root (default "/")
--refresh Refresh application data when retrieving
--revision string Compare live app to a particular revision
Expand Down
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)
}
18 changes: 9 additions & 9 deletions util/io/files/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func TestTgz(t *testing.T) {

// then
assert.Equal(t, 6, filesWritten)
assert.NoError(t, err)
require.NoError(t, err)
prepareRead(f)
files, err := read(f.file)
require.NoError(t, err)
assert.Equal(t, 16, len(files))
assert.Len(t, files, 16)
assert.Contains(t, files, "README.md")
assert.Contains(t, files, "applicationset/latest/kustomization.yaml")
assert.Contains(t, files, "applicationset/stable/kustomization.yaml")
Expand All @@ -75,11 +75,11 @@ func TestTgz(t *testing.T) {

// then
assert.Equal(t, 5, filesWritten)
assert.NoError(t, err)
require.NoError(t, err)
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 @@ -95,11 +95,11 @@ func TestTgz(t *testing.T) {

// then
assert.Equal(t, 4, filesWritten)
assert.NoError(t, err)
require.NoError(t, err)
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 All @@ -121,13 +121,13 @@ func TestTgz(t *testing.T) {

// then
assert.Equal(t, 4, filesWritten)
assert.NoError(t, err)
require.NoError(t, err)
prepareRead(f)

files, err := read(f.file)
require.NoError(t, err)

assert.Equal(t, 13, len(files))
assert.Len(t, files, 13)
assert.Contains(t, files, "applicationset/stable/kustomization.yaml")
assert.Contains(t, files, "applicationset/stable/kustomization.yaml")
assert.NotContains(t, files, "git/index")
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
2 changes: 1 addition & 1 deletion util/localconfig/file_perm_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func getFilePermission(fi os.FileInfo) error {
if fi.Mode().Perm() == 0666 || fi.Mode().Perm() == 0444 {
if fi.Mode().Perm() == 0o666 || fi.Mode().Perm() == 0o444 {
return nil
}
return fmt.Errorf("config file has incorrect permission flags:%s."+
Expand Down

0 comments on commit 0355820

Please sign in to comment.