Skip to content

Commit 9683228

Browse files
Merge pull request #43 from PDOK/jd/ingressroute-finalizer
Added finalizer to ingressroute
2 parents f7e8577 + eef1c83 commit 9683228

File tree

7 files changed

+18
-54
lines changed

7 files changed

+18
-54
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/google/go-cmp v0.7.0
1111
github.com/onsi/ginkgo/v2 v2.22.1
1212
github.com/onsi/gomega v1.36.2
13-
github.com/pdok/atom-generator v0.6.3
13+
github.com/pdok/atom-generator v0.6.4
1414
github.com/pdok/smooth-operator v0.1.1
1515
github.com/peterbourgon/ff v1.7.1
1616
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
150150
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
151151
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
152152
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
153-
github.com/pdok/atom-generator v0.6.3 h1:wg491zQAokf6ePr1HcfVpF3mhMG2WroFPFpu14cX6Y0=
154-
github.com/pdok/atom-generator v0.6.3/go.mod h1:IlPwti5ocXDTjB4xmz0ZpHCOW/suuW5gQMfjfwPX6uM=
153+
github.com/pdok/atom-generator v0.6.4 h1:UpTTSKskdWLnxTAhSNOlz8dF2tBousD97V03kWzCV2k=
154+
github.com/pdok/atom-generator v0.6.4/go.mod h1:IlPwti5ocXDTjB4xmz0ZpHCOW/suuW5gQMfjfwPX6uM=
155155
github.com/pdok/smooth-operator v0.1.1 h1:rmsup4HmzJsxt4ZT9GWfj498dKLRfDhyuILeEkjju/A=
156156
github.com/pdok/smooth-operator v0.1.1/go.mod h1:przwM7mBGmNPqabyhImKVZ15WL4zbqLqH4ExbuWKhWE=
157157
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=

internal/controller/ingressroute.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ func (r *AtomReconciler) mutateIngressRoute(atom *pdoknlv3.Atom, ingressRoute *t
5656
},
5757
Middlewares: []traefikiov1alpha1.MiddlewareRef{
5858
{
59-
Name: atom.Name + headersSuffix,
60-
Namespace: atom.GetNamespace(),
59+
Name: atom.Name + headersSuffix,
6160
},
6261
{
63-
Name: atom.Name + stripPrefixSuffix,
64-
Namespace: atom.GetNamespace(),
62+
Name: atom.Name + stripPrefixSuffix,
6563
},
6664
},
6765
},
@@ -90,8 +88,7 @@ func (r *AtomReconciler) mutateIngressRoute(atom *pdoknlv3.Atom, ingressRoute *t
9088
},
9189
Middlewares: []traefikiov1alpha1.MiddlewareRef{
9290
{
93-
Name: atom.Name + headersSuffix,
94-
Namespace: atom.GetNamespace(),
91+
Name: atom.Name + headersSuffix,
9592
},
9693
},
9794
}
@@ -100,8 +97,7 @@ func (r *AtomReconciler) mutateIngressRoute(atom *pdoknlv3.Atom, ingressRoute *t
10097
// Set additional Azure storage middleware per download link
10198
for _, group := range getDownloadLinkGroups(atom.GetDownloadLinks()) {
10299
middlewareRef := traefikiov1alpha1.MiddlewareRef{
103-
Name: atom.Name + downloadsSuffix + strconv.Itoa(*group.index),
104-
Namespace: atom.GetNamespace(),
100+
Name: atom.Name + downloadsSuffix + strconv.Itoa(*group.index),
105101
}
106102
downloadMiddlewares = append(downloadMiddlewares, middlewareRef)
107103
}
@@ -114,6 +110,9 @@ func (r *AtomReconciler) mutateIngressRoute(atom *pdoknlv3.Atom, ingressRoute *t
114110

115111
ingressRoute.Spec.Routes = append(ingressRoute.Spec.Routes, azureStorageRule)
116112

113+
// Add finalizers
114+
ingressRoute.Finalizers = []string{"uptime.pdok.nl/finalizer"}
115+
117116
if err := smoothutil.EnsureSetGVK(r.Client, ingressRoute, ingressRoute); err != nil {
118117
return err
119118
}
@@ -145,12 +144,10 @@ func getDefaultRule(atom *pdoknlv3.Atom, matchRule string) traefikiov1alpha1.Rou
145144
},
146145
Middlewares: []traefikiov1alpha1.MiddlewareRef{
147146
{
148-
Name: atom.Name + headersSuffix,
149-
Namespace: atom.GetNamespace(),
147+
Name: atom.Name + headersSuffix,
150148
},
151149
{
152-
Name: atom.Name + stripPrefixSuffix,
153-
Namespace: atom.GetNamespace(),
150+
Name: atom.Name + stripPrefixSuffix,
154151
},
155152
},
156153
}

