Skip to content

Cannot use argocd-commenter with multiple sources #849

@bennesp

Description

@bennesp

ArgoCD v2.6 ships with a very nice feature that enables people to use multiple sources in a single Application.

This can come very handy when you want for example to define helm values in separate file in the Git repository, or for many other use cases. For further references, see here https://github.com/argoproj/argo-cd/blob/master/docs/proposals/multiple-sources-for-applications.md and here argoproj/argo-cd#10432

The current implementation of argocd-commenter is using only the .source part of the spec, ignoring the .sources one, in this function:

func NewCommentOnOnPhaseChanged(app argocdv1alpha1.Application, argocdURL string) *Comment {
repository := github.ParseRepositoryURL(app.Spec.Source.RepoURL)
if repository == nil {
return nil
}
revision := argocd.GetDeployedRevision(app)
if revision == "" {
return nil
}
body := generateCommentOnPhaseChanged(app, argocdURL)
if body == "" {
return nil
}
return &Comment{
GitHubRepository: *repository,
Revision: revision,
Body: body,
}
}

A workaround like using both source and sources in the Application definition (so that ArgoCD will ignore the source while using the sources, while argocd-commenter will pick the source and will ignore the sources) won't work because of how the status is now: instead of using .revision, now we have .revisions, so the following function will return an empty string, causing the caller to return nil and thus not creating any comment

func GetDeployedRevision(a argocdv1alpha1.Application) string {
if a.Status.OperationState == nil {
return ""
}
if a.Status.OperationState.Operation.Sync == nil {
return ""
}
return a.Status.OperationState.Operation.Sync.Revision
}

It would be great to have the new "multiple sources" feature implemented also on this project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions