Skip to content
Merged
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
14 changes: 10 additions & 4 deletions pkg/pipelines/tekton/resources_pac.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ func ensurePACRepositoryExists(ctx context.Context, f fn.Function, namespace str
repoNotFound = true
}

// TODO we should also compare labels and annotations
if repoNotFound || !equality.Semantic.DeepDerivative(existingRepo.Spec, repo.Spec) {
// Decide whether create or update
needsUpdate := repoNotFound ||
!equality.Semantic.DeepDerivative(existingRepo.Spec, repo.Spec) ||
!equality.Semantic.DeepEqual(existingRepo.Labels, repo.Labels) ||
!equality.Semantic.DeepEqual(existingRepo.Annotations, repo.Annotations)

if needsUpdate {
if repoNotFound {
_, err = client.Repositories(namespace).Create(ctx, &repo, metav1.CreateOptions{})
} else {
_, err = client.Repositories(namespace).Update(ctx, &repo, metav1.UpdateOptions{})
existingRepo.Spec = repo.Spec
existingRepo.Labels = repo.Labels
existingRepo.Annotations = repo.Annotations
_, err = client.Repositories(namespace).Update(ctx, existingRepo, metav1.UpdateOptions{})
}
if err != nil {
return err
Expand Down
Loading