Skip to content

Commit e35a2b7

Browse files
authored
Add entitlement check in gitops-repo-broker (#170)
* Move entitlement into common package * Add entitlement middleware to gitops-repo-broker API * Wire in logr implementation * Code review changes * Increase timeout * Add test to ensure middleware is wired up correctly to gitops-repo-broker * Add test when no entitlement exist * Code review changes * Simplify scheme registration
1 parent 546c4f6 commit e35a2b7

File tree

27 files changed

+925
-739
lines changed

27 files changed

+925
-739
lines changed

.github/workflows/deploy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install Go
2525
uses: actions/setup-go@v2
2626
with:
27-
go-version: 1.16.x
27+
go-version: 1.17.x
2828
- name: Configure git for private modules
2929
env:
3030
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -111,7 +111,7 @@ jobs:
111111
- name: Install Go
112112
uses: actions/setup-go@v2
113113
with:
114-
go-version: 1.16.x
114+
go-version: 1.17.x
115115
- name: Checkout code
116116
uses: actions/checkout@v2
117117
- name: Configure git for private modules
@@ -197,7 +197,7 @@ jobs:
197197
- name: Install Go
198198
uses: actions/setup-go@v2
199199
with:
200-
go-version: 1.16.x
200+
go-version: 1.17.x
201201
- name: Checkout code
202202
uses: actions/checkout@v2
203203
with:

.github/workflows/nightly.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Go
2424
uses: actions/setup-go@v2
2525
with:
26-
go-version: 1.16.x
26+
go-version: 1.17.x
2727
- name: Configure git for private modules
2828
env:
2929
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -137,7 +137,7 @@ jobs:
137137
- name: Install Go
138138
uses: actions/setup-go@v2
139139
with:
140-
go-version: 1.16.x
140+
go-version: 1.17.x
141141
- name: Checkout code
142142
uses: actions/checkout@v2
143143
with:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install Go
2727
uses: actions/setup-go@v2
2828
with:
29-
go-version: 1.16.x
29+
go-version: 1.17.x
3030
- name: Configure git for private modules
3131
env:
3232
GITHUB_BUILD_USERNAME: wge-build-bot

.github/workflows/test.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Install Go
5555
uses: actions/setup-go@v2
5656
with:
57-
go-version: 1.16.x
57+
go-version: 1.17.x
5858
- name: Configure git for private modules
5959
env:
6060
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -109,7 +109,7 @@ jobs:
109109
- name: Install Go
110110
uses: actions/setup-go@v2
111111
with:
112-
go-version: 1.16.x
112+
go-version: 1.17.x
113113
- name: Configure git for private modules
114114
env:
115115
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -194,7 +194,7 @@ jobs:
194194
- name: Install Go
195195
uses: actions/setup-go@v2
196196
with:
197-
go-version: 1.16.x
197+
go-version: 1.17.x
198198
- name: Configure git for private modules
199199
env:
200200
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -246,7 +246,7 @@ jobs:
246246
- name: Install Go
247247
uses: actions/setup-go@v2
248248
with:
249-
go-version: 1.16.x
249+
go-version: 1.17.x
250250
- name: Configure git for private modules
251251
env:
252252
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -319,7 +319,7 @@ jobs:
319319
- name: Install Go
320320
uses: actions/setup-go@v2
321321
with:
322-
go-version: 1.16.x
322+
go-version: 1.17.x
323323
- name: Configure git for private modules
324324
env:
325325
GITHUB_BUILD_USERNAME: wge-build-bot
@@ -436,7 +436,7 @@ jobs:
436436
- name: Install Go
437437
uses: actions/setup-go@v2
438438
with:
439-
go-version: 1.16.x
439+
go-version: 1.17.x
440440
- name: Configure git for private modules
441441
env:
442442
GITHUB_BUILD_USERNAME: wge-build-bot

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cmd/event-writer/$(UPTODATE): cmd/event-writer/Dockerfile cmd/event-writer/*
4141
--build-arg=version=$(VERSION) \
4242
--build-arg=image_tag=$(IMAGE_TAG) \
4343
--build-arg=revision=$(GIT_REVISION) \
44+
--build-arg=GITHUB_BUILD_TOKEN=$(GITHUB_BUILD_TOKEN) \
4445
--tag $(IMAGE_PREFIX)$(subst wkp-,,$(shell basename $(@D))) \
4546
--file cmd/event-writer/Dockerfile \
4647
.

charts/mccp/templates/gitops-repo-broker/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
imagePullSecrets:
2121
{{- toYaml . | nindent 8 }}
2222
{{- end }}
23+
serviceAccountName: {{ include "mccp.serviceAccountName" . }}
2324
volumes:
2425
- name: git-key
2526
secret:

cmd/capi-server/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
"github.com/weaveworks/go-checkpoint"
1515
ent "github.com/weaveworks/weave-gitops-enterprise-credentials/pkg/entitlement"
1616
capiv1 "github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/api/v1alpha1"
17-
"github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/entitlement"
1817
"github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/git"
1918
capi_proto "github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/protos"
2019
"github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/server"
2120
"github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/templates"
2221
"github.com/weaveworks/weave-gitops-enterprise/cmd/capi-server/pkg/version"
2322
"github.com/weaveworks/weave-gitops-enterprise/common/database/utils"
23+
"github.com/weaveworks/weave-gitops-enterprise/common/entitlement"
2424
wego_proto "github.com/weaveworks/weave-gitops/pkg/api/applications"
2525
"github.com/weaveworks/weave-gitops/pkg/middleware"
2626
wego_server "github.com/weaveworks/weave-gitops/pkg/server"

cmd/capi-server/app/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func createSecret(s string) *corev1.Secret {
8484
Name: "name",
8585
Namespace: "namespace",
8686
},
87-
Type: "Opaque",
87+
Type: corev1.SecretTypeOpaque,
8888
Data: map[string][]byte{"entitlement": []byte(s)},
8989
}
9090
}

cmd/capi-server/go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ go 1.17
44

55
require (
66
github.com/fluxcd/go-git-providers v0.2.1-0.20210908163615-833963032787
7-
github.com/golang-jwt/jwt/v4 v4.0.0
7+
github.com/go-logr/logr v1.1.0
8+
github.com/go-logr/zapr v1.1.0
89
github.com/google/go-cmp v0.5.6
910
github.com/google/go-github/v32 v32.1.0
1011
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
@@ -19,19 +20,20 @@ require (
1920
github.com/weaveworks/weave-gitops-enterprise-credentials v0.0.1
2021
github.com/weaveworks/weave-gitops-enterprise/common v0.0.0-00010101000000-000000000000
2122
github.com/xanzy/go-gitlab v0.43.0
23+
go.uber.org/zap v1.19.0
2224
golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1
2325
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced
2426
google.golang.org/grpc v1.38.0
2527
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
2628
google.golang.org/protobuf v1.27.1
2729
gopkg.in/src-d/go-git.v4 v4.13.1
2830
gorm.io/gorm v1.21.11
29-
k8s.io/api v0.22.1
30-
k8s.io/apimachinery v0.22.1
31-
k8s.io/client-go v0.22.1
31+
k8s.io/api v0.22.2
32+
k8s.io/apimachinery v0.22.2
33+
k8s.io/client-go v0.22.2
3234
k8s.io/klog/v2 v2.9.0
3335
sigs.k8s.io/cluster-api v0.3.16
34-
sigs.k8s.io/controller-runtime v0.9.1
36+
sigs.k8s.io/controller-runtime v0.9.6
3537
sigs.k8s.io/kustomize/kyaml v0.11.0
3638
sigs.k8s.io/yaml v1.2.0
3739
)
@@ -71,12 +73,11 @@ require (
7173
github.com/go-git/gcfg v1.5.0 // indirect
7274
github.com/go-git/go-billy/v5 v5.3.1 // indirect
7375
github.com/go-git/go-git/v5 v5.4.2 // indirect
74-
github.com/go-logr/logr v1.1.0 // indirect
75-
github.com/go-logr/zapr v1.1.0 // indirect
7676
github.com/go-openapi/jsonpointer v0.19.5 // indirect
7777
github.com/go-openapi/jsonreference v0.19.5 // indirect
7878
github.com/go-openapi/swag v0.19.14 // indirect
7979
github.com/gogo/protobuf v1.3.2 // indirect
80+
github.com/golang-jwt/jwt/v4 v4.0.0 // indirect
8081
github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect
8182
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
8283
github.com/golang/protobuf v1.5.2 // indirect
@@ -118,7 +119,7 @@ require (
118119
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
119120
github.com/modern-go/reflect2 v1.0.1 // indirect
120121
github.com/olekukonko/tablewriter v0.0.5 // indirect
121-
github.com/onsi/gomega v1.13.0 // indirect
122+
github.com/onsi/gomega v1.14.0 // indirect
122123
github.com/pelletier/go-toml v1.9.3 // indirect
123124
github.com/pkg/errors v0.9.1 // indirect
124125
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -136,7 +137,6 @@ require (
136137
github.com/xanzy/ssh-agent v0.3.0 // indirect
137138
go.uber.org/atomic v1.7.0 // indirect
138139
go.uber.org/multierr v1.6.0 // indirect
139-
go.uber.org/zap v1.19.0 // indirect
140140
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
141141
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
142142
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 // indirect
@@ -155,10 +155,10 @@ require (
155155
gorm.io/datatypes v1.0.0 // indirect
156156
gorm.io/driver/postgres v1.0.5 // indirect
157157
gorm.io/driver/sqlite v1.1.4 // indirect
158-
k8s.io/apiextensions-apiserver v0.21.2 // indirect
158+
k8s.io/apiextensions-apiserver v0.21.3 // indirect
159159
k8s.io/component-base v0.22.1 // indirect
160160
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
161-
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 // indirect
161+
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
162162
sigs.k8s.io/kustomize/kstatus v0.0.2 // indirect
163163
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
164164
)

0 commit comments

Comments
 (0)