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

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 #13360

Merged
merged 10 commits into from
May 8, 2023
4 changes: 2 additions & 2 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ func runConfigManagementPluginSidecars(ctx context.Context, appPath, repoPath, p
}

// detect config management plugin server (sidecar)
conn, cmpClient, err := discovery.DetectConfigManagementPlugin(ctx, appPath, pluginName, env, tarExcludedGlobs)
jiachengxu marked this conversation as resolved.
Show resolved Hide resolved
conn, cmpClient, err := discovery.DetectConfigManagementPlugin(ctx, repoPath, pluginName, env, tarExcludedGlobs)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2169,7 +2169,7 @@ func populatePluginAppDetails(ctx context.Context, res *apiclient.RepoAppDetails
pluginName = q.Source.Plugin.Name
}
// detect config management plugin server (sidecar)
conn, cmpClient, err := discovery.DetectConfigManagementPlugin(ctx, appPath, pluginName, env, tarExcludedGlobs)
conn, cmpClient, err := discovery.DetectConfigManagementPlugin(ctx, repoPath, pluginName, env, tarExcludedGlobs)
if err != nil {
return fmt.Errorf("failed to detect CMP for app: %w", err)
}
Expand Down
57 changes: 57 additions & 0 deletions test/e2e/custom_tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,60 @@ func TestPreserveFileModeForCMP(t *testing.T) {
assert.Equal(t, "ConfigMap", app.Status.Resources[0].Kind)
})
}

func TestCMPWithSymlinkPartialFiles(t *testing.T) {
Given(t).
And(func() {
go startCMPServer("./testdata/cmp-symlink")
time.Sleep(1 * time.Second)
os.Setenv("ARGOCD_BINARY_NAME", "argocd")
}).
Path("guestbook-partial-symlink-files").
When().
CreateFromFile(func(app *Application) {
app.Spec.Source.Plugin = &ApplicationSourcePlugin{Name: "cmp-symlink-v1.0"}
jiachengxu marked this conversation as resolved.
Show resolved Hide resolved
}).
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy))
}

func TestCMPWithSymlinkFolder(t *testing.T) {
Given(t).
And(func() {
go startCMPServer("./testdata/cmp-symlink")
time.Sleep(1 * time.Second)
os.Setenv("ARGOCD_BINARY_NAME", "argocd")
}).
Path("guestbook-symlink-folder").
When().
CreateFromFile(func(app *Application) {
app.Spec.Source.Plugin = &ApplicationSourcePlugin{Name: "cmp-symlink-v1.0"}
}).
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy))
}

func TestCMPWithSymlinkFiles(t *testing.T) {
Given(t).
And(func() {
go startCMPServer("./testdata/cmp-symlink")
time.Sleep(1 * time.Second)
os.Setenv("ARGOCD_BINARY_NAME", "argocd")
}).
Path("guestbook-symlink-files").
When().
CreateFromFile(func(app *Application) {
app.Spec.Source.Plugin = &ApplicationSourcePlugin{Name: "cmp-symlink-v1.0"}
}).
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy))
}
10 changes: 10 additions & 0 deletions test/e2e/testdata/cmp-symlink/plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
name: cmp-symlink
spec:
version: v1.0
init:
command: [kustomize, version]
generate:
command: [sh, -c, 'kustomize build --load-restrictor LoadRestrictionsNone']
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: guestbook-ui
spec:
ports:
- port: 80
targetPort: 80
selector:
app: guestbook-ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ./guestbook-ui-deployment.yaml
- ./guestbook-ui-svc.yaml
1 change: 1 addition & 0 deletions test/e2e/testdata/guestbook-symlink-folder