Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions util/notification/argocd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

type Service interface {
GetCommitMetadata(ctx context.Context, repoURL string, commitSHA string) (*shared.CommitMetadata, error)
GetAppDetails(ctx context.Context, appSource *v1alpha1.ApplicationSource) (*shared.AppDetail, error)
GetAppDetails(ctx context.Context, appSource *v1alpha1.ApplicationSource, appName string) (*shared.AppDetail, error)
}

func NewArgoCDService(clientset kubernetes.Interface, namespace string, repoClientset apiclient.Clientset) (*argoCDService, error) {
Expand Down Expand Up @@ -76,7 +76,7 @@ func (svc *argoCDService) getKustomizeOptions(source *v1alpha1.ApplicationSource
return kustomizeSettings.GetOptions(*source)
}

func (svc *argoCDService) GetAppDetails(ctx context.Context, appSource *v1alpha1.ApplicationSource) (*shared.AppDetail, error) {
func (svc *argoCDService) GetAppDetails(ctx context.Context, appSource *v1alpha1.ApplicationSource, appName string) (*shared.AppDetail, error) {
argocdDB := db.NewDB(svc.namespace, svc.settingsMgr, svc.clientset)
repo, err := argocdDB.GetRepository(ctx, appSource.RepoURL)
if err != nil {
Expand All @@ -95,6 +95,7 @@ func (svc *argoCDService) GetAppDetails(ctx context.Context, appSource *v1alpha1
return nil, err
}
appDetail, err := svc.repoServerClient.GetAppDetails(ctx, &apiclient.RepoServerAppDetailsQuery{
AppName: appName,
Repo: repo,
Source: appSource,
Repos: helmRepos,
Expand Down
12 changes: 6 additions & 6 deletions util/notification/expression/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ var (
gitSuffix = regexp.MustCompile(`\.git$`)
)

func getApplicationSource(obj *unstructured.Unstructured) (*v1alpha1.ApplicationSource, error) {
func getApplicationSourceAndName(obj *unstructured.Unstructured) (*v1alpha1.ApplicationSource, string, error) {
data, err := json.Marshal(obj)
if err != nil {
return nil, err
return nil, "", err
}
application := &v1alpha1.Application{}
err = json.Unmarshal(data, application)
if err != nil {
return nil, err
return nil, "", err
}
return application.Spec.GetSourcePtr(), nil
return application.Spec.GetSourcePtr(), application.GetName(), nil
}

func getAppDetails(app *unstructured.Unstructured, argocdService service.Service) (*shared.AppDetail, error) {
appSource, err := getApplicationSource(app)
appSource, appName, err := getApplicationSourceAndName(app)
if err != nil {
return nil, err
}
appDetail, err := argocdService.GetAppDetails(context.Background(), appSource)
appDetail, err := argocdService.GetAppDetails(context.Background(), appSource, appName)
if err != nil {
return nil, err
}
Expand Down