Skip to content

Commit

Permalink
add support for embedded apps
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu Mccloskey <[email protected]>
  • Loading branch information
nabuskey committed Nov 16, 2023
1 parent 9c07d61 commit ab7a85c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/controllers/gitrepository/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ func getEmbedded(name string) ([][]byte, error) {
switch name {
case "argocd":
return localbuild.GetRawInstallResources()
case "nginx":
return localbuild.RawNginxInstallResources()
default:
return nil, fmt.Errorf("unsupported embedded app name %s", name)
}
Expand Down
37 changes: 37 additions & 0 deletions pkg/controllers/gitrepository/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,43 @@ func TestGitRepositoryContentReconcile(t *testing.T) {
})
}

func TestGitRepositoryContentReconcileEmbedded(t *testing.T) {
ctx := context.Background()
dir, _, err := setUpLocalRepo()
defer os.RemoveAll(dir)
if err != nil {
t.Fatalf("failed setting up local git repo: %v", err)
}

m := metav1.ObjectMeta{
Name: "test",
Namespace: "test",
}
resource := v1alpha1.GitRepository{
ObjectMeta: m,
Spec: v1alpha1.GitRepositorySpec{
Source: v1alpha1.GitRepositorySource{
EmbeddedAppName: "nginx",
Type: "embedded",
},
},
}

t.Run("should sync embedded", func(t *testing.T) {
reconciler := RepositoryReconciler{
Client: fake.NewClientBuilder().Build(),
GiteaClientFN: func(url string, options ...gitea.ClientOption) (GiteaClient, error) {
return mockGitea{}, nil
},
}

err := reconciler.reconcileRepoContent(ctx, &resource, &gitea.Repository{CloneURL: dir})
if err != nil {
t.Fatalf("failed adding %v", err)
}
})
}

func TestGitRepositoryReconcile(t *testing.T) {
dir, hash, err := setUpLocalRepo()
defer os.RemoveAll(dir)
Expand Down

0 comments on commit ab7a85c

Please sign in to comment.