internal/controller/test_data/maximum-atom/expected-output/configmap.yaml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: maximum-atom-generator-mg8kmkb7c8
4+
name: maximum-atom-generator-f9tftfg7bh
55
namespace: default
66
labels:
77
test: test
@@ -30,21 +30,17 @@ data:
3030
subtitle: service-subtitle
3131
link:
3232
- href: https://test.com/path/index.xml
33-
data: null
3433
rel: self
3534
type: application/atom+xml
3635
title: service-title
3736
- href: https://test.com/csw?uuid=00000000-0000-0000-0000-000000000000
38-
data: null
3937
rel: describedby
4038
type: application/xml
4139
- href: https://test.com/html/00000000-0000-0000-0000-000000000000
42-
data: null
4340
rel: related
4441
type: text/html
4542
title: NGR pagina voor deze download service
4643
- href: https://test.com/open/00000000-0000-0000-0000-000000000000.xml
47-
data: null
4844
rel: search
4945
type: application/opensearchdescription+xml
5046
title: Open Search document voor INSPIRE Download service PDOK
@@ -58,11 +54,9 @@ data:
5854
summary: feed-1-subtitle
5955
link:
6056
- href: https://test.com/csw?uuid=00000000-0000-0000-0000-000000000001
61-
data: null
6257
rel: describedby
6358
type: application/xml
6459
- href: https://test.com/path/feed-1.xml
65-
data: null
6660
rel: alternate
6761
type: application/atom+xml
6862
title: feed-1-title
@@ -79,11 +73,9 @@ data:
7973
summary: feed-2-subtitle
8074
link:
8175
- href: https://test.com/csw?uuid=00000000-0000-0000-0000-000000000003
82-
data: null
8376
rel: describedby
8477
type: application/xml
8578
- href: https://test.com/path/feed-2.xml
86-
data: null
8779
rel: alternate
8880
type: application/atom+xml
8981
title: feed-2-title
@@ -104,24 +96,19 @@ data:
10496
subtitle: feed-1-subtitle
10597
link:
10698
- href: https://test.com/path/feed-1.xml
107-
data: null
10899
rel: self
109100
- href: https://test.com/path/index.xml
110-
data: null
111101
rel: up
112102
type: application/atom+xml
113103
title: Top Atom Download Service Feed
114104
- href: https://test.com/csw?uuid=00000000-0000-0000-0000-000000000001
115-
data: null
116105
rel: describedby
117106
type: application/xml
118107
- href: https://test.com/html/00000000-0000-0000-0000-000000000001
119-
data: null
120108
rel: related
121109
type: text/html
122110
title: NGR pagina voor deze dataset
123111
- href: https://test.com/encodingrule.pdf
124-
data: null
125112
rel: encodingRule
126113
type: application/pdf
127114
hreflang: en
@@ -176,19 +163,15 @@ data:
176163
subtitle: feed-2-subtitle
177164
link:
178165
- href: https://test.com/path/feed-2.xml
179-
data: null
180166
rel: self
181167
- href: https://test.com/path/index.xml
182-
data: null
183168
rel: up
184169
type: application/atom+xml
185170
title: Top Atom Download Service Feed
186171
- href: https://test.com/csw?uuid=00000000-0000-0000-0000-000000000003
187-
data: null
188172
rel: describedby
189173
type: application/xml
190174
- href: https://test.com/html/00000000-0000-0000-0000-000000000003
191-
data: null
192175
rel: related
193176
type: text/html
194177
title: NGR pagina voor deze dataset

