Skip to content

Commit

Permalink
ensure multi source spec is handled
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu McCloskey <[email protected]>
  • Loading branch information
nabuskey committed Dec 26, 2023
1 parent 9cf1434 commit 0e89480
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/controllers/custompackage/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *Reconciler) reconcileCustomPackage(ctx context.Context, resource *v1alp
synced := true
if app.Spec.HasMultipleSources() {
for j := range app.Spec.Sources {
s := app.Spec.Sources[j]
s := &app.Spec.Sources[j]
res, repo, sErr := r.reconcileArgocdSource(ctx, resource, appName, resource.Spec.ArgoCD.ApplicationFile, s.RepoURL)
if sErr != nil {
return res, sErr
Expand Down
32 changes: 32 additions & 0 deletions pkg/controllers/custompackage/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ func TestReconcileCustomPkg(t *testing.T) {
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "test3",
Namespace: "test",
UID: "abc",
},
Spec: v1alpha1.CustomPackageSpec{
Replicate: true,
GitServerURL: "https://cnoe.io",
InternalGitServeURL: "http://internal.cnoe.io",
ArgoCD: v1alpha1.ArgoCDPackageSpec{
ApplicationFile: filepath.Join(cwd, "test/resources/customPackages/testDir/app2.yaml"),
Name: "my-app2",
Namespace: "argocd",
},
},
},
}

for _, n := range []string{"argocd", "test"} {
Expand Down Expand Up @@ -182,4 +199,19 @@ func TestReconcileCustomPkg(t *testing.T) {
t.Fatalf("expected %s arogapp : %v", n, err)
}
}

localApp2 := argov1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "my-app2",
Namespace: "argocd",
},
}
err = c.Get(context.Background(), client.ObjectKeyFromObject(&localApp2), &localApp2)
if err != nil {
t.Fatalf("failed getting my-app2 %v", err)
}

if strings.HasPrefix(localApp2.Spec.Sources[0].RepoURL, "cnoe://") {
t.Fatalf("cnoe:// prefix should be removed")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app2
namespace: argocd
spec:
destination:
namespace: my-app2
server: "https://kubernetes.default.svc"
sources:
- repoURL: cnoe://busybox
targetRevision: HEAD
path: "."
project: default
syncPolicy:
automated:
selfHeal: true
syncOptions:
- CreateNamespace=true

0 comments on commit 0e89480

Please sign in to comment.