@@ -31,6 +31,7 @@ import (
31
31
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
32
32
notifv1 "github.com/fluxcd/notification-controller/api/v1"
33
33
notifv1beta3 "github.com/fluxcd/notification-controller/api/v1beta3"
34
+ networkingv1 "k8s.io/api/networking/v1"
34
35
35
36
"github.com/fluxcd/pkg/apis/meta"
36
37
sourcev1 "github.com/fluxcd/source-controller/api/v1"
@@ -262,6 +263,84 @@ func GenerateKustomizationForApp(
262
263
}, nil
263
264
}
264
265
266
+ func GenerateIngress (
267
+ app string ,
268
+ port int32 ,
269
+ namespace string ,
270
+ host string ,
271
+ targetPath string ,
272
+ httpPath string ,
273
+ ) (* manifestgen.Manifest , error ) {
274
+ nginx := "nginx"
275
+ var pathType networkingv1.PathType
276
+ pathType = "Prefix"
277
+
278
+ ingress := networkingv1.Ingress {
279
+ TypeMeta : metav1.TypeMeta {
280
+ APIVersion : "networking.k8s.io/v1" ,
281
+ Kind : "Ingress" ,
282
+ },
283
+ ObjectMeta : metav1.ObjectMeta {
284
+ Name : fmt .Sprintf ("%s-ingress" , app ),
285
+ Namespace : namespace ,
286
+ Annotations : map [string ]string {
287
+ "kubernetes.io/ingress.class" : "nginx" ,
288
+ "nginx.ingress.kubernetes.io/configuration-snippet" : `sub_filter '</body>' '
289
+ <div class="bg-transparent bottom-0 md:px-0 fixed z-[2147483647] left-0 md:left-[calc(50%-390px)]">
290
+ <iframe class="h-48 min-h-[initial] max-h-[initial] translate-[initial] bg-transparent border-0 block w-screen md:w-[780px]"
291
+ id="github-iframe"
292
+ title="Gimlet Drawer"
293
+ src=""
294
+ >
295
+ </iframe>
296
+ <script src="https://cdn.tailwindcss.com"></script>
297
+ <script>
298
+ fetch("https://api.github.com/repos/dzsak/deploying-a-static-site-with-netlify-sample/contents/gimlet-preview.html?ref=v0.0.1-rc.19").then(function(t){return t.json()})
299
+ .then(function(t){(iframe=document.getElementById("github-iframe")).src="data:text/html;base64,"+encodeURIComponent(t.content)});
300
+ </script>
301
+ </body>';
302
+ proxy_set_header Accept-Encoding "";` ,
303
+ },
304
+ },
305
+ Spec : networkingv1.IngressSpec {
306
+ IngressClassName : & nginx ,
307
+ Rules : []networkingv1.IngressRule {
308
+ {
309
+ Host : host ,
310
+ IngressRuleValue : networkingv1.IngressRuleValue {
311
+ HTTP : & networkingv1.HTTPIngressRuleValue {
312
+ Paths : []networkingv1.HTTPIngressPath {
313
+ {
314
+ Backend : networkingv1.IngressBackend {
315
+ Service : & networkingv1.IngressServiceBackend {
316
+ Name : app ,
317
+ Port : networkingv1.ServiceBackendPort {
318
+ Number : port ,
319
+ },
320
+ },
321
+ },
322
+ Path : httpPath ,
323
+ PathType : & pathType ,
324
+ },
325
+ },
326
+ },
327
+ },
328
+ },
329
+ },
330
+ },
331
+ }
332
+
333
+ ingressData , err := yaml .Marshal (ingress )
334
+ if err != nil {
335
+ return nil , err
336
+ }
337
+
338
+ return & manifestgen.Manifest {
339
+ Path : path .Join (targetPath , namespace , fmt .Sprintf ("ingress-%s.yaml" , app )),
340
+ Content : fmt .Sprintf ("---\n %s" , resourceToString (ingressData )),
341
+ }, nil
342
+ }
343
+
265
344
func GenerateConfigMap (
266
345
configMapName string ,
267
346
namespace string ,
0 commit comments