Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit dff3c3e

Browse files
authored
feat: create branch protection rules for github (#42)
* feat: create branch protection rules * adding creating a git repository object to track values file changes
1 parent 366b1a0 commit dff3c3e

File tree

14 files changed

+187
-45
lines changed

14 files changed

+187
-45
lines changed

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# git-controller
2-
// TODO(user): Add simple overview of use/purpose
2+
3+
[![REUSE status](https://api.reuse.software/badge/github.com/open-component-model/git-controller)](https://api.reuse.software/info/github.com/open-component-model/git-controller)
34

45
## Description
56
// TODO(user): An in-depth paragraph about your project and overview of use
@@ -76,19 +77,8 @@ make manifests
7677

7778
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
7879

79-
## License
80-
81-
Copyright 2022.
82-
83-
Licensed under the Apache License, Version 2.0 (the "License");
84-
you may not use this file except in compliance with the License.
85-
You may obtain a copy of the License at
86-
87-
http://www.apache.org/licenses/LICENSE-2.0
88-
89-
Unless required by applicable law or agreed to in writing, software
90-
distributed under the License is distributed on an "AS IS" BASIS,
91-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92-
See the License for the specific language governing permissions and
93-
limitations under the License.
80+
## Licensing
9481

82+
Copyright 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
83+
Please see our [LICENSE](LICENSE) for copyright and license information.
84+
Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/open-component-model/ocm-controller).

apis/delivery/v1alpha1/condition_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ const (
2222

2323
// CreatePullRequestFailedReason is used when creating a pull request failed.
2424
CreatePullRequestFailedReason = "CreatePullRequestFailed"
25+
26+
// GitRepositoryCreateFailedReason is used when creating a git repository failed.
27+
GitRepositoryCreateFailedReason = "GitRepositoryCreateFailed"
2528
)

apis/mpas/v1alpha1/condition_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ package v1alpha1
77
const (
88
// RepositoryCreateFailedReason is used when we fail to create a Repository.
99
RepositoryCreateFailedReason = "RepositoryCreateFailed"
10+
11+
// UpdatingBranchProtectionFailedReason is used when we fail to update a branch protection rules.
12+
UpdatingBranchProtectionFailedReason = "UpdatingBranchProtectionFailed"
1013
)

controllers/delivery/sync_controller.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ import (
1313
"github.com/fluxcd/pkg/apis/meta"
1414
"github.com/fluxcd/pkg/runtime/conditions"
1515
"github.com/fluxcd/pkg/runtime/patch"
16+
sourcebeta2 "github.com/fluxcd/source-controller/api/v1beta2"
1617
corev1 "k8s.io/api/core/v1"
1718
apierrors "k8s.io/apimachinery/pkg/api/errors"
1819
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
"k8s.io/apimachinery/pkg/runtime"
2021
"k8s.io/apimachinery/pkg/types"
22+
"k8s.io/utils/pointer"
2123
ctrl "sigs.k8s.io/controller-runtime"
2224
"sigs.k8s.io/controller-runtime/pkg/builder"
2325
"sigs.k8s.io/controller-runtime/pkg/client"
26+
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2427
"sigs.k8s.io/controller-runtime/pkg/log"
2528
"sigs.k8s.io/controller-runtime/pkg/predicate"
2629

@@ -226,6 +229,14 @@ func (r *SyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
226229

227230
return ctrl.Result{}, err
228231
}
232+
233+
// Create GitRepository to track values file changes.
234+
if err := r.createValueFileGitRepository(ctx, *obj, *repository, targetBranch); err != nil {
235+
err = fmt.Errorf("failed to create value tracking git repository object: %w", err)
236+
conditions.MarkFalse(obj, meta.ReadyCondition, v1alpha1.GitRepositoryCreateFailedReason, err.Error())
237+
238+
return ctrl.Result{}, err
239+
}
229240
}
230241

231242
// Remove any stale Ready condition, most likely False, set above. Its value
@@ -264,3 +275,47 @@ func (r *SyncReconciler) parseAuthSecret(secret *corev1.Secret, opts *pkg.PushOp
264275
},
265276
}
266277
}
278+
279+
// createValueFileGitRepository creates a GitRepository that tracks changes on a branch.
280+
func (r *SyncReconciler) createValueFileGitRepository(ctx context.Context, sync v1alpha1.Sync, repository mpasv1alpha1.Repository, branch string) error {
281+
owners := sync.GetOwnerReferences()
282+
if len(owners) != 1 {
283+
return fmt.Errorf("expected exactly one owner, got: %d", len(owners))
284+
}
285+
286+
repo := &sourcebeta2.GitRepository{
287+
ObjectMeta: metav1.ObjectMeta{
288+
Name: repository.Name + "values-repo",
289+
Namespace: repository.Namespace,
290+
},
291+
Spec: sourcebeta2.GitRepositorySpec{
292+
URL: repository.GetRepositoryURL(),
293+
SecretRef: &meta.LocalObjectReference{
294+
Name: repository.Spec.Credentials.SecretRef.Name,
295+
},
296+
Interval: metav1.Duration{Duration: 5 * time.Second},
297+
Reference: &sourcebeta2.GitRepositoryRef{
298+
Branch: branch,
299+
},
300+
Ignore: pointer.String(fmt.Sprintf(`# exclude all
301+
/*
302+
# include values.yaml
303+
!./products/%s/values.yaml
304+
`, owners[0].Name)),
305+
},
306+
}
307+
308+
if _, err := controllerutil.CreateOrUpdate(ctx, r.Client, repo, func() error {
309+
if repo.ObjectMeta.CreationTimestamp.IsZero() {
310+
if err := controllerutil.SetOwnerReference(&repository, repo, r.Scheme); err != nil {
311+
return fmt.Errorf("failed to set owner to git repository object: %w", err)
312+
}
313+
}
314+
315+
return nil
316+
}); err != nil {
317+
return fmt.Errorf("failed to create git repository: %w", err)
318+
}
319+
320+
return nil
321+
}

