Skip to content

Commit 57eb6fc

Browse files
committed
feat: add filter path support
1 parent 5e86d7e commit 57eb6fc

11 files changed

+462
-15
lines changed

api/v1alpha1/changetransferpolicy_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ type ChangeTransferPolicySpec struct {
5151
// ProposedCommitStatuses lists the statuses to be monitored on the proposed branch
5252
// +kubebuilder:validation:Optional
5353
ProposedCommitStatuses []CommitStatusSelector `json:"proposedCommitStatuses"`
54+
55+
// +kubebuilder:validation:Optional
56+
OpenPullerRequestFilter *OpenPullerRequestFilter `json:"openPullRequestFilter,omitempty"`
5457
}
5558

5659
type ChangeRequestPolicyCommitStatusPhase struct {

api/v1alpha1/common_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ type ObjectReference struct {
1212
// +kubebuilder:validation:Required
1313
Name string `json:"name"`
1414
}
15+
16+
type OpenPullerRequestFilter struct {
17+
Paths []string `json:"paths,omitempty"`
18+
}

api/v1alpha1/promotionstrategy_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ type PromotionStrategySpec struct {
5151
// Environments is the sequence of environments that a dry commit will be promoted through.
5252
// +kubebuilder:validation:MinItems:=1
5353
Environments []Environment `json:"environments"`
54+
55+
// +kubebuilder:validation:Optional
56+
OpenPullerRequestFilter *OpenPullerRequestFilter `json:"openPullRequestFilter,omitempty"`
5457
}
5558

5659
type Environment struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/promoter.argoproj.io_changetransferpolicies.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ spec:
7373
required:
7474
- name
7575
type: object
76+
openPullRequestFilter:
77+
properties:
78+
paths:
79+
items:
80+
type: string
81+
type: array
82+
type: object
7683
proposedBranch:
7784
description: ProposedBranch staging hydrated branch
7885
type: string

config/crd/bases/promoter.argoproj.io_promotionstrategies.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ spec:
120120
required:
121121
- name
122122
type: object
123+
openPullRequestFilter:
124+
properties:
125+
paths:
126+
items:
127+
type: string
128+
type: array
129+
type: object
123130
proposedCommitStatuses:
124131
description: |-
125132
ProposedCommitStatuses are commit statuses describing a proposed dry commit, i.e. one that is not yet running

dist/install.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ spec:
8585
required:
8686
- name
8787
type: object
88+
openPullRequestFilter:
89+
properties:
90+
paths:
91+
items:
92+
type: string
93+
type: array
94+
type: object
8895
proposedBranch:
8996
description: ProposedBranch staging hydrated branch
9097
type: string
@@ -492,6 +499,13 @@ spec:
492499
required:
493500
- name
494501
type: object
502+
openPullRequestFilter:
503+
properties:
504+
paths:
505+
items:
506+
type: string
507+
type: array
508+
type: object
495509
proposedCommitStatuses:
496510
description: |-
497511
ProposedCommitStatuses are commit statuses describing a proposed dry commit, i.e. one that is not yet running

internal/controller/changetransferpolicy_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (r *ChangeTransferPolicyReconciler) mergeOrPullRequestPromote(ctx context.C
308308
return nil
309309
}
310310

311-
prRequired, err := gitOperations.IsPullRequestRequired(ctx, ctp.Spec.ProposedBranch, ctp.Spec.ActiveBranch)
311+
prRequired, err := gitOperations.IsPullRequestRequired(ctx, ctp.Spec.OpenPullerRequestFilter, ctp.Spec.ProposedBranch, ctp.Spec.ActiveBranch)
312312
if err != nil {
313313
return fmt.Errorf("failed to check whether a PR is required from branch %q to %q: %w", ctp.Spec.ProposedBranch, ctp.Spec.ActiveBranch, err)
314314
}

internal/controller/promotionstrategy_controller.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ func (r *PromotionStrategyReconciler) upsertChangeTransferPolicy(ctx context.Con
155155
},
156156
},
157157
Spec: promoterv1alpha1.ChangeTransferPolicySpec{
158-
RepositoryReference: ps.Spec.RepositoryReference,
159-
ProposedBranch: fmt.Sprintf("%s-%s", environment.Branch, "next"),
160-
ActiveBranch: environment.Branch,
161-
ActiveCommitStatuses: append(environment.ActiveCommitStatuses, ps.Spec.ActiveCommitStatuses...),
162-
ProposedCommitStatuses: append(environment.ProposedCommitStatuses, ps.Spec.ProposedCommitStatuses...),
163-
AutoMerge: environment.AutoMerge,
158+
RepositoryReference: ps.Spec.RepositoryReference,
159+
ProposedBranch: fmt.Sprintf("%s-%s", environment.Branch, "next"),
160+
ActiveBranch: environment.Branch,
161+
ActiveCommitStatuses: append(environment.ActiveCommitStatuses, ps.Spec.ActiveCommitStatuses...),
162+
ProposedCommitStatuses: append(environment.ProposedCommitStatuses, ps.Spec.ProposedCommitStatuses...),
163+
AutoMerge: environment.AutoMerge,
164+
OpenPullerRequestFilter: ps.Spec.OpenPullerRequestFilter,
164165
},
165166
}
166167

0 commit comments

Comments
 (0)