Skip to content

Commit fe304f4

Browse files
author
Jelle Dijkstra
committed
Added finalizer to ingressroute
1 parent f7e8577 commit fe304f4

File tree

7 files changed

+18
-33
lines changed

7 files changed

+18
-33
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 & 1 deletion
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

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 & 1 deletion
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

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)