controllers/delivery/sync_controller_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/fluxcd/pkg/apis/meta"
1313
"github.com/fluxcd/pkg/runtime/conditions"
14+
sourcebeta2 "github.com/fluxcd/source-controller/api/v1beta2"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
1617
v1 "k8s.io/api/core/v1"
@@ -193,6 +194,11 @@ func TestSyncReconcilerWithAutomaticPullRequest(t *testing.T) {
193194
ObjectMeta: metav1.ObjectMeta{
194195
Name: "git-test",
195196
Namespace: "default",
197+
OwnerReferences: []metav1.OwnerReference{
198+
{
199+
Name: "whatever",
200+
},
201+
},
196202
},
197203
Spec: v1alpha1.SyncSpec{
198204
SnapshotRef: v1.LocalObjectReference{
@@ -213,7 +219,12 @@ func TestSyncReconcilerWithAutomaticPullRequest(t *testing.T) {
213219
},
214220
}
215221

216-
client := env.FakeKubeClient(WithObjets(sync, snapshot, secret, repository), WithAddToScheme(ocmv1.AddToScheme), WithAddToScheme(mpasv1alpha1.AddToScheme))
222+
client := env.FakeKubeClient(
223+
WithObjets(sync, snapshot, secret, repository),
224+
WithAddToScheme(ocmv1.AddToScheme),
225+
WithAddToScheme(mpasv1alpha1.AddToScheme),
226+
WithAddToScheme(sourcebeta2.AddToScheme),
227+
)
217228
m := &mockGit{
218229
digest: "test-digest",
219230
}

controllers/mpas/repository_controller.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,29 @@ func (r *RepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error {
123123
}
124124

125125
func (r *RepositoryReconciler) reconcile(ctx context.Context, obj *mpasv1alpha1.Repository) (ctrl.Result, error) {
126+
logger := log.FromContext(ctx)
127+
128+
logger.Info("creating or adopting repository")
126129
if err := r.Provider.CreateRepository(ctx, *obj); err != nil {
127130
conditions.MarkFalse(obj, meta.ReadyCondition, mpasv1alpha1.RepositoryCreateFailedReason, err.Error())
128131

129132
return ctrl.Result{}, fmt.Errorf("failed to create repository: %w", err)
130133
}
131134

135+
logger.Info("updating branch protection rules")
136+
if err := r.Provider.CreateBranchProtection(ctx, *obj); err != nil {
137+
if errors.Is(err, providers.NotSupportedError) {
138+
// ignore and return without branch protection rules.
139+
logger.Error(err, fmt.Sprintf("provider %s does not support updating branch protection rules", obj.Spec.Provider))
140+
141+
return ctrl.Result{}, nil
142+
}
143+
144+
conditions.MarkFalse(obj, meta.ReadyCondition, mpasv1alpha1.UpdatingBranchProtectionFailedReason, err.Error())
145+
146+
return ctrl.Result{}, fmt.Errorf("failed to update branch protection rules: %w", err)
147+
}
148+
149+
logger.Info("done reconciling repository")
132150
return ctrl.Result{}, nil
133151
}

go.mod

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ require (
99
github.com/fluxcd/go-git-providers v0.15.0
1010
github.com/fluxcd/pkg/apis/meta v0.19.0
1111
github.com/fluxcd/pkg/runtime v0.27.0
12+
github.com/fluxcd/source-controller/api v0.33.0
1213
github.com/go-git/go-git/v5 v5.6.0
1314
github.com/go-logr/logr v1.2.3
15+
github.com/google/go-github/v52 v52.0.0
1416
github.com/open-component-model/ocm-controller v0.4.0
1517
github.com/stretchr/testify v1.8.1
18+
golang.org/x/oauth2 v0.7.0
1619
k8s.io/api v0.26.2
1720
k8s.io/apimachinery v0.26.2
1821
k8s.io/client-go v0.26.2
22+
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
1923
sigs.k8s.io/controller-runtime v0.14.4
2024
)
2125

@@ -66,6 +70,7 @@ require (
6670
github.com/emirpasic/gods v1.18.1 // indirect
6771
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
6872
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
73+
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
6974
github.com/fsnotify/fsnotify v1.6.0 // indirect
7075
github.com/fvbommel/sortorder v1.0.2 // indirect
7176
github.com/ghodss/yaml v1.0.0 // indirect
@@ -148,14 +153,13 @@ require (
148153
go.uber.org/atomic v1.10.0 // indirect
149154
go.uber.org/multierr v1.9.0 // indirect
150155
go.uber.org/zap v1.24.0 // indirect
151-
golang.org/x/crypto v0.6.0 // indirect
156+
golang.org/x/crypto v0.7.0 // indirect
152157
golang.org/x/mod v0.8.0 // indirect
153-
golang.org/x/net v0.8.0 // indirect
154-
golang.org/x/oauth2 v0.6.0 // indirect
158+
golang.org/x/net v0.9.0 // indirect
155159
golang.org/x/sync v0.1.0 // indirect
156-
golang.org/x/sys v0.6.0 // indirect
157-
golang.org/x/term v0.6.0 // indirect
158-
golang.org/x/text v0.8.0 // indirect
160+
golang.org/x/sys v0.7.0 // indirect
161+
golang.org/x/term v0.7.0 // indirect
162+
golang.org/x/text v0.9.0 // indirect
159163
golang.org/x/time v0.3.0 // indirect
160164
golang.org/x/tools v0.6.0 // indirect
161165
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
@@ -171,7 +175,6 @@ require (
171175
k8s.io/component-base v0.26.2 // indirect
172176
k8s.io/klog/v2 v2.90.0 // indirect
173177
k8s.io/kube-openapi v0.0.0-20230228151317-19cbebb19cb7 // indirect
174-
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect
175178
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
176179
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
177180
sigs.k8s.io/yaml v1.3.0 // indirect

go.sum

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,14 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd
477477
github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0=
478478
github.com/fluxcd/go-git-providers v0.15.0 h1:WuBw+CcmXi7UhSf8mFNB6tbGelS0kVlgI9wtlWjzimk=
479479
github.com/fluxcd/go-git-providers v0.15.0/go.mod h1:SgShGfc2rA5Gi7N65CBjMOIolarDZzZCMzEHOoY3P0I=
480+
github.com/fluxcd/pkg/apis/acl v0.1.0 h1:EoAl377hDQYL3WqanWCdifauXqXbMyFuK82NnX6pH4Q=
481+
github.com/fluxcd/pkg/apis/acl v0.1.0/go.mod h1:zfEZzz169Oap034EsDhmCAGgnWlcWmIObZjYMusoXS8=
480482
github.com/fluxcd/pkg/apis/meta v0.19.0 h1:CX75e/eaRWZDTzNdMSWomY1InlssLKcS8GQDSg/aopI=
481483
github.com/fluxcd/pkg/apis/meta v0.19.0/go.mod h1:7b6prDPsViyAzoY7eRfSPS0/MbXpGGsOMvRq2QrTKa4=
482484
github.com/fluxcd/pkg/runtime v0.27.0 h1:zVA95Z0KvNjvZxEZhvIbJyJIwtaiv1aVttHZ4YB/FzY=
483485
github.com/fluxcd/pkg/runtime v0.27.0/go.mod h1:fC1l4Wv1hnsqPKB46eDZBXF8RMZm5FXeU4bnJkwGkqk=
486+
github.com/fluxcd/source-controller/api v0.33.0 h1:NZYU3+MNf9puyrTbBa7AJbBDlN7tmt0uw8lyye++5fE=
487+
github.com/fluxcd/source-controller/api v0.33.0/go.mod h1:+DiGND4WSNdGkS7loPUroSarif6dHU4VlVgtLMRKCR8=
484488
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
485489
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
486490
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
@@ -638,6 +642,8 @@ github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FC
638642
github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28=
639643
github.com/google/go-github/v49 v49.1.0 h1:LFkMgawGQ8dfzWLH/rNE0b3u1D3n6/dw7ZmrN3b+YFY=
640644
github.com/google/go-github/v49 v49.1.0/go.mod h1:MUUzHPrhGniB6vUKa27y37likpipzG+BXXJbG04J334=
645+
github.com/google/go-github/v52 v52.0.0 h1:uyGWOY+jMQ8GVGSX8dkSwCzlehU3WfdxQ7GweO/JP7M=
646+
github.com/google/go-github/v52 v52.0.0/go.mod h1:WJV6VEEUPuMo5pXqqa2ZCZEdbQqua4zAk2MZTIo+m+4=
641647
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
642648
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
643649
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
@@ -1280,8 +1286,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
12801286
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
12811287
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
12821288
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
1283-
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
1284-
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
1289+
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
1290+
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
12851291
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12861292
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12871293
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1384,8 +1390,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
13841390
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
13851391
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
13861392
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
1387-
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
1388-
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
1393+
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
1394+
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
13891395
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13901396
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
13911397
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1399,8 +1405,8 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ
13991405
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
14001406
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
14011407
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
1402-
golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw=
1403-
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
1408+
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
1409+
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
14041410
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14051411
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14061412
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1524,8 +1530,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
15241530
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15251531
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15261532
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1527-
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
1528-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1533+
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
1534+
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15291535
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
15301536
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
15311537
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -1534,8 +1540,8 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
15341540
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
15351541
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
15361542
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
1537-
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
1538-
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
1543+
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
1544+
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
15391545
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
15401546
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
15411547
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1546,8 +1552,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
15461552
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
15471553
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
15481554
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
1549-
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
1550-
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
1555+
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
1556+
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
15511557
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
15521558
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
15531559
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

pkg/providers/fakes/fake_provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func (p *Provider) CreateRepositoryCallArgsForNumber(i int) ([]any, error) {
6262
return args, nil
6363
}
6464

65+
func (p *Provider) CreateBranchProtection(ctx context.Context, obj mpasv1alpha1.Repository) error {
66+
return nil
67+
}
68+
6569
func NewProvider() *Provider {
6670
return &Provider{}
6771
}
68-
69-
var _ providers.Provider = &Provider{}

pkg/providers/gitea/gitea.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,7 @@ func (c *Client) CreatePullRequest(ctx context.Context, branch string, sync deli
204204

205205
return nil
206206
}
207+
208+
func (c *Client) CreateBranchProtection(ctx context.Context, obj mpasv1alpha1.Repository) error {
209+
return providers.NotSupportedError
210+
}

0 commit comments

Comments
 (0)