Skip to content

Commit

Permalink
Add nil check of ApplicationSpec.Source (#891)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Mar 9, 2023
1 parent 4eb44ef commit d56671a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/notification/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type Comment struct {
}

func NewCommentOnOnPhaseChanged(app argocdv1alpha1.Application, argocdURL string) *Comment {
if app.Spec.Source == nil {
return nil
}
repository := github.ParseRepositoryURL(app.Spec.Source.RepoURL)
if repository == nil {
return nil
Expand Down Expand Up @@ -81,6 +84,9 @@ func generateSyncResultComment(app argocdv1alpha1.Application) string {
}

func NewCommentOnOnHealthChanged(app argocdv1alpha1.Application, argocdURL string) *Comment {
if app.Spec.Source == nil {
return nil
}
repository := github.ParseRepositoryURL(app.Spec.Source.RepoURL)
if repository == nil {
return nil
Expand Down
7 changes: 7 additions & 0 deletions pkg/notification/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func filterPullRequestsRelatedToEvent(pulls []github.PullRequest, app argocdv1al
}

func isPullRequestRelatedToEvent(pull github.PullRequest, app argocdv1alpha1.Application) bool {
if app.Spec.Source == nil {
return false
}

// support manifest path annotation
// see https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability/#webhook-and-manifest-paths-annotation
// https://github.com/int128/argocd-commenter/pull/656
Expand All @@ -44,6 +48,9 @@ func getManifestGeneratePaths(app argocdv1alpha1.Application) []string {
if app.Annotations == nil {
return nil
}
if app.Spec.Source == nil {
return nil
}
var canonicalPaths []string
annotatedPaths := strings.Split(app.Annotations["argocd.argoproj.io/manifest-generate-paths"], ";")
for _, path := range annotatedPaths {
Expand Down

0 comments on commit d56671a

Please sign in to comment.