internal/controller/test_data/maximum-atom/expected-output/ingressroute.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ metadata:
1818
uid: ""
1919
blockOwnerDeletion: true
2020
controller: true
21+
finalizers:
22+
- uptime.pdok.nl/finalizer
2123
spec:
2224
routes:
2325
- kind: Rule
@@ -28,9 +30,7 @@ spec:
2830
port: 80
2931
middlewares:
3032
- name: maximum-atom-headers
31-
namespace: default
3233
- name: maximum-atom-prefixstrip
33-
namespace: default
3434
- kind: Rule
3535
match: (Host(`localhost`) || Host(`test.com`)) && Path(`/path/feed-1.xml`)
3636
services:
@@ -39,9 +39,7 @@ spec:
3939
port: 80
4040
middlewares:
4141
- name: maximum-atom-headers
42-
namespace: default
4342
- name: maximum-atom-prefixstrip
44-
namespace: default
4543
- kind: Rule
4644
match: (Host(`localhost`) || Host(`test.com`)) && Path(`/path/feed-2.xml`)
4745
services:
@@ -50,9 +48,7 @@ spec:
5048
port: 80
5149
middlewares:
5250
- name: maximum-atom-headers
53-
namespace: default
5451
- name: maximum-atom-prefixstrip
55-
namespace: default
5652
- kind: Rule
5753
match: (Host(`localhost`) || Host(`test.com`)) && PathPrefix(`/path/downloads/`)
5854
services:
@@ -62,10 +58,6 @@ spec:
6258
passHostHeader: false
6359
middlewares:
6460
- name: maximum-atom-headers
65-
namespace: default
6661
- name: maximum-atom-downloads-0
67-
namespace: default
6862
- name: maximum-atom-downloads-1
69-
namespace: default
7063
- name: maximum-atom-downloads-2
71-
namespace: default

internal/controller/test_data/minimal-atom/expected-output/configmap.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: minimal-atom-generator-tmk22c7fm9
4+
name: minimal-atom-generator-fd8bdfdkh6
55
namespace: default
66
labels:
77
test: test
@@ -30,7 +30,6 @@ data:
3030
subtitle: service-subtitle
3131
link:
3232
- href: https://test.com/path/index.xml
33-
data: null
3433
rel: self
3534
type: application/atom+xml
3635
title: service-title
@@ -44,7 +43,6 @@ data:
4443
summary: feed-subtitle
4544
link:
4645
- href: https://test.com/path/feed.xml
47-
data: null
4846
rel: alternate
4947
type: application/atom+xml
5048
title: feed-title
@@ -63,10 +61,8 @@ data:
6361
subtitle: feed-subtitle
6462
link:
6563
- href: https://test.com/path/feed.xml
66-
data: null
6764
rel: self
6865
- href: https://test.com/path/index.xml
69-
data: null
7066
rel: up
7167
type: application/atom+xml
7268
title: Top Atom Download Service Feed

internal/controller/test_data/minimal-atom/expected-output/ingressroute.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ metadata:
1818
uid: ""
1919
blockOwnerDeletion: true
2020
controller: true
21+
finalizers:
22+
- uptime.pdok.nl/finalizer
2123
spec:
2224
routes:
2325
- kind: Rule
@@ -28,9 +30,7 @@ spec:
2830
port: 80
2931
middlewares:
3032
- name: minimal-atom-headers
31-
namespace: default
3233
- name: minimal-atom-prefixstrip
33-
namespace: default
3434
- kind: Rule
3535
match: (Host(`localhost`) || Host(`test.com`)) && Path(`/path/feed.xml`)
3636
services:
@@ -39,9 +39,7 @@ spec:
3939
port: 80
4040
middlewares:
4141
- name: minimal-atom-headers
42-
namespace: default
4342
- name: minimal-atom-prefixstrip
44-
namespace: default
4543
- kind: Rule
4644
match: (Host(`localhost`) || Host(`test.com`)) && PathPrefix(`/path/downloads/`)
4745
services:
@@ -51,6 +49,4 @@ spec:
5149
passHostHeader: false
5250
middlewares:
5351
- name: minimal-atom-headers
54-
namespace: default
5552
- name: minimal-atom-downloads-0
56-
namespace: default

0 commit comments

Comments
 (0)