From 24d525b6b85212fffe0fcaf8e99b349e083ea49f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Mon, 8 Jan 2024 09:34:54 +1100 Subject: [PATCH] test: consolidate test seed data (#284) --- cmd/identify_feature.go | 2 +- cmd/identify_feature_test.go | 279 ++--- cmd/identify_ingress.go | 6 +- cmd/identify_ingress_test.go | 978 +++++++----------- cmd/root.go | 1 + cmd/tasks_run.go | 4 +- cmd/template_autogen_ingress.go | 2 +- cmd/template_autogen_ingress_test.go | 944 +++++++---------- cmd/template_backups.go | 2 +- cmd/template_backups_test.go | 427 +++----- cmd/template_dbaas.go | 2 +- cmd/template_dbaas_test.go | 150 +-- cmd/template_ingress.go | 2 +- cmd/template_ingress_test.go | 766 ++++++-------- internal/generator/generator.go | 8 +- .../generator/helpers_generator.go | 61 +- internal/helpers/helpers.go | 4 + internal/lagoon/lagoon_test.go | 8 +- .../lagoon-yaml/test1/lagoon.yml | 0 .../lagoon-yaml/test2/lagoon.yml | 0 .../lagoon-yaml/test3/lagoon.yml | 0 .../lagoon-yaml/test4/lagoon.yml | 0 .../autogen-templates/ingress-1}/nginx.yaml | 0 .../ingress-2}/nginx-php.yaml | 0 .../autogen-templates/ingress-3}/nginx.yaml | 0 .../k8up-lagoon-backup-schedule.yaml | 0 .../backup-1}/prebackuppods.yaml | 2 +- .../k8up-lagoon-backup-schedule.yaml | 11 +- .../backup-2/prebackuppods.yaml | 56 + .../dbaas-templates/dbaas-1}/dbaas.yaml | 0 .../complex/docker-compose.complex-1.yml | 0 .../complex/docker-compose.small-1.yml | 2 +- .../complex/docker-compose.small-2.yml | 70 ++ .../testdata/complex}/docker-compose.yml | 39 +- .../ingress-1}/content.example.com.yaml | 0 .../testdata/complex/lagoon.complex-1.yml | 2 +- .../testdata/complex/lagoon.complex-2.yml | 2 +- .../testdata/complex/lagoon.small-2.yml | 2 +- internal/testdata/complex/lagoon.small.yml | 59 ++ .../testdata/complex}/lagoon.yml | 2 +- .../autogen-templates/ingress-1}/nginx.yaml | 0 .../autogen-templates/ingress-2}/nginx.yaml | 0 .../ingress-3}/nginx-php.yaml | 0 .../nginxphp/docker-compose.nginx-1.yml | 0 .../nginxphp/docker-compose.servicename.yml | 0 .../testdata/nginxphp}/docker-compose.yml | 0 .../testdata/nginxphp/lagoon.nginx-1.yml | 2 +- .../testdata/nginxphp/lagoon.nginx-2.yml | 2 +- .../testdata/nginxphp/lagoon.servicename.yml | 4 +- .../testdata/nginxphp}/lagoon.yml | 4 +- .../autogen-templates/ingress-1}/node.yaml | 0 .../autogen-templates/ingress-10}/node.yaml | 0 .../autogen-templates/ingress-11}/node.yaml | 0 .../autogen-templates/ingress-12}/node.yaml | 0 .../autogen-templates/ingress-13}/node.yaml | 0 .../autogen-templates/ingress-14}/node.yaml | 0 .../autogen-templates/ingress-2}/node.yaml | 9 +- .../autogen-templates/ingress-3}/node.yaml | 0 .../autogen-templates/ingress-4}/node.yaml | 0 .../autogen-templates/ingress-5}/node.yaml | 0 .../autogen-templates/ingress-6}/node.yaml | 0 .../autogen-templates/ingress-7}/node.yaml | 0 .../autogen-templates/ingress-8}/node.yaml | 0 .../autogen-templates/ingress-9}/node.yaml | 0 .../k8up-lagoon-backup-schedule.yaml | 0 .../backup-2/k8up-lagoon-backup-schedule.yaml | 42 + .../k8up-lagoon-backup-schedule.yaml | 6 +- .../k8up-lagoon-backup-schedule.yaml | 6 +- .../k8up-lagoon-backup-schedule.yaml | 7 +- .../k8up-lagoon-backup-schedule.yaml | 0 .../node/docker-compose.autogen-1.yml | 2 +- .../node/docker-compose.autogen-2.yml | 2 +- .../node/docker-compose.autogen-3.yml | 0 .../testdata/node/docker-compose.none.yml | 2 +- .../testdata/node}/docker-compose.yml | 0 .../ingress-1}/example.com.yaml | 0 .../ingress-10/main-sb.example.com.yaml | 16 +- .../ingress-10}/standby.example.com.yaml | 4 +- .../ingress-11}/test1.example.com.yaml | 4 +- .../ingress-12}/example.com.yaml | 0 .../ingress-13/example.com.yaml | 52 + .../ingress-14}/example.com.yaml | 0 .../ingress-15}/example.com.yaml | 0 .../ingress-16}/example.com.yaml | 4 +- .../ingress-17}/example.com.yaml | 4 +- .../ingress-18}/example.com.yaml | 4 +- .../ingress-18}/www.example.com.yaml | 4 +- .../ingress-19}/performance.example.com.yaml | 0 .../ingress-2}/example.com.yaml | 0 .../ingress-20}/performance.example.com.yaml | 0 .../ingress-21}/example.com.yaml | 4 +- .../ingress-22}/example.com.yaml | 4 +- .../ingress-3}/example.com.yaml | 0 .../ingress-4}/example.com.yaml | 0 .../ingress-5}/multiproject1.com.yaml | 0 .../ingress-6}/multiproject2.com.yaml | 0 .../ingress-7}/example.com.yaml | 4 +- .../ingress-7}/www.example.com.yaml | 4 +- .../customdomain-will-be-main-domain.com.yaml | 0 ...domain-will-be-not-be-main-domain.com.yaml | 0 .../ingress-9}/active.example.com.yaml | 0 .../ingress-9}/main.example.com.yaml | 0 .../testdata/node/lagoon.activestandby.yml | 6 +- .../testdata/node/lagoon.autogen-1.yml | 2 +- .../testdata/node/lagoon.autogen-2.yml | 2 +- .../testdata/node/lagoon.autogen-3.yml | 2 +- .../testdata/node/lagoon.autogen-4.yml | 2 +- .../testdata/node/lagoon.autogen-5.yml | 2 +- .../testdata/node/lagoon.autogen-6.yml | 2 +- .../testdata/node/lagoon.autogen-7.yml | 2 +- .../testdata/node/lagoon.autogen-8.yml | 2 +- .../testdata/node/lagoon.autogen-9.yml | 2 +- .../node/lagoon.autogen-prefixes-1.yml | 4 +- .../testdata/node/lagoon.polysite-pr.yml | 4 +- .../testdata/node/lagoon.polysite.yml | 10 +- internal/testdata/node/lagoon.yml | 74 ++ internal/testdata/testdata.go | 237 +++++ .../identify-feature/alltest/lagoon.yml | 10 - .../identify-ingress/test1/docker-compose.yml | 20 - .../identify-ingress/test1/lagoon.yml | 10 - .../test10/docker-compose.yml | 20 - .../identify-ingress/test10/lagoon.yml | 24 - .../test11/docker-compose.yml | 20 - .../identify-ingress/test11/lagoon.yml | 10 - .../test12/docker-compose.yml | 20 - .../test13/docker-compose.yml | 20 - .../identify-ingress/test13/lagoon.yml | 14 - .../test14/docker-compose.yml | 20 - .../identify-ingress/test14/lagoon.yml | 5 - .../test15/docker-compose.yml | 153 --- .../identify-ingress/test15/lagoon.yml | 66 -- .../test16/docker-compose.yml | 146 --- .../identify-ingress/test16/lagoon.yml | 43 - .../test17/docker-compose.yml | 119 --- .../identify-ingress/test17/lagoon.yml | 1 - .../test18/docker-compose.yml | 104 -- .../identify-ingress/test2/docker-compose.yml | 20 - .../identify-ingress/test2/lagoon.yml | 10 - .../identify-ingress/test3/docker-compose.yml | 20 - .../identify-ingress/test3/lagoon.yml | 10 - .../identify-ingress/test4/docker-compose.yml | 20 - .../identify-ingress/test4/lagoon.yml | 10 - .../identify-ingress/test5/docker-compose.yml | 20 - .../identify-ingress/test5/lagoon.yml | 17 - .../identify-ingress/test6/docker-compose.yml | 20 - .../identify-ingress/test7/docker-compose.yml | 20 - .../identify-ingress/test7/lagoon.yml | 11 - .../identify-ingress/test8/docker-compose.yml | 20 - .../identify-ingress/test8/lagoon.yml | 8 - .../identify-ingress/test9/docker-compose.yml | 20 - .../identify-ingress/test9/lagoon.yml | 24 - .../test1/docker-compose.yml | 20 - .../test10/docker-compose.yml | 20 - .../template-autogenerated/test10/lagoon.yml | 15 - .../test11/docker-compose.yml | 20 - .../template-autogenerated/test11/lagoon.yml | 15 - .../test12/docker-compose.yml | 20 - .../template-autogenerated/test13/lagoon.yml | 15 - .../test14/docker-compose.yml | 20 - .../template-autogenerated/test14/lagoon.yml | 15 - .../template-autogenerated/test15/lagoon.yml | 15 - .../template-autogenerated/test16/lagoon.yml | 15 - .../test18/docker-compose.yml | 20 - .../test2/docker-compose.yml | 20 - .../template-autogenerated/test20/lagoon.yml | 43 - .../test23/docker-compose.yml | 20 - .../template-autogenerated/test23/lagoon.yml | 15 - .../test24/docker-compose.yml | 20 - .../test25/docker-compose.yml | 20 - .../template-autogenerated/test25/lagoon.yml | 18 - .../test26/docker-compose.yml | 20 - .../template-autogenerated/test26/lagoon.yml | 17 - .../test3/docker-compose.yml | 20 - .../test4/docker-compose.yml | 20 - .../test5/docker-compose.yml | 20 - .../template-autogenerated/test6/lagoon.yml | 16 - .../test7-results/node.yaml | 46 - .../test8/docker-compose.yml | 20 - .../test9/docker-compose.yml | 20 - .../template-autogenerated/test9/lagoon.yml | 15 - .../template-backups/test1/docker-compose.yml | 42 - .../template-backups/test1/lagoon.yml | 10 - .../template-backups/test2/docker-compose.yml | 20 - .../template-backups/test2/lagoon.yml | 10 - .../template-backups/test3/docker-compose.yml | 20 - .../template-backups/test3/lagoon.yml | 17 - .../template-backups/test4/docker-compose.yml | 20 - .../template-backups/test4/lagoon.yml | 10 - .../template-backups/test5/docker-compose.yml | 20 - .../template-backups/test5/lagoon.yml | 10 - .../template-backups/test6/docker-compose.yml | 20 - .../template-backups/test6/lagoon.yml | 20 - .../template-backups/test7/docker-compose.yml | 20 - .../template-backups/test7/lagoon.yml | 10 - .../template-dbaas/test1/docker-compose.yml | 121 --- .../template-ingress/test1/docker-compose.yml | 20 - .../template-ingress/test1/lagoon.yml | 10 - .../test10/docker-compose.yml | 20 - .../template-ingress/test10/lagoon.yml | 24 - .../test11/docker-compose.yml | 146 --- .../test12/docker-compose.yml | 20 - .../template-ingress/test12/lagoon.yml | 10 - .../test13/docker-compose.yml | 20 - .../template-ingress/test13/lagoon.yml | 10 - .../test14/docker-compose.yml | 20 - .../template-ingress/test14/lagoon.yml | 11 - .../test15/docker-compose.yml | 20 - .../template-ingress/test15/lagoon.yml | 10 - .../test16/docker-compose.yml | 20 - .../template-ingress/test16/lagoon.yml | 12 - .../test17/docker-compose.yml | 20 - .../template-ingress/test17/lagoon.yml | 14 - .../test18/docker-compose.yml | 20 - .../template-ingress/test18/lagoon.yml | 11 - .../test19/docker-compose.yml | 14 - .../template-ingress/test19/lagoon.yml | 22 - .../template-ingress/test2/docker-compose.yml | 20 - .../template-ingress/test2/lagoon.yml | 10 - .../test20/docker-compose.yml | 14 - .../test21/docker-compose.yml | 20 - .../template-ingress/test21/lagoon.yml | 13 - .../test22/docker-compose.yml | 20 - .../template-ingress/test22/lagoon.yml | 12 - .../template-ingress/test3/docker-compose.yml | 20 - .../template-ingress/test3/lagoon.yml | 10 - .../template-ingress/test4/docker-compose.yml | 20 - .../template-ingress/test4/lagoon.yml | 10 - .../template-ingress/test5/docker-compose.yml | 20 - .../template-ingress/test5/lagoon.yml | 17 - .../template-ingress/test6/docker-compose.yml | 20 - .../template-ingress/test6/lagoon.yml | 17 - .../template-ingress/test7/docker-compose.yml | 20 - .../template-ingress/test7/lagoon.yml | 11 - .../template-ingress/test8/docker-compose.yml | 20 - .../template-ingress/test8/lagoon.yml | 8 - .../template-ingress/test9/docker-compose.yml | 20 - 236 files changed, 2078 insertions(+), 5185 deletions(-) rename cmd/helpers_values.go => internal/generator/helpers_generator.go (58%) rename {test-resources => internal/lagoon/test-resources}/lagoon-yaml/test1/lagoon.yml (100%) rename {test-resources => internal/lagoon/test-resources}/lagoon-yaml/test2/lagoon.yml (100%) rename {test-resources => internal/lagoon/test-resources}/lagoon-yaml/test3/lagoon.yml (100%) rename {test-resources => internal/lagoon/test-resources}/lagoon-yaml/test4/lagoon.yml (100%) rename {test-resources/template-autogenerated/test17-results => internal/testdata/complex/autogen-templates/ingress-1}/nginx.yaml (100%) rename {test-resources/template-autogenerated/test20-results => internal/testdata/complex/autogen-templates/ingress-2}/nginx-php.yaml (100%) rename {test-resources/template-autogenerated/test21-results => internal/testdata/complex/autogen-templates/ingress-3}/nginx.yaml (100%) rename {test-resources/template-backups/test1-results => internal/testdata/complex/backup-templates/backup-1}/k8up-lagoon-backup-schedule.yaml (100%) rename {test-resources/template-backups/test1-results => internal/testdata/complex/backup-templates/backup-1}/prebackuppods.yaml (96%) rename {test-resources/template-backups/test6-results => internal/testdata/complex/backup-templates/backup-2}/k8up-lagoon-backup-schedule.yaml (85%) create mode 100644 internal/testdata/complex/backup-templates/backup-2/prebackuppods.yaml rename {test-resources/template-dbaas/test1-results => internal/testdata/complex/dbaas-templates/dbaas-1}/dbaas.yaml (100%) rename test-resources/template-autogenerated/test21/docker-compose.yml => internal/testdata/complex/docker-compose.complex-1.yml (100%) rename test-resources/template-autogenerated/test17/docker-compose.yml => internal/testdata/complex/docker-compose.small-1.yml (98%) create mode 100644 internal/testdata/complex/docker-compose.small-2.yml rename {test-resources/template-autogenerated/test20 => internal/testdata/complex}/docker-compose.yml (84%) rename {test-resources/template-ingress/test11-results => internal/testdata/complex/ingress-templates/ingress-1}/content.example.com.yaml (100%) rename test-resources/template-autogenerated/test21/lagoon.yml => internal/testdata/complex/lagoon.complex-1.yml (87%) rename test-resources/identify-ingress/test18/lagoon.yml => internal/testdata/complex/lagoon.complex-2.yml (76%) rename test-resources/template-autogenerated/test17/lagoon.yml => internal/testdata/complex/lagoon.small-2.yml (94%) create mode 100644 internal/testdata/complex/lagoon.small.yml rename {test-resources/template-ingress/test11 => internal/testdata/complex}/lagoon.yml (91%) rename {test-resources/template-autogenerated/test15-results => internal/testdata/nginxphp/autogen-templates/ingress-1}/nginx.yaml (100%) rename {test-resources/template-autogenerated/test16-results => internal/testdata/nginxphp/autogen-templates/ingress-2}/nginx.yaml (100%) rename {test-resources/template-autogenerated/test22-results => internal/testdata/nginxphp/autogen-templates/ingress-3}/nginx-php.yaml (100%) rename test-resources/template-autogenerated/test22/docker-compose.yml => internal/testdata/nginxphp/docker-compose.nginx-1.yml (100%) rename test-resources/template-autogenerated/test16/docker-compose.yml => internal/testdata/nginxphp/docker-compose.servicename.yml (100%) rename {test-resources/template-autogenerated/test15 => internal/testdata/nginxphp}/docker-compose.yml (100%) rename test-resources/template-autogenerated/test2/lagoon.yml => internal/testdata/nginxphp/lagoon.nginx-1.yml (70%) rename test-resources/template-dbaas/test1/lagoon.yml => internal/testdata/nginxphp/lagoon.nginx-2.yml (59%) rename test-resources/template-autogenerated/test8/lagoon.yml => internal/testdata/nginxphp/lagoon.servicename.yml (62%) rename {test-resources/template-autogenerated/test1 => internal/testdata/nginxphp}/lagoon.yml (62%) rename {test-resources/template-autogenerated/test1-results => internal/testdata/node/autogen-templates/ingress-1}/node.yaml (100%) rename {test-resources/template-autogenerated/test12-results => internal/testdata/node/autogen-templates/ingress-10}/node.yaml (100%) rename {test-resources/template-autogenerated/test13-results => internal/testdata/node/autogen-templates/ingress-11}/node.yaml (100%) rename {test-resources/template-autogenerated/test18-results => internal/testdata/node/autogen-templates/ingress-12}/node.yaml (100%) rename {test-resources/template-autogenerated/test19-results => internal/testdata/node/autogen-templates/ingress-13}/node.yaml (100%) rename {test-resources/template-autogenerated/test23-results => internal/testdata/node/autogen-templates/ingress-14}/node.yaml (100%) rename {test-resources/template-autogenerated/test2-results => internal/testdata/node/autogen-templates/ingress-2}/node.yaml (84%) rename {test-resources/template-autogenerated/test4-results => internal/testdata/node/autogen-templates/ingress-3}/node.yaml (100%) rename {test-resources/template-autogenerated/test5-results => internal/testdata/node/autogen-templates/ingress-4}/node.yaml (100%) rename {test-resources/template-autogenerated/test24-results => internal/testdata/node/autogen-templates/ingress-5}/node.yaml (100%) rename {test-resources/template-autogenerated/test8-results => internal/testdata/node/autogen-templates/ingress-6}/node.yaml (100%) rename {test-resources/template-autogenerated/test9-results => internal/testdata/node/autogen-templates/ingress-7}/node.yaml (100%) rename {test-resources/template-autogenerated/test10-results => internal/testdata/node/autogen-templates/ingress-8}/node.yaml (100%) rename {test-resources/template-autogenerated/test11-results => internal/testdata/node/autogen-templates/ingress-9}/node.yaml (100%) rename {test-resources/template-backups/test2-results => internal/testdata/node/backup-templates/backup-1}/k8up-lagoon-backup-schedule.yaml (100%) create mode 100644 internal/testdata/node/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml rename {test-resources/template-backups/test4-results => internal/testdata/node/backup-templates/backup-3}/k8up-lagoon-backup-schedule.yaml (94%) rename {test-resources/template-backups/test5-results => internal/testdata/node/backup-templates/backup-4}/k8up-lagoon-backup-schedule.yaml (93%) rename {test-resources/template-backups/test3-results => internal/testdata/node/backup-templates/backup-5}/k8up-lagoon-backup-schedule.yaml (92%) rename {test-resources/template-backups/test7-results => internal/testdata/node/backup-templates/backup-6}/k8up-lagoon-backup-schedule.yaml (100%) rename test-resources/template-autogenerated/test6/docker-compose.yml => internal/testdata/node/docker-compose.autogen-1.yml (95%) rename test-resources/template-autogenerated/test7/docker-compose.yml => internal/testdata/node/docker-compose.autogen-2.yml (95%) rename test-resources/template-autogenerated/test19/docker-compose.yml => internal/testdata/node/docker-compose.autogen-3.yml (100%) rename test-resources/template-autogenerated/test13/docker-compose.yml => internal/testdata/node/docker-compose.none.yml (94%) rename {test-resources/identify-feature/alltest => internal/testdata/node}/docker-compose.yml (100%) rename {test-resources/template-ingress/test1-results => internal/testdata/node/ingress-templates/ingress-1}/example.com.yaml (100%) rename test-resources/template-ingress/test10-results/main2.example.com.yaml => internal/testdata/node/ingress-templates/ingress-10/main-sb.example.com.yaml (77%) rename {test-resources/template-ingress/test10-results => internal/testdata/node/ingress-templates/ingress-10}/standby.example.com.yaml (95%) rename {test-resources/template-ingress/test12-results => internal/testdata/node/ingress-templates/ingress-11}/test1.example.com.yaml (94%) rename {test-resources/template-ingress/test13-results => internal/testdata/node/ingress-templates/ingress-12}/example.com.yaml (100%) create mode 100644 internal/testdata/node/ingress-templates/ingress-13/example.com.yaml rename {test-resources/template-ingress/test14-results => internal/testdata/node/ingress-templates/ingress-14}/example.com.yaml (100%) rename {test-resources/template-ingress/test15-results => internal/testdata/node/ingress-templates/ingress-15}/example.com.yaml (100%) rename {test-resources/template-ingress/test16-results => internal/testdata/node/ingress-templates/ingress-16}/example.com.yaml (96%) rename {test-resources/template-ingress/test17-results => internal/testdata/node/ingress-templates/ingress-17}/example.com.yaml (96%) rename {test-resources/template-ingress/test7-results => internal/testdata/node/ingress-templates/ingress-18}/example.com.yaml (95%) rename {test-resources/template-ingress/test18-results => internal/testdata/node/ingress-templates/ingress-18}/www.example.com.yaml (94%) rename {test-resources/template-ingress/test19-results => internal/testdata/node/ingress-templates/ingress-19}/performance.example.com.yaml (100%) rename {test-resources/template-ingress/test2-results => internal/testdata/node/ingress-templates/ingress-2}/example.com.yaml (100%) rename {test-resources/template-ingress/test20-results => internal/testdata/node/ingress-templates/ingress-20}/performance.example.com.yaml (100%) rename {test-resources/template-ingress/test21-results => internal/testdata/node/ingress-templates/ingress-21}/example.com.yaml (95%) rename {test-resources/template-ingress/test22-results => internal/testdata/node/ingress-templates/ingress-22}/example.com.yaml (94%) rename {test-resources/template-ingress/test3-results => internal/testdata/node/ingress-templates/ingress-3}/example.com.yaml (100%) rename {test-resources/template-ingress/test18-results => internal/testdata/node/ingress-templates/ingress-4}/example.com.yaml (100%) rename {test-resources/template-ingress/test5-results => internal/testdata/node/ingress-templates/ingress-5}/multiproject1.com.yaml (100%) rename {test-resources/template-ingress/test6-results => internal/testdata/node/ingress-templates/ingress-6}/multiproject2.com.yaml (100%) rename {test-resources/template-ingress/test4-results => internal/testdata/node/ingress-templates/ingress-7}/example.com.yaml (95%) rename {test-resources/template-ingress/test7-results => internal/testdata/node/ingress-templates/ingress-7}/www.example.com.yaml (94%) rename {test-resources/template-ingress/test8-results => internal/testdata/node/ingress-templates/ingress-8}/customdomain-will-be-main-domain.com.yaml (100%) rename {test-resources/template-ingress/test8-results => internal/testdata/node/ingress-templates/ingress-8}/customdomain-will-be-not-be-main-domain.com.yaml (100%) rename {test-resources/template-ingress/test9-results => internal/testdata/node/ingress-templates/ingress-9}/active.example.com.yaml (100%) rename {test-resources/template-ingress/test9-results => internal/testdata/node/ingress-templates/ingress-9}/main.example.com.yaml (100%) rename test-resources/template-ingress/test9/lagoon.yml => internal/testdata/node/lagoon.activestandby.yml (71%) rename test-resources/template-autogenerated/test22/lagoon.yml => internal/testdata/node/lagoon.autogen-1.yml (70%) rename test-resources/template-autogenerated/test3/lagoon.yml => internal/testdata/node/lagoon.autogen-2.yml (70%) rename test-resources/template-autogenerated/test4/lagoon.yml => internal/testdata/node/lagoon.autogen-3.yml (67%) rename test-resources/template-autogenerated/test7/lagoon.yml => internal/testdata/node/lagoon.autogen-4.yml (70%) rename test-resources/template-autogenerated/test12/lagoon.yml => internal/testdata/node/lagoon.autogen-5.yml (64%) rename test-resources/template-autogenerated/test5/lagoon.yml => internal/testdata/node/lagoon.autogen-6.yml (67%) rename test-resources/template-autogenerated/test18/lagoon.yml => internal/testdata/node/lagoon.autogen-7.yml (69%) rename test-resources/template-autogenerated/test19/lagoon.yml => internal/testdata/node/lagoon.autogen-8.yml (64%) rename test-resources/template-autogenerated/test24/lagoon.yml => internal/testdata/node/lagoon.autogen-9.yml (67%) rename test-resources/identify-ingress/test12/lagoon.yml => internal/testdata/node/lagoon.autogen-prefixes-1.yml (62%) rename test-resources/template-ingress/test20/lagoon.yml => internal/testdata/node/lagoon.polysite-pr.yml (83%) rename test-resources/identify-ingress/test6/lagoon.yml => internal/testdata/node/lagoon.polysite.yml (56%) create mode 100644 internal/testdata/node/lagoon.yml create mode 100644 internal/testdata/testdata.go delete mode 100644 test-resources/identify-feature/alltest/lagoon.yml delete mode 100644 test-resources/identify-ingress/test1/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test1/lagoon.yml delete mode 100644 test-resources/identify-ingress/test10/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test10/lagoon.yml delete mode 100644 test-resources/identify-ingress/test11/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test11/lagoon.yml delete mode 100644 test-resources/identify-ingress/test12/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test13/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test13/lagoon.yml delete mode 100644 test-resources/identify-ingress/test14/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test14/lagoon.yml delete mode 100644 test-resources/identify-ingress/test15/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test15/lagoon.yml delete mode 100644 test-resources/identify-ingress/test16/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test16/lagoon.yml delete mode 100644 test-resources/identify-ingress/test17/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test17/lagoon.yml delete mode 100644 test-resources/identify-ingress/test18/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test2/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test2/lagoon.yml delete mode 100644 test-resources/identify-ingress/test3/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test3/lagoon.yml delete mode 100644 test-resources/identify-ingress/test4/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test4/lagoon.yml delete mode 100644 test-resources/identify-ingress/test5/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test5/lagoon.yml delete mode 100644 test-resources/identify-ingress/test6/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test7/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test7/lagoon.yml delete mode 100644 test-resources/identify-ingress/test8/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test8/lagoon.yml delete mode 100644 test-resources/identify-ingress/test9/docker-compose.yml delete mode 100644 test-resources/identify-ingress/test9/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test1/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test10/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test10/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test11/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test11/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test12/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test13/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test14/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test14/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test15/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test16/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test18/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test2/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test20/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test23/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test23/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test24/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test25/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test25/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test26/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test26/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test3/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test4/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test5/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test6/lagoon.yml delete mode 100644 test-resources/template-autogenerated/test7-results/node.yaml delete mode 100644 test-resources/template-autogenerated/test8/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test9/docker-compose.yml delete mode 100644 test-resources/template-autogenerated/test9/lagoon.yml delete mode 100644 test-resources/template-backups/test1/docker-compose.yml delete mode 100644 test-resources/template-backups/test1/lagoon.yml delete mode 100644 test-resources/template-backups/test2/docker-compose.yml delete mode 100644 test-resources/template-backups/test2/lagoon.yml delete mode 100644 test-resources/template-backups/test3/docker-compose.yml delete mode 100644 test-resources/template-backups/test3/lagoon.yml delete mode 100644 test-resources/template-backups/test4/docker-compose.yml delete mode 100644 test-resources/template-backups/test4/lagoon.yml delete mode 100644 test-resources/template-backups/test5/docker-compose.yml delete mode 100644 test-resources/template-backups/test5/lagoon.yml delete mode 100644 test-resources/template-backups/test6/docker-compose.yml delete mode 100644 test-resources/template-backups/test6/lagoon.yml delete mode 100644 test-resources/template-backups/test7/docker-compose.yml delete mode 100644 test-resources/template-backups/test7/lagoon.yml delete mode 100644 test-resources/template-dbaas/test1/docker-compose.yml delete mode 100644 test-resources/template-ingress/test1/docker-compose.yml delete mode 100644 test-resources/template-ingress/test1/lagoon.yml delete mode 100644 test-resources/template-ingress/test10/docker-compose.yml delete mode 100644 test-resources/template-ingress/test10/lagoon.yml delete mode 100644 test-resources/template-ingress/test11/docker-compose.yml delete mode 100644 test-resources/template-ingress/test12/docker-compose.yml delete mode 100644 test-resources/template-ingress/test12/lagoon.yml delete mode 100644 test-resources/template-ingress/test13/docker-compose.yml delete mode 100644 test-resources/template-ingress/test13/lagoon.yml delete mode 100644 test-resources/template-ingress/test14/docker-compose.yml delete mode 100644 test-resources/template-ingress/test14/lagoon.yml delete mode 100644 test-resources/template-ingress/test15/docker-compose.yml delete mode 100644 test-resources/template-ingress/test15/lagoon.yml delete mode 100644 test-resources/template-ingress/test16/docker-compose.yml delete mode 100644 test-resources/template-ingress/test16/lagoon.yml delete mode 100644 test-resources/template-ingress/test17/docker-compose.yml delete mode 100644 test-resources/template-ingress/test17/lagoon.yml delete mode 100644 test-resources/template-ingress/test18/docker-compose.yml delete mode 100644 test-resources/template-ingress/test18/lagoon.yml delete mode 100644 test-resources/template-ingress/test19/docker-compose.yml delete mode 100644 test-resources/template-ingress/test19/lagoon.yml delete mode 100644 test-resources/template-ingress/test2/docker-compose.yml delete mode 100644 test-resources/template-ingress/test2/lagoon.yml delete mode 100644 test-resources/template-ingress/test20/docker-compose.yml delete mode 100644 test-resources/template-ingress/test21/docker-compose.yml delete mode 100644 test-resources/template-ingress/test21/lagoon.yml delete mode 100644 test-resources/template-ingress/test22/docker-compose.yml delete mode 100644 test-resources/template-ingress/test22/lagoon.yml delete mode 100644 test-resources/template-ingress/test3/docker-compose.yml delete mode 100644 test-resources/template-ingress/test3/lagoon.yml delete mode 100644 test-resources/template-ingress/test4/docker-compose.yml delete mode 100644 test-resources/template-ingress/test4/lagoon.yml delete mode 100644 test-resources/template-ingress/test5/docker-compose.yml delete mode 100644 test-resources/template-ingress/test5/lagoon.yml delete mode 100644 test-resources/template-ingress/test6/docker-compose.yml delete mode 100644 test-resources/template-ingress/test6/lagoon.yml delete mode 100644 test-resources/template-ingress/test7/docker-compose.yml delete mode 100644 test-resources/template-ingress/test7/lagoon.yml delete mode 100644 test-resources/template-ingress/test8/docker-compose.yml delete mode 100644 test-resources/template-ingress/test8/lagoon.yml delete mode 100644 test-resources/template-ingress/test9/docker-compose.yml diff --git a/cmd/identify_feature.go b/cmd/identify_feature.go index 77dd8923..f3d17261 100644 --- a/cmd/identify_feature.go +++ b/cmd/identify_feature.go @@ -14,7 +14,7 @@ var featureFlagIdentify = &cobra.Command{ Aliases: []string{"f"}, Short: "Identify if a feature flag has been enabled", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(false) + generator, err := generator.GenerateInput(*rootCmd, false) if err != nil { return err } diff --git a/cmd/identify_feature_test.go b/cmd/identify_feature_test.go index 72cffa5e..6fa34f5f 100644 --- a/cmd/identify_feature_test.go +++ b/cmd/identify_feature_test.go @@ -3,10 +3,10 @@ package cmd import ( "os" "testing" - "time" - "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestIdentifyFeatureFlag(t *testing.T) { @@ -35,67 +35,65 @@ func TestIdentifyFeatureFlag(t *testing.T) { templatePath string } tests := []struct { - name string - args args - vars []helpers.EnvironmentVariable - want string - wantErr bool + name string + args testdata.TestData + templatePath string + varName string + vars []helpers.EnvironmentVariable + want string + wantErr bool }{ { - name: "test1 check if flag is defined in lagoon project variables", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "enabled", + name: "test1 check if flag is defined in lagoon project variables", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD", + Value: "enabled", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "enabled", }, { - name: "test2 check if flag is defined in lagoon environment variables", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "enabled", + name: "test2 check if flag is defined in lagoon environment variables", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + EnvVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD", + Value: "enabled", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "enabled", }, { - name: "test3 check if force flag is defined in build variables", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, + name: "test3 check if force flag is defined in build variables", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", vars: []helpers.EnvironmentVariable{ { Name: "LAGOON_FEATURE_FLAG_FORCE_ROOTLESS_WORKLOAD", @@ -105,22 +103,16 @@ func TestIdentifyFeatureFlag(t *testing.T) { want: "enabled", }, { - name: "test4 check if force flag is defined in build variables and default flag is ignored", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, + name: "test4 check if force flag is defined in build variables and default flag is ignored", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", vars: []helpers.EnvironmentVariable{ { Name: "LAGOON_FEATURE_FLAG_FORCE_ROOTLESS_WORKLOAD", @@ -134,22 +126,22 @@ func TestIdentifyFeatureFlag(t *testing.T) { want: "enabled", }, { - name: "test5 check if force flag is defined in build variables and one defined in lagoon project variables is ignored", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, + name: "test5 check if force flag is defined in build variables and one defined in lagoon project variables is ignored", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD", + Value: "enabled", + Scope: "build", + }, + }, + }, true), vars: []helpers.EnvironmentVariable{ { Name: "LAGOON_FEATURE_FLAG_FORCE_ROOTLESS_WORKLOAD", @@ -163,22 +155,22 @@ func TestIdentifyFeatureFlag(t *testing.T) { want: "disabled", }, { - name: "test6 check if default flag is ignored and lagoon project variable is used", - args: args{ - name: "ROOTLESS_WORKLOAD", - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml", - templatePath: "../test-resources/output", - }, + name: "test6 check if default flag is ignored and lagoon project variable is used", + varName: "ROOTLESS_WORKLOAD", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD", + Value: "enabled", + Scope: "build", + }, + }, + }, true), vars: []helpers.EnvironmentVariable{ { Name: "LAGOON_FEATURE_FLAG_DEFAULT_ROOTLESS_WORKLOAD", @@ -191,89 +183,18 @@ func TestIdentifyFeatureFlag(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - for _, envVar := range tt.vars { err = os.Setenv(envVar.Name, envVar.Value) if err != nil { t.Errorf("%v", err) } } - got, err := IdentifyFeatureFlag(generator, tt.args.name) + got, err := IdentifyFeatureFlag(generator, tt.varName) if (err != nil) != tt.wantErr { t.Errorf("IdentifyFeatureFlag() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/cmd/identify_ingress.go b/cmd/identify_ingress.go index 2ea79daf..a3e93849 100644 --- a/cmd/identify_ingress.go +++ b/cmd/identify_ingress.go @@ -19,7 +19,7 @@ var primaryIngressIdentify = &cobra.Command{ Aliases: []string{"pi"}, Short: "Identify the primary ingress for a specific environment", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(false) + generator, err := generator.GenerateInput(*rootCmd, false) if err != nil { return err } @@ -37,7 +37,7 @@ var ingressIdentify = &cobra.Command{ Aliases: []string{"i"}, Short: "Identify all ingress for a specific environment", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(false) + generator, err := generator.GenerateInput(*rootCmd, false) if err != nil { return err } @@ -73,7 +73,7 @@ var autogenIngressIdentify = &cobra.Command{ Aliases: []string{"ci"}, Short: "Identify all created ingress object names for a specific environment", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(false) + generator, err := generator.GenerateInput(*rootCmd, false) if err != nil { return err } diff --git a/cmd/identify_ingress_test.go b/cmd/identify_ingress_test.go index 22a777d1..ba83a600 100644 --- a/cmd/identify_ingress_test.go +++ b/cmd/identify_ingress_test.go @@ -2,302 +2,224 @@ package cmd import ( "encoding/json" - "os" "reflect" "testing" - "time" - "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestIdentifyRoute(t *testing.T) { - type args struct { - alertContact string - statusPageID string - projectName string - environmentName string - branch string - prNumber string - prHeadBranch string - prBaseBranch string - environmentType string - buildType string - activeEnvironment string - standbyEnvironment string - cacheNoCache string - serviceID string - secretPrefix string - projectVars string - envVars string - lagoonVersion string - lagoonYAML string - valuesFilePath string - templatePath string - } tests := []struct { - name string - args args - want string - wantJSON string - wantRemain []string - wantautoGen []string + name string + args testdata.TestData + templatePath string + want string + wantJSON string + wantRemain []string + wantautoGen []string }{ { name: "test1 check LAGOON_FASTLY_SERVICE_IDS with secret no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test1/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true:annotationscom", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, + wantautoGen: []string{"https://node-example-project-main.example.com"}, + wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, }, { name: "test2 check LAGOON_FASTLY_SERVICE_IDS no secret and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test2/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, + wantautoGen: []string{"https://node-example-project-main.example.com"}, + wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, }, { name: "test3 check LAGOON_FASTLY_SERVICE_ID no secret and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test3/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, + wantautoGen: []string{"https://node-example-project-main.example.com"}, + wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, }, { name: "test4 check no fastly and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test4/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"}, + wantautoGen: []string{"https://node-example-project-main.example.com"}, + wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, }, { name: "test5 multiproject1 no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "multiproject1", - environmentName: "multiproject", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "multiproject", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test5/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://multiproject1.com", - wantRemain: []string{"https://node-multiproject1-multiproject.example.com", "https://multiproject1.com"}, - wantautoGen: []string{"https://node-multiproject1-multiproject.example.com"}, - wantJSON: `{"primary":"https://multiproject1.com","secondary":["https://node-multiproject1-multiproject.example.com","https://multiproject1.com"],"autogenerated":["https://node-multiproject1-multiproject.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "multiproject1", + EnvironmentName: "multiproject", + Branch: "multiproject", + LagoonYAML: "../internal/testdata/node/lagoon.polysite.yml", + }, true), + templatePath: "testdata/output", + want: "https://multiproject1.com", + wantRemain: []string{"https://node-multiproject1-multiproject.example.com", "https://multiproject1.com"}, + wantautoGen: []string{"https://node-multiproject1-multiproject.example.com"}, + wantJSON: `{"primary":"https://multiproject1.com","secondary":["https://node-multiproject1-multiproject.example.com","https://multiproject1.com"],"autogenerated":["https://node-multiproject1-multiproject.example.com"]}`, }, { name: "test6 multiproject2 no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "multiproject2", - environmentName: "multiproject", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "multiproject", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test6/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://multiproject2.com", - wantRemain: []string{"https://node-multiproject2-multiproject.example.com", "https://multiproject2.com"}, - wantautoGen: []string{"https://node-multiproject2-multiproject.example.com"}, - wantJSON: `{"primary":"https://multiproject2.com","secondary":["https://node-multiproject2-multiproject.example.com","https://multiproject2.com"],"autogenerated":["https://node-multiproject2-multiproject.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "multiproject2", + EnvironmentName: "multiproject", + Branch: "multiproject", + LagoonYAML: "../internal/testdata/node/lagoon.polysite.yml", + }, true), + templatePath: "testdata/output", + want: "https://multiproject2.com", + wantRemain: []string{"https://node-multiproject2-multiproject.example.com", "https://multiproject2.com"}, + wantautoGen: []string{"https://node-multiproject2-multiproject.example.com"}, + wantJSON: `{"primary":"https://multiproject2.com","secondary":["https://node-multiproject2-multiproject.example.com","https://multiproject2.com"],"autogenerated":["https://node-multiproject2-multiproject.example.com"]}`, }, { name: "test7 multidomain no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test7/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com", "https://www.example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-main.example.com","https://example.com","https://www.example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "tworoutes", + Branch: "tworoutes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://node-example-project-tworoutes.example.com", "https://example.com", "https://www.example.com"}, + wantautoGen: []string{"https://node-example-project-tworoutes.example.com"}, + wantJSON: `{"primary":"https://example.com","secondary":["https://node-example-project-tworoutes.example.com","https://example.com","https://www.example.com"],"autogenerated":["https://node-example-project-tworoutes.example.com"]}`, }, { name: "test8 multidomain no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "branch-routes", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "branch/routes", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test8/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://customdomain-will-be-main-domain.com", - wantRemain: []string{"https://node-example-project-branch-routes.example.com", "https://customdomain-will-be-main-domain.com", "https://customdomain-will-be-not-be-main-domain.com"}, - wantautoGen: []string{"https://node-example-project-branch-routes.example.com"}, - wantJSON: `{"primary":"https://customdomain-will-be-main-domain.com","secondary":["https://node-example-project-branch-routes.example.com","https://customdomain-will-be-main-domain.com","https://customdomain-will-be-not-be-main-domain.com"],"autogenerated":["https://node-example-project-branch-routes.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "branch-routes", + Branch: "branch/routes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "https://customdomain-will-be-main-domain.com", + wantRemain: []string{"https://node-example-project-branch-routes.example.com", "https://customdomain-will-be-main-domain.com", "https://customdomain-will-be-not-be-main-domain.com"}, + wantautoGen: []string{"https://node-example-project-branch-routes.example.com"}, + wantJSON: `{"primary":"https://customdomain-will-be-main-domain.com","secondary":["https://node-example-project-branch-routes.example.com","https://customdomain-will-be-main-domain.com","https://customdomain-will-be-not-be-main-domain.com"],"autogenerated":["https://node-example-project-branch-routes.example.com"]}`, }, { name: "test9 active no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - activeEnvironment: "main", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/identify-ingress/test9/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://active.example.com", - wantRemain: []string{"https://node-example-project-main.example.com", "https://main.example.com", "https://active.example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://active.example.com","secondary":["https://node-example-project-main.example.com","https://main.example.com","https://active.example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + ActiveEnvironment: "main", + StandbyEnvironment: "main-sb", + LagoonYAML: "../internal/testdata/node/lagoon.activestandby.yml", + }, true), + templatePath: "testdata/output", + want: "https://active.example.com", + wantRemain: []string{"https://node-example-project-main.example.com", "https://main.example.com", "https://active.example.com"}, + wantautoGen: []string{"https://node-example-project-main.example.com"}, + wantJSON: `{"primary":"https://active.example.com","secondary":["https://node-example-project-main.example.com","https://main.example.com","https://active.example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, }, { name: "test10 standby no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main2", - environmentType: "production", - buildType: "branch", - standbyEnvironment: "main2", - lagoonVersion: "v2.7.x", - branch: "main2", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/identify-ingress/test10/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://standby.example.com", - wantRemain: []string{"https://node-example-project-main2.example.com", "https://main2.example.com", "https://standby.example.com"}, - wantautoGen: []string{"https://node-example-project-main2.example.com"}, - wantJSON: `{"primary":"https://standby.example.com","secondary":["https://node-example-project-main2.example.com","https://main2.example.com","https://standby.example.com"],"autogenerated":["https://node-example-project-main2.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main-sb", + Branch: "main-sb", + ActiveEnvironment: "main", + StandbyEnvironment: "main-sb", + LagoonYAML: "../internal/testdata/node/lagoon.activestandby.yml", + }, true), + templatePath: "testdata/output", + want: "https://standby.example.com", + wantRemain: []string{"https://node-example-project-main-sb.example.com", "https://main-sb.example.com", "https://standby.example.com"}, + wantautoGen: []string{"https://node-example-project-main-sb.example.com"}, + wantJSON: `{"primary":"https://standby.example.com","secondary":["https://node-example-project-main-sb.example.com","https://main-sb.example.com","https://standby.example.com"],"autogenerated":["https://node-example-project-main-sb.example.com"]}`, }, { name: "test11 no custom ingress", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "no-ingress", - environmentType: "production", - buildType: "branch", - standbyEnvironment: "no-ingress", - lagoonVersion: "v2.7.x", - branch: "main2", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/identify-ingress/test11/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://node-example-project-no-ingress.example.com", - wantRemain: []string{"https://node-example-project-no-ingress.example.com"}, - wantautoGen: []string{"https://node-example-project-no-ingress.example.com"}, - wantJSON: `{"primary":"https://node-example-project-no-ingress.example.com","secondary":["https://node-example-project-no-ingress.example.com"],"autogenerated":["https://node-example-project-no-ingress.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "no-ingress", + Branch: "no-ingress", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "https://node-example-project-no-ingress.example.com", + wantRemain: []string{"https://node-example-project-no-ingress.example.com"}, + wantautoGen: []string{"https://node-example-project-no-ingress.example.com"}, + wantJSON: `{"primary":"https://node-example-project-no-ingress.example.com","secondary":["https://node-example-project-no-ingress.example.com"],"autogenerated":["https://node-example-project-no-ingress.example.com"]}`, }, { name: "test12 no custom ingress", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "no-ingress", - environmentType: "production", - buildType: "branch", - standbyEnvironment: "no-ingress", - lagoonVersion: "v2.7.x", - branch: "main2", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/identify-ingress/test12/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://node-example-project-no-ingress.example.com", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "no-ingress", + Branch: "no-ingress", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-prefixes-1.yml", + }, true), + templatePath: "testdata/output", + want: "https://node-example-project-no-ingress.example.com", wantRemain: []string{ "https://node-example-project-no-ingress.example.com", "https://www.node-example-project-no-ingress.example.com", @@ -316,214 +238,119 @@ func TestIdentifyRoute(t *testing.T) { }, { name: "test13 no autogenerated routes", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test13/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://example.com", - wantRemain: []string{"https://example.com"}, - wantautoGen: []string{}, - wantJSON: `{"primary":"https://example.com","secondary":["https://example.com"],"autogenerated":[]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-1.yml", + }, true), + templatePath: "testdata/output", + want: "https://example.com", + wantRemain: []string{"https://example.com"}, + wantautoGen: []string{}, + wantJSON: `{"primary":"https://example.com","secondary":["https://example.com"],"autogenerated":[]}`, }, { name: "test14 only autogenerated route", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test14/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://node-example-project-main.example.com", - wantRemain: []string{"https://node-example-project-main.example.com"}, - wantautoGen: []string{"https://node-example-project-main.example.com"}, - wantJSON: `{"primary":"https://node-example-project-main.example.com","secondary":["https://node-example-project-main.example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "notmain", + Branch: "notmain", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "https://node-example-project-notmain.example.com", + wantRemain: []string{"https://node-example-project-notmain.example.com"}, + wantautoGen: []string{"https://node-example-project-notmain.example.com"}, + wantJSON: `{"primary":"https://node-example-project-notmain.example.com","secondary":["https://node-example-project-notmain.example.com"],"autogenerated":["https://node-example-project-notmain.example.com"]}`, }, { name: "test15 only autogenerated route complex", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "sales-customer-support", - environmentName: "develop", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "develop", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.ex1.example-web.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test15/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://nginx-sales-customer-support-develop.ex1.example-web.com", - wantRemain: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"}, - wantautoGen: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"}, - wantJSON: `{"primary":"https://nginx-sales-customer-support-develop.ex1.example-web.com","secondary":["https://nginx-sales-customer-support-develop.ex1.example-web.com"],"autogenerated":["https://nginx-sales-customer-support-develop.ex1.example-web.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "sales-customer-support", + EnvironmentName: "develop", + Branch: "develop", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/complex/lagoon.small.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${service}-${project}-${environment}.ex1.example-web.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "https://nginx-sales-customer-support-develop.ex1.example-web.com", + wantRemain: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"}, + wantautoGen: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"}, + wantJSON: `{"primary":"https://nginx-sales-customer-support-develop.ex1.example-web.com","secondary":["https://nginx-sales-customer-support-develop.ex1.example-web.com"],"autogenerated":["https://nginx-sales-customer-support-develop.ex1.example-web.com"]}`, }, { name: "test16 autogenerated routes where lagoon.name of service does not match service names", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "content-example-com", - environmentName: "feature-migration", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "feature/migration", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test16/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://nginx-php.feature-migration.content-example-com.example.com", - wantRemain: []string{"https://nginx-php.feature-migration.content-example-com.example.com"}, - wantautoGen: []string{"https://nginx-php.feature-migration.content-example-com.example.com"}, - wantJSON: `{"primary":"https://nginx-php.feature-migration.content-example-com.example.com","secondary":["https://nginx-php.feature-migration.content-example-com.example.com"],"autogenerated":["https://nginx-php.feature-migration.content-example-com.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "content-example-com", + EnvironmentName: "feature-migration", + Branch: "feature/migration", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/nginxphp/lagoon.nginx-2.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${environment}.${project}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "https://nginx-php.feature-migration.content-example-com.example.com", + wantRemain: []string{"https://nginx-php.feature-migration.content-example-com.example.com"}, + wantautoGen: []string{"https://nginx-php.feature-migration.content-example-com.example.com"}, + wantJSON: `{"primary":"https://nginx-php.feature-migration.content-example-com.example.com","secondary":["https://nginx-php.feature-migration.content-example-com.example.com"],"autogenerated":["https://nginx-php.feature-migration.content-example-com.example.com"]}`, }, { name: "test17 autogenerated routes with mulitple routeable services", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test17/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://nginx-example-project-main.example.com", - wantRemain: []string{"https://nginx-example-project-main.example.com", "https://varnish-example-project-main.example.com"}, - wantautoGen: []string{"https://nginx-example-project-main.example.com", "https://varnish-example-project-main.example.com"}, - wantJSON: `{"primary":"https://nginx-example-project-main.example.com","secondary":["https://nginx-example-project-main.example.com","https://varnish-example-project-main.example.com"],"autogenerated":["https://nginx-example-project-main.example.com","https://varnish-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.small-2.yml", + }, true), + templatePath: "testdata/output", + want: "https://nginx-example-project-main.example.com", + wantRemain: []string{"https://nginx-example-project-main.example.com", "https://varnish-example-project-main.example.com"}, + wantautoGen: []string{"https://nginx-example-project-main.example.com", "https://varnish-example-project-main.example.com"}, + wantJSON: `{"primary":"https://nginx-example-project-main.example.com","secondary":["https://nginx-example-project-main.example.com","https://varnish-example-project-main.example.com"],"autogenerated":["https://nginx-example-project-main.example.com","https://varnish-example-project-main.example.com"]}`, }, { name: "test18 autogenerated routes with wildcard and altnames", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test18/lagoon.yml", - templatePath: "../test-resources/output", - }, - want: "https://wild.example.com", - wantRemain: []string{"https://nginx-example-project-main.example.com", "https://wild.example.com", "https://alt.example.com", "https://www.example.com", "https://en.example.com"}, - wantautoGen: []string{"https://nginx-example-project-main.example.com"}, - wantJSON: `{"primary":"https://wild.example.com","secondary":["https://nginx-example-project-main.example.com","https://wild.example.com","https://alt.example.com","https://www.example.com","https://en.example.com"],"autogenerated":["https://nginx-example-project-main.example.com"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.complex-2.yml", + }, true), + templatePath: "testdata/output", + want: "https://wild.example.com", + wantRemain: []string{"https://nginx-example-project-main.example.com", "https://wild.example.com", "https://alt.example.com", "https://www.example.com", "https://en.example.com"}, + wantautoGen: []string{"https://nginx-example-project-main.example.com"}, + wantJSON: `{"primary":"https://wild.example.com","secondary":["https://nginx-example-project-main.example.com","https://wild.example.com","https://alt.example.com","https://www.example.com","https://en.example.com"],"autogenerated":["https://nginx-example-project-main.example.com"]}`, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_GIT_BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - primary, remainders, autogen, err := IdentifyPrimaryIngress(generator) if err != nil { t.Errorf("%v", err) @@ -580,216 +407,123 @@ func TestCreatedIngressIdentification(t *testing.T) { templatePath string } tests := []struct { - name string - args args - want string - wantJSON string - wantRemain []string - wantautoGen []string + name string + args testdata.TestData + templatePath string + want string + wantJSON string + wantRemain []string + wantautoGen []string }{ { name: "test13 no autogenerated routes", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test13/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{"example.com"}, - wantautoGen: []string{}, - wantJSON: `{"primary":"","secondary":["example.com"],"autogenerated":[]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-1.yml", + }, true), + templatePath: "testdata/output", + wantRemain: []string{"example.com"}, + wantautoGen: []string{}, + wantJSON: `{"primary":"","secondary":["example.com"],"autogenerated":[]}`, }, { name: "test14 only autogenerated route", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test14/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{}, - wantautoGen: []string{"node"}, - wantJSON: `{"primary":"","secondary":[],"autogenerated":["node"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "notmain", + Branch: "notmain", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + wantRemain: []string{}, + wantautoGen: []string{"node"}, + wantJSON: `{"primary":"","secondary":[],"autogenerated":["node"]}`, }, { name: "test15 only autogenerated route complex", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "sales-customer-support", - environmentName: "develop", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "develop", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.ex1.example-web.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test15/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{}, - wantautoGen: []string{"nginx"}, - wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "sales-customer-support", + EnvironmentName: "develop", + Branch: "develop", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/complex/lagoon.small.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${service}-${project}-${environment}.ex1.example-web.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + wantRemain: []string{}, + wantautoGen: []string{"nginx"}, + wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx"]}`, }, { name: "test16 autogenerated routes where lagoon.name of service does not match service names", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "content-example-com", - environmentName: "feature-migration", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "feature/migration", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test16/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{}, - wantautoGen: []string{"nginx-php"}, - wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx-php"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "content-example-com", + EnvironmentName: "feature-migration", + Branch: "feature/migration", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/nginxphp/lagoon.nginx-2.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${environment}.${project}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + wantRemain: []string{}, + wantautoGen: []string{"nginx-php"}, + wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx-php"]}`, }, { name: "test17 autogenerated routes with mulitple routeable services", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test17/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{}, - wantautoGen: []string{"nginx", "varnish"}, - wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx","varnish"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.small-2.yml", + }, true), + templatePath: "testdata/output", + wantRemain: []string{}, + wantautoGen: []string{"nginx", "varnish"}, + wantJSON: `{"primary":"","secondary":[],"autogenerated":["nginx","varnish"]}`, }, { name: "test18 autogenerated routes with wildcard and altnames", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/identify-ingress/test18/lagoon.yml", - templatePath: "../test-resources/output", - }, - wantRemain: []string{"wildcard-wild.example.com", "alt.example.com"}, - wantautoGen: []string{"nginx"}, - wantJSON: `{"primary":"","secondary":["wildcard-wild.example.com","alt.example.com"],"autogenerated":["nginx"]}`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.complex-2.yml", + }, true), + templatePath: "testdata/output", + wantRemain: []string{"wildcard-wild.example.com", "alt.example.com"}, + wantautoGen: []string{"nginx"}, + wantJSON: `{"primary":"","secondary":["wildcard-wild.example.com","alt.example.com"],"autogenerated":["nginx"]}`, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_GIT_BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - generator.LagoonYAML = tt.args.lagoonYAML - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) autogen, remainders, err := CreatedIngressIdentification(generator) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 2df51d83..b17849c0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -136,6 +136,7 @@ func init() { "Path to the template on disk") rootCmd.PersistentFlags().StringP("saved-templates-path", "T", "/kubectl-build-deploy/lagoon/services-routes", "Path to where the resulting templates are saved") + rootCmd.PersistentFlags().String("default-backup-schedule", "", "The default backup schedule to use") rootCmd.PersistentFlags().StringP("monitoring-config", "M", "", "The monitoring contact config if known") rootCmd.PersistentFlags().StringP("monitoring-status-page-id", "m", "", diff --git a/cmd/tasks_run.go b/cmd/tasks_run.go index d2940045..fd970d42 100644 --- a/cmd/tasks_run.go +++ b/cmd/tasks_run.go @@ -53,7 +53,7 @@ var tasksPreRun = &cobra.Command{ Aliases: []string{"pre"}, Short: "Will run pre rollout tasks defined in .lagoon.yml", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } @@ -84,7 +84,7 @@ var tasksPostRun = &cobra.Command{ Aliases: []string{"post"}, Short: "Will run post rollout tasks defined in .lagoon.yml", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } diff --git a/cmd/template_autogen_ingress.go b/cmd/template_autogen_ingress.go index 21141368..06364728 100644 --- a/cmd/template_autogen_ingress.go +++ b/cmd/template_autogen_ingress.go @@ -14,7 +14,7 @@ var autogenRouteGeneration = &cobra.Command{ Aliases: []string{"autogen-ingress", "autogen", "ai"}, Short: "Generate the autogenerated ingress templates for a Lagoon build", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } diff --git a/cmd/template_autogen_ingress_test.go b/cmd/template_autogen_ingress_test.go index bcd431dd..ded28cae 100644 --- a/cmd/template_autogen_ingress_test.go +++ b/cmd/template_autogen_ingress_test.go @@ -7,651 +7,485 @@ import ( "os" "reflect" "testing" - "time" - "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestAutogeneratedIngressGeneration(t *testing.T) { - type args struct { - alertContact string - statusPageID string - projectName string - environmentName string - branch string - prNumber string - prHeadBranch string - prBaseBranch string - environmentType string - buildType string - activeEnvironment string - standbyEnvironment string - cacheNoCache string - serviceID string - secretPrefix string - projectVars string - envVars string - lagoonVersion string - lagoonYAML string - valuesFilePath string - templatePath string - } tests := []struct { - name string - args args - wantErr bool - emptyDir bool // if no templates are generated, then there will be a .gitkeep file in there - want string + name string + args testdata.TestData + templatePath string + wantErr bool + emptyDir bool // if no templates are generated, then there will be a .gitkeep file in there + want string }{ { name: "test1 autogenerated route", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test1/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test1-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-1", }, { name: "test2 no autogenerated routes but allow pullrequests", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "pullrequest", - prNumber: "123", - prHeadBranch: "main", - prBaseBranch: "main2", - lagoonVersion: "v2.7.x", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test2/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test2-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-123", + BuildType: "pullrequest", + PRNumber: "123", + PRHeadBranch: "main", + PRBaseBranch: "main2", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-1.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-2", }, { name: "test3 autogenerated route but no pullrequests", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "pullrequest", - prNumber: "123", - prHeadBranch: "main", - prBaseBranch: "main2", - lagoonVersion: "v2.7.x", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test3/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: true, - want: "", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-123", + BuildType: "pullrequest", + PRNumber: "123", + PRHeadBranch: "main", + PRBaseBranch: "main2", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-2.yml", + }, true), + templatePath: "testdata/output", + emptyDir: true, + want: "", }, { name: "test4 autogenerated route no service in pattern", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test4/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test4-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${project}-${environment}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-3", }, { name: "test5 autogenerated route short url", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "ci-features-control-k8s", - environmentName: "short-router-url-from-a-very-l-ebe8", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "short-router-url-from-a-very-long-environment-name-like-this", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}.${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test5/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test5-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "ci-features-control-k8s", + EnvironmentName: "short-router-url-from-a-very-l-ebe8", + Branch: "short-router-url-from-a-very-long-environment-name-like-this", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${service}.${project}-${environment}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-4", }, { name: "test6 autogenerated routes but disabled by service label", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test6/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: true, - want: "", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-3.yml", + }, true), + templatePath: "testdata/output", + emptyDir: true, + want: "", }, { name: "test7 no autogenerated routes but enabled by service label", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test7/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test7-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-4.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-5", }, { name: "test8 autogenerated routes with fastly", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[ - {"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"global"}, - {"name":"LAGOON_FASTLY_AUTOGENERATED","value":"enabled","scope":"global"} - ]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test8/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test8-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + { + Name: "LAGOON_FASTLY_AUTOGENERATED", + Value: "enabled", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-6", }, { name: "test9 autogenerated routes with fastly specific domain", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[ - {"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_FASTLY_SERVICE_IDS","value":"node-example-project-main.example.com:service-id:true","scope":"global"}, - {"name":"LAGOON_FASTLY_AUTOGENERATED","value":"enabled","scope":"global"} - ]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test9/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test9-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "node-example-project-main.example.com:service-id:true", + Scope: "build", + }, + { + Name: "LAGOON_FASTLY_AUTOGENERATED", + Value: "enabled", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-7", }, { name: "test10 autogenerated routes with fastly and specific secret", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[ - {"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true:secretname","scope":"global"}, - {"name":"LAGOON_FEATURE_FLAG_FASTLY_AUTOGENERATED","value":"enabled","scope":"global"} - ]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test10/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test10-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true:secretname", + Scope: "build", + }, + { + Name: "LAGOON_FASTLY_AUTOGENERATED", + Value: "enabled", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-8", }, { name: "test11 autogenerated route development environment", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test11/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test11-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-9", }, { - name: "test12 autogenerated route development environment", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test12/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test12-results", + name: "test12 autogenerated route development environment - no insecure redirect", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-5.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-10", }, { name: "test13 autogenerated route development service type override", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_SERVICE_TYPES","value":"node:node-persistent","scope":"build"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test13/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test13-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SERVICE_TYPES", + Value: "node:node-persistent", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-11", }, { name: "test14 autogenerated route development no service type override", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test14/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: true, - want: "", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-6.yml", + }, true), + templatePath: "testdata/output", + emptyDir: true, + want: "", }, { name: "test15 autogenerated route development service type override", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test15/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test15-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/nginxphp/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/nginxphp/autogen-templates/ingress-1", }, { - name: "test16 autogenerated route development service type override", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test16/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test16-results", + name: "test16 autogenerated route development service name override", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/nginxphp/lagoon.servicename.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/nginxphp/autogen-templates/ingress-2", }, { name: "test17 autogenerated route development service type override", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "ci-drush-la-control-k8s", - environmentName: "drush-first", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "drush-first", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}.${project}.${environment}.172.18.0.3.nip.io","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test17/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test17-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "ci-drush-la-control-k8s", + EnvironmentName: "drush-first", + Branch: "drush-first", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/complex/lagoon.small.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${service}.${project}.${environment}.172.18.0.3.nip.io", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/complex/autogen-templates/ingress-1", }, { name: "test18 autogenerated route tls-acme disabled", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test18/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test18-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "production", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-7.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-12", }, { name: "test19 autogenerated routes but tls-acme disabled by service label", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test19/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test19-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "production", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-8.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-13", }, { name: "test20 autogenerated routes where lagoon.name of service does not match service names", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "content-example-com", - environmentName: "feature-migration", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "feature/migration", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test20/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test20-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "content-example-com", + EnvironmentName: "feature-migration", + Branch: "feature/migration", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${environment}.${project}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/complex/autogen-templates/ingress-2", }, { name: "test21 autogenerated routes where docker-compose env_file has missing file references", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "test21-example-com", - environmentName: "feature", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "feature", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test21/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test21-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "test21-example-com", + EnvironmentName: "feature", + Branch: "feature", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/complex/lagoon.complex-1.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${environment}.${project}.example.com", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/complex/autogen-templates/ingress-3", }, { name: "test22 autogenerated routes where should truncate long dns", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "content-abcdefghijk-net-com-co", - environmentName: "pr-123", - environmentType: "development", - lagoonVersion: "v2.7.x", - buildType: "pullrequest", - prNumber: "123", - prHeadBranch: "main", - prBaseBranch: "main2", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.abc1.abc.net.com.co","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test22/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test22-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "content-abcdefghijk-net-com-co", + EnvironmentName: "pr-123", + EnvironmentType: "development", + BuildType: "pullrequest", + PRNumber: "123", + PRHeadBranch: "main", + PRBaseBranch: "main2", + LagoonYAML: "../internal/testdata/nginxphp/lagoon.nginx-1.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${environment}.${project}.abc1.abc.net.com.co", + Scope: "internal_system", + }, + }, + }, false), + templatePath: "testdata/output", + want: "../internal/testdata/nginxphp/autogen-templates/ingress-3", }, { name: "test23 autogenerated routes with fastly service, should be no fastly annotations on autogenerated route", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[ - {"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"global"} - ]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test23/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test23-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-14", }, { - name: "test24 autogenerated routes with fastly service, should be no fastly annotations on autogenerated route", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[ - {"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}, - {"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"global"} - ]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-autogenerated/test24/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: false, - want: "../test-resources/template-autogenerated/test24-results", + name: "test24 autogenerated routes with 'string true enabled' with fastly service, should be no fastly annotations on autogenerated route", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.autogen-9.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/autogen-templates/ingress-14", }, { name: "test25 autogenerated routes enabled globally but disabled by environment", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test25/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: true, - want: "", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "autogendisabled", + Branch: "autogendisabled", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + emptyDir: true, + want: "", }, { name: "test26 polysite autogenerated routes enabled globally but disabled by environment", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-autogenerated/test26/lagoon.yml", - templatePath: "../test-resources/template-autogenerated/output", - }, - emptyDir: true, - want: "", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "multiproject3", + EnvironmentName: "autogendisabled", + Branch: "autogendisabled", + LagoonYAML: "../internal/testdata/node/lagoon.polysite.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + emptyDir: true, + want: "", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - generator.SavedTemplatesPath = tt.args.templatePath - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - savedTemplates := tt.args.templatePath - err = os.MkdirAll(tt.args.templatePath, 0755) + err = os.MkdirAll(savedTemplates, 0755) if err != nil { t.Errorf("couldn't create directory %v: %v", savedTemplates, err) } diff --git a/cmd/template_backups.go b/cmd/template_backups.go index 62ccbae1..33ff8ef9 100644 --- a/cmd/template_backups.go +++ b/cmd/template_backups.go @@ -24,7 +24,7 @@ var backupGeneration = &cobra.Command{ if err != nil { return fmt.Errorf("error reading domain flag: %v", err) } - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } diff --git a/cmd/template_backups_test.go b/cmd/template_backups_test.go index 3194997e..0fddbd1f 100644 --- a/cmd/template_backups_test.go +++ b/cmd/template_backups_test.go @@ -6,297 +6,198 @@ import ( "os" "reflect" "testing" - "time" "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestBackupTemplateGeneration(t *testing.T) { - type args struct { - alertContact string - statusPageID string - projectName string - environmentName string - branch string - prNumber string - prHeadBranch string - prBaseBranch string - environmentType string - buildType string - activeEnvironment string - standbyEnvironment string - cacheNoCache string - serviceID string - secretPrefix string - projectVars string - envVars string - lagoonVersion string - lagoonYAML string - templatePath string - controllerDevSchedule string - controllerPRSchedule string - k8upVersion string - namespace string - defaultBackupSchedule string - } tests := []struct { - name string - args args - want string - wantErr bool + name string + args testdata.TestData + templatePath string + want string + wantErr bool }{ { - name: "test1", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_IMAGECACHE_REGISTRY","value":"https://imagecache.example.com","scope":"global"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test1/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test1-results", + name: "test1 - change the image registry used for prebackup pods", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_IMAGECACHE_REGISTRY", + Value: "imagecache.example.com", + Scope: "global", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/backup-templates/backup-1", + }, + { + name: "test2 - custom dev only schedule but global config change enabled", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG", + Value: "enabled", + Scope: "global", + }, + { + Name: "LAGOON_BACKUP_DEV_SCHEDULE", + Value: "1,31 23 * * *", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-1", }, { - name: "test2", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "development", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG","value":"enabled","scope":"global"},{"name":"LAGOON_BACKUP_DEV_SCHEDULE","value":"1,31 23 * * *","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test2/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test2-results", + name: "test3 - custom dev only schedule but global config change not configured (use defaults)", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_BACKUP_DEV_SCHEDULE", + Value: "1,31 23 * * *", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-2", }, { - name: "test3", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_BACKUP_DEV_SCHEDULE","value":"1,31 23 * * *","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test3/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test3-results", + name: "test4 - custom schedule and custom backup keys", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-123", + EnvironmentType: "development", + BuildType: "pullrequest", + PRNumber: "123", + PRHeadBranch: "main", + PRBaseBranch: "main2", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG", + Value: "enabled", + Scope: "global", + }, + {Name: "LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG", Value: "enabled", Scope: "global"}, + {Name: "LAGOON_BAAS_CUSTOM_BACKUP_ACCESS_KEY", Value: "abcdefg", Scope: "build"}, + {Name: "LAGOON_BAAS_CUSTOM_BACKUP_SECRET_KEY", Value: "abcdefg1234567", Scope: "build"}, + {Name: "LAGOON_BACKUP_DEV_SCHEDULE", Value: "1,31 23 * * *", Scope: "build"}, + {Name: "LAGOON_BACKUP_PR_SCHEDULE", Value: "3,33 12 * * *", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-3", }, { - name: "test4", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "development", - buildType: "pullrequest", - prNumber: "123", - prHeadBranch: "main", - prBaseBranch: "main2", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG","value":"enabled","scope":"global"},{"name":"LAGOON_BAAS_CUSTOM_BACKUP_ACCESS_KEY","value":"abcdefg","scope":"build"},{"name":"LAGOON_BAAS_CUSTOM_BACKUP_SECRET_KEY","value":"abcdefg1234567","scope":"build"},{"name":"LAGOON_BACKUP_DEV_SCHEDULE","value":"1,31 23 * * *","scope":"build"},{"name":"LAGOON_BACKUP_PR_SCHEDULE","value":"3,33 12 * * *","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test4/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test4-results", + name: "test5 - custom schedule and custom restore keys", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-123", + EnvironmentType: "development", + BuildType: "pullrequest", + PRNumber: "123", + PRHeadBranch: "main", + PRBaseBranch: "main2", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG", + Value: "enabled", + Scope: "global", + }, + {Name: "LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG", Value: "enabled", Scope: "global"}, + {Name: "LAGOON_BAAS_CUSTOM_RESTORE_ACCESS_KEY", Value: "abcdefg", Scope: "build"}, + {Name: "LAGOON_BAAS_CUSTOM_RESTORE_SECRET_KEY", Value: "abcdefg1234567", Scope: "build"}, + {Name: "LAGOON_BACKUP_DEV_SCHEDULE", Value: "1,31 23 * * *", Scope: "build"}, + {Name: "LAGOON_BACKUP_PR_SCHEDULE", Value: "3,33 12 * * *", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-4", }, { - name: "test5", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "development", - buildType: "pullrequest", - prNumber: "123", - prHeadBranch: "main", - prBaseBranch: "main2", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_CUSTOM_BACKUP_CONFIG","value":"enabled","scope":"global"},{"name":"LAGOON_BAAS_CUSTOM_RESTORE_ACCESS_KEY","value":"abcdefg","scope":"build"},{"name":"LAGOON_BAAS_CUSTOM_RESTORE_SECRET_KEY","value":"abcdefg1234567","scope":"build"},{"name":"LAGOON_BACKUP_DEV_SCHEDULE","value":"1,31 23 * * *","scope":"build"},{"name":"LAGOON_BACKUP_PR_SCHEDULE","value":"3,33 12 * * *","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test5/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test5-results", + name: "test6 - generic backup", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "production", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-5", }, { - name: "test6", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test6/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - }, - want: "../test-resources/template-backups/test6-results", + name: "test7 - changed default backup schedule", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "production", + DefaultBackupSchedule: "M */6 * * *", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/backup-templates/backup-6", }, { - name: "test7", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - namespace: "example-project-main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - k8upVersion: "v1", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-backups/test7/lagoon.yml", - templatePath: "../test-resources/template-backups/output", - defaultBackupSchedule: "M */6 * * *", - }, - want: "../test-resources/template-backups/test7-results", + name: "test8 - change the image registry used for prebackup pods k8upv2", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + K8UPVersion: "v2", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_IMAGECACHE_REGISTRY", + Value: "imagecache.example.com", + Scope: "global", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/backup-templates/backup-2", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("NAMESPACE", tt.args.namespace) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_GIT_BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FEATURE_BACKUP_DEV_SCHEDULE", tt.args.controllerDevSchedule) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FEATURE_BACKUP_PR_SCHEDULE", tt.args.controllerPRSchedule) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("DEFAULT_BACKUP_SCHEDULE", tt.args.defaultBackupSchedule) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - generator.SavedTemplatesPath = tt.args.templatePath - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - generator.BackupConfiguration.K8upVersion = tt.args.k8upVersion - - savedTemplates := tt.args.templatePath - err = os.MkdirAll(tt.args.templatePath, 0755) + err = os.MkdirAll(savedTemplates, 0755) if err != nil { t.Errorf("couldn't create directory %v: %v", savedTemplates, err) } @@ -361,7 +262,7 @@ func TestBackupTemplateGeneration(t *testing.T) { t.Errorf("resulting templates do not match") } t.Cleanup(func() { - helpers.UnsetEnvVars([]helpers.EnvironmentVariable{{Name: "DEFAULT_BACKUP_SCHEDULE"}}) + helpers.UnsetEnvVars(nil) }) }) } diff --git a/cmd/template_dbaas.go b/cmd/template_dbaas.go index 3365a729..421f7cae 100644 --- a/cmd/template_dbaas.go +++ b/cmd/template_dbaas.go @@ -14,7 +14,7 @@ var dbaasGeneration = &cobra.Command{ Aliases: []string{"db"}, Short: "Generate the DBaaS templates for a Lagoon build", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } diff --git a/cmd/template_dbaas_test.go b/cmd/template_dbaas_test.go index bf205e0e..bff3765b 100644 --- a/cmd/template_dbaas_test.go +++ b/cmd/template_dbaas_test.go @@ -6,156 +6,42 @@ import ( "os" "reflect" "testing" - "time" "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestDBaaSTemplateGeneration(t *testing.T) { - type args struct { - alertContact string - statusPageID string - projectName string - environmentName string - branch string - prNumber string - prHeadBranch string - prBaseBranch string - environmentType string - buildType string - activeEnvironment string - standbyEnvironment string - cacheNoCache string - serviceID string - secretPrefix string - projectVars string - envVars string - lagoonVersion string - lagoonYAML string - templatePath string - controllerDevSchedule string - controllerPRSchedule string - } tests := []struct { - name string - args args - want string - wantErr bool + name string + args testdata.TestData + templatePath string + want string + wantErr bool }{ { name: "test1 - mariadb-dbaas", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-dbaas/test1/lagoon.yml", - templatePath: "../test-resources/template-dbaas/output", - }, - want: "../test-resources/template-dbaas/test1-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/dbaas-templates/dbaas-1", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_GIT_BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("LAGOON_FEATURE_BACKUP_DEV_SCHEDULE", tt.args.controllerDevSchedule) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FEATURE_BACKUP_PR_SCHEDULE", tt.args.controllerPRSchedule) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - generator.SavedTemplatesPath = tt.args.templatePath - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - - savedTemplates := tt.args.templatePath - err = os.MkdirAll(tt.args.templatePath, 0755) + err = os.MkdirAll(savedTemplates, 0755) if err != nil { t.Errorf("couldn't create directory %v: %v", savedTemplates, err) } diff --git a/cmd/template_ingress.go b/cmd/template_ingress.go index db8108d3..993c8d40 100644 --- a/cmd/template_ingress.go +++ b/cmd/template_ingress.go @@ -14,7 +14,7 @@ var routeGeneration = &cobra.Command{ Aliases: []string{"i"}, Short: "Generate the ingress templates for a Lagoon build", RunE: func(cmd *cobra.Command, args []string) error { - generator, err := generatorInput(true) + generator, err := generator.GenerateInput(*rootCmd, true) if err != nil { return err } diff --git a/cmd/template_ingress_test.go b/cmd/template_ingress_test.go index 20a44562..a85fe839 100644 --- a/cmd/template_ingress_test.go +++ b/cmd/template_ingress_test.go @@ -1,562 +1,394 @@ package cmd import ( + "encoding/base64" "fmt" "io/ioutil" "os" "reflect" "testing" - "time" - "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" ) func TestTemplateRoutes(t *testing.T) { - type args struct { - alertContact string - statusPageID string - projectName string - environmentName string - branch string - prNumber string - prHeadBranch string - prBaseBranch string - environmentType string - buildType string - activeEnvironment string - standbyEnvironment string - cacheNoCache string - serviceID string - secretPrefix string - ingressClass string - projectVars string - envVars string - lagoonVersion string - lagoonYAML string - valuesFilePath string - templatePath string - } tests := []struct { - name string - args args - want string + name string + args testdata.TestData + templatePath string + want string }{ { name: "test1 check LAGOON_FASTLY_SERVICE_IDS with secret no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test1/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test1-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true:annotationscom", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-1", }, { name: "test2 check LAGOON_FASTLY_SERVICE_IDS no secret and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test2/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test2-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-2", }, { name: "test3 check LAGOON_FASTLY_SERVICE_ID no secret and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test3/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test3-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_ID", + Value: "service-id:true", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-3", }, { name: "test4 check no fastly and no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test4/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test4-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-4", }, { name: "test5 multiproject1 no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "multiproject1", - environmentName: "multiproject", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "multiproject", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test5/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test5-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "multiproject1", + EnvironmentName: "multiproject", + Branch: "multiproject", + LagoonYAML: "../internal/testdata/node/lagoon.polysite.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-5", }, { name: "test6 multiproject2 no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "multiproject2", - environmentName: "multiproject", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "multiproject", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test6/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test6-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "multiproject2", + EnvironmentName: "multiproject", + Branch: "multiproject", + LagoonYAML: "../internal/testdata/node/lagoon.polysite.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-6", }, { name: "test7 multidomain no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test7/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test7-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "tworoutes", + Branch: "tworoutes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-7", }, { name: "test8 multidomain no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "branch-routes", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "branch/routes", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test8/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test8-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "branch-routes", + Branch: "branch/routes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-8", }, { name: "test9 active no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - activeEnvironment: "main", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-ingress/test9/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test9-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + ActiveEnvironment: "main", + StandbyEnvironment: "main-sb", + LagoonYAML: "../internal/testdata/node/lagoon.activestandby.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-9", }, { name: "test10 standby no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main2", - environmentType: "production", - buildType: "branch", - standbyEnvironment: "main2", - lagoonVersion: "v2.7.x", - branch: "main2", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-ingress/test10/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test10-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main-sb", + Branch: "main-sb", + ActiveEnvironment: "main", + StandbyEnvironment: "main-sb", + LagoonYAML: "../internal/testdata/node/lagoon.activestandby.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-10", }, { name: "test11 standby no values", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "content-example-com", - environmentName: "production", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "production", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${environment}.${project}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test11/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test11-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "content-example-com", + EnvironmentName: "production", + Branch: "production", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/ingress-templates/ingress-1", }, { name: "test12 check LAGOON_ROUTES_JSON generates ingress", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_ROUTES_JSON","value":"eyJyb3V0ZXMiOlt7ImRvbWFpbiI6InRlc3QxLmV4YW1wbGUuY29tIiwic2VydmljZSI6Im5naW54IiwidGxzLWFjbWUiOmZhbHNlLCJtb25pdG9yaW5nLXBhdGgiOiIvYnlwYXNzLWNhY2hlIn1dfQo=","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test12/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test12-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "noyamlroutes", + Branch: "noyamlroutes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true:annotationscom", + Scope: "build", + }, + { + Name: "LAGOON_ROUTES_JSON", + Value: base64.StdEncoding.EncodeToString([]byte(`{"routes":[{"domain":"test1.example.com","service":"nginx","tls-acme":false,"monitoring-path":"/bypass-cache"}]}`)), + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-11", }, { name: "test13 ingress class from default flag", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - ingressClass: "nginx", - lagoonYAML: "../test-resources/template-ingress/test13/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test13-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + IngressClass: "nginx", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-12", }, { name: "test14 ingress class from lagoon.yml should overwrite default and featureflag variable", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - ingressClass: "nginx", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_INGRESS_CLASS","value":"nginx","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test14/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test14-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "ingressclass", + Branch: "ingressclass", + IngressClass: "nginx", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-13", }, { name: "test15a ingress class from lagoon api project scope", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - ingressClass: "nginx", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_INGRESS_CLASS","value":"custom-ingress","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test15/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test15-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + IngressClass: "nginx", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_INGRESS_CLASS", + Value: "custom-ingress", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-14", }, { name: "test15b ingress class from lagoon api environment scope", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - ingressClass: "nginx", - projectVars: `[{"name":"LAGOON_FEATURE_FLAG_INGRESS_CLASS","value":"project-custom-ingress","scope":"build"},{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[{"name":"LAGOON_FEATURE_FLAG_INGRESS_CLASS","value":"custom-ingress","scope":"build"}]`, - lagoonYAML: "../test-resources/template-ingress/test15/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test15-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_INGRESS_CLASS", + Value: "project-custom-ingress", + Scope: "build", + }, + }, + EnvVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FEATURE_FLAG_INGRESS_CLASS", + Value: "custom-ingress", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-15", }, { name: "test16 hsts basic", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test16/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test16-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "hsts", + Branch: "hsts", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true:annotationscom", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-16", }, { name: "test17 hsts advanced", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test17/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test17-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "hsts2", + Branch: "hsts2", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_FASTLY_SERVICE_IDS", + Value: "example.com:service-id:true:annotationscom", + Scope: "build", + }, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-17", }, { name: "test18 check first route has monitoring only", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test18/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test18-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "tworoutes", + Branch: "tworoutes", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-18", }, { name: "test19 pullrequest routes", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "pr-4841", - environmentType: "development", - buildType: "pullrequest", - lagoonVersion: "v2.7.x", - prNumber: "4841", - prHeadBranch: "main", - prBaseBranch: "my-branch", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test19/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test19-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-4841", + BuildType: "pullrequest", + PRNumber: "4841", + PRHeadBranch: "main", + PRBaseBranch: "my-branch", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-19", }, { name: "test20 pullrequest routes polysite", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "pr-4841", - environmentType: "development", - buildType: "pullrequest", - lagoonVersion: "v2.7.x", - prNumber: "4841", - prHeadBranch: "main", - prBaseBranch: "my-branch", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test20/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test20-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "pr-4841", + BuildType: "pullrequest", + PRNumber: "4841", + PRHeadBranch: "main", + PRBaseBranch: "my-branch", + EnvironmentType: "development", + LagoonYAML: "../internal/testdata/node/lagoon.polysite-pr.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-20", }, { name: "test21 alternative names", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - standbyEnvironment: "main2", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - secretPrefix: "fastly-api-", - lagoonYAML: "../test-resources/template-ingress/test21/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test21-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "alternativename", + Branch: "alternativename", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-21", }, { name: "test22 check wildcard", - args: args{ - alertContact: "alertcontact", - statusPageID: "statuspageid", - projectName: "example-project", - environmentName: "main", - environmentType: "production", - buildType: "branch", - lagoonVersion: "v2.7.x", - branch: "main", - projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`, - envVars: `[]`, - lagoonYAML: "../test-resources/template-ingress/test22/lagoon.yml", - templatePath: "../test-resources/template-ingress/output", - }, - want: "../test-resources/template-ingress/test22-results", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "wildcard", + Branch: "wildcard", + LagoonYAML: "../internal/testdata/node/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/ingress-templates/ingress-22", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // set the environment variables from args - err := os.Setenv("MONITORING_ALERTCONTACT", tt.args.alertContact) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("MONITORING_STATUSPAGEID", tt.args.statusPageID) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PROJECT", tt.args.projectName) + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) if err != nil { t.Errorf("%v", err) } - err = os.Setenv("ENVIRONMENT", tt.args.environmentName) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BRANCH", tt.args.branch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_NUMBER", tt.args.prNumber) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_HEAD_BRANCH", tt.args.prHeadBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("PR_BASE_BRANCH", tt.args.prBaseBranch) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ENVIRONMENT_TYPE", tt.args.environmentType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("BUILD_TYPE", tt.args.buildType) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("ACTIVE_ENVIRONMENT", tt.args.activeEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("STANDBY_ENVIRONMENT", tt.args.standbyEnvironment) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", tt.args.cacheNoCache) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_PROJECT_VARIABLES", tt.args.projectVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", tt.args.envVars) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_VERSION", tt.args.lagoonVersion) - if err != nil { - t.Errorf("%v", err) - } - err = os.Setenv("LAGOON_FEATURE_FLAG_DEFAULT_INGRESS_CLASS", tt.args.ingressClass) - if err != nil { - t.Errorf("%v", err) - } - generator, err := generatorInput(false) - if err != nil { - t.Errorf("%v", err) - } - generator.LagoonYAML = tt.args.lagoonYAML - generator.SavedTemplatesPath = tt.args.templatePath - // add dbaasclient overrides for tests - generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ - RetryMax: 5, - RetryWaitMin: time.Duration(10) * time.Millisecond, - RetryWaitMax: time.Duration(50) * time.Millisecond, - }) - savedTemplates := tt.args.templatePath - err = os.MkdirAll(tt.args.templatePath, 0755) + err = os.MkdirAll(savedTemplates, 0755) if err != nil { t.Errorf("couldn't create directory %v: %v", savedTemplates, err) } diff --git a/internal/generator/generator.go b/internal/generator/generator.go index 6fa06a88..029bbf65 100644 --- a/internal/generator/generator.go +++ b/internal/generator/generator.go @@ -54,6 +54,7 @@ type GeneratorInput struct { Debug bool DBaaSClient *dbaasclient.Client Namespace string + DefaultBackupSchedule string } func NewGenerator( @@ -88,7 +89,10 @@ func NewGenerator( fastlyAPISecretPrefix := helpers.GetEnv("ROUTE_FASTLY_SERVICE_ID", generator.FastlyAPISecretPrefix, generator.Debug) lagoonVersion := helpers.GetEnv("LAGOON_VERSION", generator.LagoonVersion, generator.Debug) - defaultBackupSchedule := helpers.GetEnv("DEFAULT_BACKUP_SCHEDULE", "M H(22-2) * * *", generator.Debug) + defaultBackupSchedule := helpers.GetEnv("DEFAULT_BACKUP_SCHEDULE", generator.DefaultBackupSchedule, generator.Debug) + if defaultBackupSchedule == "" { + defaultBackupSchedule = "M H(22-2) * * *" + } // try source the namespace from the generator, but whatever is defined in the service account location // should be used if one exists, falls back to whatever came in via generator @@ -378,7 +382,7 @@ func collectBuildVariables(buildValues BuildValues) []lagoon.EnvironmentVariable return vars } -// GetEnv gets an environment variable +// checks the provided environment variables looking for feature flag based variables func CheckFeatureFlag(key string, envVariables []lagoon.EnvironmentVariable, debug bool) string { // check for force value if value, ok := os.LookupEnv(fmt.Sprintf("LAGOON_FEATURE_FLAG_FORCE_%s", key)); ok { diff --git a/cmd/helpers_values.go b/internal/generator/helpers_generator.go similarity index 58% rename from cmd/helpers_values.go rename to internal/generator/helpers_generator.go index 2df1afd1..6686fde1 100644 --- a/cmd/helpers_values.go +++ b/internal/generator/helpers_generator.go @@ -1,108 +1,114 @@ -package cmd +package generator import ( "fmt" + "github.com/spf13/cobra" "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" - generator "github.com/uselagoon/build-deploy-tool/internal/generator" ) -func generatorInput(debug bool) (generator.GeneratorInput, error) { +// helper function that reads flag overrides and retruns a generated input dataset +// this is called from within the main environment setup helper function +func GenerateInput(rootCmd cobra.Command, debug bool) (GeneratorInput, error) { lagoonYAML, err := rootCmd.PersistentFlags().GetString("lagoon-yml") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading lagoon-yml flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading lagoon-yml flag: %v", err) } lagoonYAMLOverride, err := rootCmd.PersistentFlags().GetString("lagoon-yml-override") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading lagoon-yml-override flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading lagoon-yml-override flag: %v", err) } lagoonVersion, err := rootCmd.PersistentFlags().GetString("lagoon-version") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading lagoon-version flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading lagoon-version flag: %v", err) } projectName, err := rootCmd.PersistentFlags().GetString("project-name") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading project-name flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading project-name flag: %v", err) } environmentName, err := rootCmd.PersistentFlags().GetString("environment-name") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading environment-name flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading environment-name flag: %v", err) } environmentType, err := rootCmd.PersistentFlags().GetString("environment-type") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading environment-type flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading environment-type flag: %v", err) } activeEnvironment, err := rootCmd.PersistentFlags().GetString("active-environment") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading active-environment flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading active-environment flag: %v", err) } standbyEnvironment, err := rootCmd.PersistentFlags().GetString("standby-environment") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading standby-environment flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading standby-environment flag: %v", err) } projectVariables, err := rootCmd.PersistentFlags().GetString("project-variables") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading project-variables flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading project-variables flag: %v", err) } environmentVariables, err := rootCmd.PersistentFlags().GetString("environment-variables") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading environment-variables flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading environment-variables flag: %v", err) } buildType, err := rootCmd.PersistentFlags().GetString("build-type") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading build-type flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading build-type flag: %v", err) } branch, err := rootCmd.PersistentFlags().GetString("branch") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading branch flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading branch flag: %v", err) } prNumber, err := rootCmd.PersistentFlags().GetString("pullrequest-number") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading pullrequest-number flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading pullrequest-number flag: %v", err) } prTitle, err := rootCmd.PersistentFlags().GetString("pullrequest-title") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading pullrequest-title flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading pullrequest-title flag: %v", err) } prHeadBranch, err := rootCmd.PersistentFlags().GetString("pullrequest-head-branch") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading pullrequest-head-branch flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading pullrequest-head-branch flag: %v", err) } prBaseBranch, err := rootCmd.PersistentFlags().GetString("pullrequest-base-branch") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading pullrequest-base-branch flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading pullrequest-base-branch flag: %v", err) } monitoringContact, err := rootCmd.PersistentFlags().GetString("monitoring-config") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading monitoring-config flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading monitoring-config flag: %v", err) } monitoringStatusPageID, err := rootCmd.PersistentFlags().GetString("monitoring-status-page-id") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading monitoring-status-page-id flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading monitoring-status-page-id flag: %v", err) } fastlyCacheNoCahce, err := rootCmd.PersistentFlags().GetString("fastly-cache-no-cache-id") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading fastly-cache-no-cache-id flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading fastly-cache-no-cache-id flag: %v", err) } fastlyAPISecretPrefix, err := rootCmd.PersistentFlags().GetString("fastly-api-secret-prefix") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading fastly-api-secret-prefix flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading fastly-api-secret-prefix flag: %v", err) } ignoreMissingEnvFiles, err := rootCmd.PersistentFlags().GetBool("ignore-missing-env-files") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading ignore-missing-env-files flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading ignore-missing-env-files flag: %v", err) } ignoreNonStringKeyErrors, err := rootCmd.PersistentFlags().GetBool("ignore-non-string-key-errors") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading ignore-non-string-key-errors flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading ignore-non-string-key-errors flag: %v", err) } savedTemplates, err := rootCmd.PersistentFlags().GetString("saved-templates-path") if err != nil { - return generator.GeneratorInput{}, fmt.Errorf("error reading saved-templates-path flag: %v", err) + return GeneratorInput{}, fmt.Errorf("error reading saved-templates-path flag: %v", err) + } + defaultBackupSchedule, err := rootCmd.PersistentFlags().GetString("default-backup-schedule") + if err != nil { + return GeneratorInput{}, fmt.Errorf("error reading default-backup-schedule flag: %v", err) } // create a dbaas client with the default configuration dbaas := dbaasclient.NewClient(dbaasclient.Client{}) - return generator.GeneratorInput{ + return GeneratorInput{ Debug: debug, LagoonYAML: lagoonYAML, LagoonYAMLOverride: lagoonYAMLOverride, @@ -128,5 +134,6 @@ func generatorInput(debug bool) (generator.GeneratorInput, error) { IgnoreMissingEnvFiles: ignoreMissingEnvFiles, IgnoreNonStringKeyErrors: ignoreNonStringKeyErrors, DBaaSClient: dbaas, + DefaultBackupSchedule: defaultBackupSchedule, }, nil } diff --git a/internal/helpers/helpers.go b/internal/helpers/helpers.go index 0d1d16cf..1b979c66 100644 --- a/internal/helpers/helpers.go +++ b/internal/helpers/helpers.go @@ -207,6 +207,10 @@ func UnsetEnvVars(localVars []EnvironmentVariable) { "LAGOON_FEATURE_BACKUP_DEV_SCHEDULE", "LAGOON_FEATURE_BACKUP_PR_SCHEDULE", "LAGOON_GIT_BRANCH", + "DEFAULT_BACKUP_SCHEDULE", + "LAGOON_FEATURE_BACKUP_DEV_SCHEDULE", + "LAGOON_FEATURE_BACKUP_PR_SCHEDULE", + "LAGOON_FEATURE_FLAG_DEFAULT_INGRESS_CLASS", } for _, varName := range varNames { os.Unsetenv(varName) diff --git a/internal/lagoon/lagoon_test.go b/internal/lagoon/lagoon_test.go index 49a58b04..61b50af1 100644 --- a/internal/lagoon/lagoon_test.go +++ b/internal/lagoon/lagoon_test.go @@ -22,7 +22,7 @@ func TestUnmarshalLagoonYAML(t *testing.T) { { name: "test-booleans-represented-as-strings", args: args{ - file: "../../test-resources/lagoon-yaml/test1/lagoon.yml", + file: "test-resources/lagoon-yaml/test1/lagoon.yml", l: &YAML{}, p: &map[string]interface{}{}, }, @@ -90,7 +90,7 @@ func TestUnmarshalLagoonYAML(t *testing.T) { { name: "test-booleans-represented-as-booleans", args: args{ - file: "../../test-resources/lagoon-yaml/test2/lagoon.yml", + file: "test-resources/lagoon-yaml/test2/lagoon.yml", l: &YAML{}, p: &map[string]interface{}{}, }, @@ -158,7 +158,7 @@ func TestUnmarshalLagoonYAML(t *testing.T) { { name: "test-booleans-represented-as-strings-and-booleans", args: args{ - file: "../../test-resources/lagoon-yaml/test3/lagoon.yml", + file: "test-resources/lagoon-yaml/test3/lagoon.yml", l: &YAML{}, p: &map[string]interface{}{}, }, @@ -226,7 +226,7 @@ func TestUnmarshalLagoonYAML(t *testing.T) { { name: "test-backup-retention", args: args{ - file: "../../test-resources/lagoon-yaml/test4/lagoon.yml", + file: "test-resources/lagoon-yaml/test4/lagoon.yml", l: &YAML{}, p: &map[string]interface{}{}, }, diff --git a/test-resources/lagoon-yaml/test1/lagoon.yml b/internal/lagoon/test-resources/lagoon-yaml/test1/lagoon.yml similarity index 100% rename from test-resources/lagoon-yaml/test1/lagoon.yml rename to internal/lagoon/test-resources/lagoon-yaml/test1/lagoon.yml diff --git a/test-resources/lagoon-yaml/test2/lagoon.yml b/internal/lagoon/test-resources/lagoon-yaml/test2/lagoon.yml similarity index 100% rename from test-resources/lagoon-yaml/test2/lagoon.yml rename to internal/lagoon/test-resources/lagoon-yaml/test2/lagoon.yml diff --git a/test-resources/lagoon-yaml/test3/lagoon.yml b/internal/lagoon/test-resources/lagoon-yaml/test3/lagoon.yml similarity index 100% rename from test-resources/lagoon-yaml/test3/lagoon.yml rename to internal/lagoon/test-resources/lagoon-yaml/test3/lagoon.yml diff --git a/test-resources/lagoon-yaml/test4/lagoon.yml b/internal/lagoon/test-resources/lagoon-yaml/test4/lagoon.yml similarity index 100% rename from test-resources/lagoon-yaml/test4/lagoon.yml rename to internal/lagoon/test-resources/lagoon-yaml/test4/lagoon.yml diff --git a/test-resources/template-autogenerated/test17-results/nginx.yaml b/internal/testdata/complex/autogen-templates/ingress-1/nginx.yaml similarity index 100% rename from test-resources/template-autogenerated/test17-results/nginx.yaml rename to internal/testdata/complex/autogen-templates/ingress-1/nginx.yaml diff --git a/test-resources/template-autogenerated/test20-results/nginx-php.yaml b/internal/testdata/complex/autogen-templates/ingress-2/nginx-php.yaml similarity index 100% rename from test-resources/template-autogenerated/test20-results/nginx-php.yaml rename to internal/testdata/complex/autogen-templates/ingress-2/nginx-php.yaml diff --git a/test-resources/template-autogenerated/test21-results/nginx.yaml b/internal/testdata/complex/autogen-templates/ingress-3/nginx.yaml similarity index 100% rename from test-resources/template-autogenerated/test21-results/nginx.yaml rename to internal/testdata/complex/autogen-templates/ingress-3/nginx.yaml diff --git a/test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/complex/backup-templates/backup-1/k8up-lagoon-backup-schedule.yaml similarity index 100% rename from test-resources/template-backups/test1-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/complex/backup-templates/backup-1/k8up-lagoon-backup-schedule.yaml diff --git a/test-resources/template-backups/test1-results/prebackuppods.yaml b/internal/testdata/complex/backup-templates/backup-1/prebackuppods.yaml similarity index 96% rename from test-resources/template-backups/test1-results/prebackuppods.yaml rename to internal/testdata/complex/backup-templates/backup-1/prebackuppods.yaml index 7c739c5b..a1fed505 100644 --- a/test-resources/template-backups/test1-results/prebackuppods.yaml +++ b/internal/testdata/complex/backup-templates/backup-1/prebackuppods.yaml @@ -50,7 +50,7 @@ spec: configMapKeyRef: key: MARIADB_DATABASE name: lagoon-env - image: https://imagecache.example.com/uselagoon/database-tools:latest + image: imagecache.example.com/uselagoon/database-tools:latest imagePullPolicy: Always name: mariadb-prebackuppod resources: {} diff --git a/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/complex/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml similarity index 85% rename from test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/complex/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml index 266a1c40..b94d3460 100644 --- a/test-resources/template-backups/test6-results/k8up-lagoon-backup-schedule.yaml +++ b/internal/testdata/complex/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml @@ -1,5 +1,5 @@ --- -apiVersion: backup.appuio.ch/v1alpha1 +apiVersion: k8up.io/v1 kind: Schedule metadata: annotations: @@ -27,17 +27,16 @@ spec: bucket: baas-example-project backup: resources: {} - schedule: 3,18,33,48 5 * * 0 + schedule: 48 22 * * * check: resources: {} schedule: 48 5 * * 1 prune: resources: {} retention: - keepDaily: 10 - keepHourly: 10 - keepMonthly: 12 - keepWeekly: 16 + keepDaily: 7 + keepMonthly: 1 + keepWeekly: 6 schedule: 48 3 * * 0 resourceRequirementsTemplate: {} status: {} diff --git a/internal/testdata/complex/backup-templates/backup-2/prebackuppods.yaml b/internal/testdata/complex/backup-templates/backup-2/prebackuppods.yaml new file mode 100644 index 00000000..bae2689e --- /dev/null +++ b/internal/testdata/complex/backup-templates/backup-2/prebackuppods.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: k8up.io/v1 +kind: PreBackupPod +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mariadb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mariadb + lagoon.sh/service-type: mariadb-dbaas + prebackuppod: mariadb + name: mariadb-prebackuppod +spec: + backupCommand: | + /bin/sh -c "if [ ! -z $BACKUP_DB_READREPLICA_HOSTS ]; then BACKUP_DB_HOST=$(echo $BACKUP_DB_READREPLICA_HOSTS | cut -d ',' -f1); fi && dump=$(mktemp) && mysqldump --max-allowed-packet=500M --events --routines --quick --add-locks --no-autocommit --single-transaction --no-create-db --no-data --no-tablespaces -h $BACKUP_DB_HOST -u $BACKUP_DB_USERNAME -p$BACKUP_DB_PASSWORD $BACKUP_DB_DATABASE > $dump && mysqldump --max-allowed-packet=500M --events --routines --quick --add-locks --no-autocommit --single-transaction --no-create-db --ignore-table=$BACKUP_DB_DATABASE.watchdog --no-create-info --no-tablespaces --skip-triggers -h $BACKUP_DB_HOST -u $BACKUP_DB_USERNAME -p$BACKUP_DB_PASSWORD $BACKUP_DB_DATABASE >> $dump && cat $dump && rm $dump" + fileExtension: .mariadb.sql + pod: + metadata: {} + spec: + containers: + - args: + - sleep + - infinity + env: + - name: BACKUP_DB_HOST + valueFrom: + configMapKeyRef: + key: MARIADB_HOST + name: lagoon-env + - name: BACKUP_DB_USERNAME + valueFrom: + configMapKeyRef: + key: MARIADB_USERNAME + name: lagoon-env + - name: BACKUP_DB_PASSWORD + valueFrom: + configMapKeyRef: + key: MARIADB_PASSWORD + name: lagoon-env + - name: BACKUP_DB_DATABASE + valueFrom: + configMapKeyRef: + key: MARIADB_DATABASE + name: lagoon-env + image: imagecache.example.com/uselagoon/database-tools:latest + imagePullPolicy: Always + name: mariadb-prebackuppod + resources: {} diff --git a/test-resources/template-dbaas/test1-results/dbaas.yaml b/internal/testdata/complex/dbaas-templates/dbaas-1/dbaas.yaml similarity index 100% rename from test-resources/template-dbaas/test1-results/dbaas.yaml rename to internal/testdata/complex/dbaas-templates/dbaas-1/dbaas.yaml diff --git a/test-resources/template-autogenerated/test21/docker-compose.yml b/internal/testdata/complex/docker-compose.complex-1.yml similarity index 100% rename from test-resources/template-autogenerated/test21/docker-compose.yml rename to internal/testdata/complex/docker-compose.complex-1.yml diff --git a/test-resources/template-autogenerated/test17/docker-compose.yml b/internal/testdata/complex/docker-compose.small-1.yml similarity index 98% rename from test-resources/template-autogenerated/test17/docker-compose.yml rename to internal/testdata/complex/docker-compose.small-1.yml index e0fb34ec..a0427540 100644 --- a/test-resources/template-autogenerated/test17/docker-compose.yml +++ b/internal/testdata/complex/docker-compose.small-1.yml @@ -56,4 +56,4 @@ services: lagoon.type: mariadb-single networks: amazeeio-network: - external: true \ No newline at end of file + external: true diff --git a/internal/testdata/complex/docker-compose.small-2.yml b/internal/testdata/complex/docker-compose.small-2.yml new file mode 100644 index 00000000..03b85222 --- /dev/null +++ b/internal/testdata/complex/docker-compose.small-2.yml @@ -0,0 +1,70 @@ +version: '2' +services: + cli: + build: + context: . + dockerfile: builder.dockerfile + image: builder + labels: + lagoon.type: cli-persistent + lagoon.persistent: /app/web/sites/default/files/ + lagoon.persistent.name: nginx + environment: + LAGOON_PROJECT: ci-drupal + LAGOON_ROUTE: drupal9-mariadb.docker.amazee.io + volumes: + - ./web:/app/web:delegated + nginx: + networks: + - amazeeio-network + - default + build: + context: . + dockerfile: nginx.dockerfile + labels: + lagoon.type: nginx-php-persistent + lagoon.persistent: /app/web/sites/default/files/ + lagoon.persistent.size: 1Gi + lagoon.name: nginx + lagoon.deployment.servicetype: nginx + volumes: + - ./web:/app/web:delegated + depends_on: + - cli + expose: + - "8080" + environment: + LAGOON_LOCALDEV_URL: drupal9-mariadb.docker.amazee.io + php: + build: + context: . + dockerfile: php.dockerfile + labels: + lagoon.type: nginx-php-persistent + lagoon.persistent: /app/web/sites/default/files/ + lagoon.name: nginx + lagoon.deployment.servicetype: php + volumes: + - ./web:/app/web:delegated + depends_on: + - cli + + varnish: + image: uselagoon/varnish-5-drupal:latest + labels: + lagoon.type: varnish + lando.type: varnish-drupal + links: + - nginx # links varnish to the nginx in this docker-compose project, or it would try to connect to any nginx running in docker + environment: + VARNISH_BYPASS: "true" # by default we bypass varnish, change to 'false' or remove in order to tell varnish to cache if possible + + mariadb: + build: + context: . + dockerfile: mariadb.dockerfile + labels: + lagoon.type: mariadb-single +networks: + amazeeio-network: + external: true diff --git a/test-resources/template-autogenerated/test20/docker-compose.yml b/internal/testdata/complex/docker-compose.yml similarity index 84% rename from test-resources/template-autogenerated/test20/docker-compose.yml rename to internal/testdata/complex/docker-compose.yml index 946ec1b0..9ed4b99b 100644 --- a/test-resources/template-autogenerated/test20/docker-compose.yml +++ b/internal/testdata/complex/docker-compose.yml @@ -1,19 +1,15 @@ version: '2.3' -x-example-image-version: - &example-image-version ${EXAMPLE_IMAGE_VERSION:-4.x} +x-example-image-version: &example-image-version ${EXAMPLE_IMAGE_VERSION:-4.x} -x-project: - &project ${PROJECT_NAME:-mysite} +x-project: &project ${PROJECT_NAME:-mysite} -x-volumes: - &default-volumes +x-volumes: &default-volumes volumes: - .:/app:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - ./docroot/sites/default/files:/app/docroot/sites/default/files:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. -x-environment: - &default-environment +x-environment: &default-environment LAGOON_PROJECT: *project DRUPAL_HASH_SALT: fakehashsaltfakehashsaltfakehashsalt LAGOON_LOCALDEV_URL: ${LOCALDEV_URL:-http://mysite.docker.amazee.io} @@ -29,7 +25,6 @@ x-environment: REDIS_CACHE_PREFIX: "tide_" DB_ALIAS: ${DB_ALIAS:-bay.production} - services: cli: @@ -41,9 +36,10 @@ services: EXAMPLE_IMAGE_VERSION: *example-image-version image: *project environment: - << : *default-environment - << : *default-volumes - volumes_from: ### Local overrides to mount host SSH keys. Automatically removed in CI. + <<: *default-environment + <<: *default-volumes + volumes_from: + ### Local overrides to mount host SSH keys. Automatically removed in CI. - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. labels: lagoon.type: cli-persistent @@ -58,9 +54,9 @@ services: args: CLI_IMAGE: *project EXAMPLE_IMAGE_VERSION: *example-image-version - << : *default-volumes + <<: *default-volumes environment: - << : *default-environment + <<: *default-environment depends_on: - cli networks: @@ -81,8 +77,8 @@ services: CLI_IMAGE: *project EXAMPLE_IMAGE_VERSION: *example-image-version environment: - << : *default-environment - << : *default-volumes + <<: *default-environment + <<: *default-volumes depends_on: - cli labels: @@ -94,7 +90,7 @@ services: mariadb: image: amazeeio/mariadb-drupal environment: - << : *default-environment + <<: *default-environment ports: - "3306" # Find port on host with `ahoy info` or `docker-compose port mariadb 3306` labels: @@ -120,8 +116,8 @@ services: image: selenium/standalone-chrome:3.141.59-oxygen shm_size: '1gb' environment: - << : *default-environment - << : *default-volumes + <<: *default-environment + <<: *default-volumes depends_on: - cli labels: @@ -130,17 +126,16 @@ services: clamav: image: clamav/clamav:${EXAMPLE_IMAGE_VERSION:-4.x} environment: - << : *default-environment + <<: *default-environment ports: - "3310" labels: lagoon.type: none - networks: amazeeio-network: external: true volumes: app: {} - files: {} \ No newline at end of file + files: {} diff --git a/test-resources/template-ingress/test11-results/content.example.com.yaml b/internal/testdata/complex/ingress-templates/ingress-1/content.example.com.yaml similarity index 100% rename from test-resources/template-ingress/test11-results/content.example.com.yaml rename to internal/testdata/complex/ingress-templates/ingress-1/content.example.com.yaml diff --git a/test-resources/template-autogenerated/test21/lagoon.yml b/internal/testdata/complex/lagoon.complex-1.yml similarity index 87% rename from test-resources/template-autogenerated/test21/lagoon.yml rename to internal/testdata/complex/lagoon.complex-1.yml index 0e1c70d5..56c60cfc 100644 --- a/test-resources/template-autogenerated/test21/lagoon.yml +++ b/internal/testdata/complex/lagoon.complex-1.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test21/docker-compose.yml +docker-compose-yaml: ../internal/testdata/complex/docker-compose.complex-1.yml tasks: diff --git a/test-resources/identify-ingress/test18/lagoon.yml b/internal/testdata/complex/lagoon.complex-2.yml similarity index 76% rename from test-resources/identify-ingress/test18/lagoon.yml rename to internal/testdata/complex/lagoon.complex-2.yml index e0704f17..4b6d3d74 100644 --- a/test-resources/identify-ingress/test18/lagoon.yml +++ b/internal/testdata/complex/lagoon.complex-2.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test18/docker-compose.yml +docker-compose-yaml: ../internal/testdata/complex/docker-compose.complex-1.yml environments: main: diff --git a/test-resources/template-autogenerated/test17/lagoon.yml b/internal/testdata/complex/lagoon.small-2.yml similarity index 94% rename from test-resources/template-autogenerated/test17/lagoon.yml rename to internal/testdata/complex/lagoon.small-2.yml index bbe6cb7c..9c03e6da 100644 --- a/test-resources/template-autogenerated/test17/lagoon.yml +++ b/internal/testdata/complex/lagoon.small-2.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test17/docker-compose.yml +docker-compose-yaml: ../internal/testdata/complex/docker-compose.small-2.yml ssh: lagoon-core-ssh.lagoon.svc:2020 api: http://lagoon-core-api.lagoon.svc:80/graphql diff --git a/internal/testdata/complex/lagoon.small.yml b/internal/testdata/complex/lagoon.small.yml new file mode 100644 index 00000000..6aa5e31e --- /dev/null +++ b/internal/testdata/complex/lagoon.small.yml @@ -0,0 +1,59 @@ +docker-compose-yaml: ../internal/testdata/complex/docker-compose.small-1.yml + +ssh: lagoon-core-ssh.lagoon.svc:2020 +api: http://lagoon-core-api.lagoon.svc:80/graphql + +environment_variables: + git_sha: 'true' + +tasks: + post-rollout: + - run: + name: env variables + command: env + service: cli + - run: + name: IF no Drupal installed, install Drupal + command: | + cd web + if tables=$(drush sqlq "show tables like \"node\";") && [ -z "$tables" ]; then + # no drupal installed, we install drupal from an db dump + zcat ../drupal.sql.gz | $(drush sql-connect) + fi + # set the sitename to the current SHA and BRANCH + drush -y cset system.site name "LAGOON_GIT_SHA=$LAGOON_GIT_SHA LAGOON_GIT_BRANCH=$LAGOON_GIT_BRANCH" + service: cli + shell: bash + - run: + name: drush cr + command: cd web && drush -y cr + service: cli + +environments: + master: + routes: + - nginx: + - "domain.com": + tls-acme: 'true' + insecure: Allow + - www.domain.com + + cronjobs: + - name: drush cron + schedule: "1 * * * *" + command: drush cron + service: cli + + drupal9-php80-mariadb-dbaas: + cronjobs: + - name: drush cron + schedule: "1 * * * *" + command: drush cron + service: cli + + drupal9-php80-mariadb-single: + cronjobs: + - name: drush cron + schedule: "1 * * * *" + command: drush cron + service: cli \ No newline at end of file diff --git a/test-resources/template-ingress/test11/lagoon.yml b/internal/testdata/complex/lagoon.yml similarity index 91% rename from test-resources/template-ingress/test11/lagoon.yml rename to internal/testdata/complex/lagoon.yml index 84ba6edd..8c6fbbe0 100644 --- a/test-resources/template-ingress/test11/lagoon.yml +++ b/internal/testdata/complex/lagoon.yml @@ -1,5 +1,5 @@ --- -docker-compose-yaml: ../test-resources/template-ingress/test11/docker-compose.yml +docker-compose-yaml: ../internal/testdata/complex/docker-compose.yml project: content-example-com diff --git a/test-resources/template-autogenerated/test15-results/nginx.yaml b/internal/testdata/nginxphp/autogen-templates/ingress-1/nginx.yaml similarity index 100% rename from test-resources/template-autogenerated/test15-results/nginx.yaml rename to internal/testdata/nginxphp/autogen-templates/ingress-1/nginx.yaml diff --git a/test-resources/template-autogenerated/test16-results/nginx.yaml b/internal/testdata/nginxphp/autogen-templates/ingress-2/nginx.yaml similarity index 100% rename from test-resources/template-autogenerated/test16-results/nginx.yaml rename to internal/testdata/nginxphp/autogen-templates/ingress-2/nginx.yaml diff --git a/test-resources/template-autogenerated/test22-results/nginx-php.yaml b/internal/testdata/nginxphp/autogen-templates/ingress-3/nginx-php.yaml similarity index 100% rename from test-resources/template-autogenerated/test22-results/nginx-php.yaml rename to internal/testdata/nginxphp/autogen-templates/ingress-3/nginx-php.yaml diff --git a/test-resources/template-autogenerated/test22/docker-compose.yml b/internal/testdata/nginxphp/docker-compose.nginx-1.yml similarity index 100% rename from test-resources/template-autogenerated/test22/docker-compose.yml rename to internal/testdata/nginxphp/docker-compose.nginx-1.yml diff --git a/test-resources/template-autogenerated/test16/docker-compose.yml b/internal/testdata/nginxphp/docker-compose.servicename.yml similarity index 100% rename from test-resources/template-autogenerated/test16/docker-compose.yml rename to internal/testdata/nginxphp/docker-compose.servicename.yml diff --git a/test-resources/template-autogenerated/test15/docker-compose.yml b/internal/testdata/nginxphp/docker-compose.yml similarity index 100% rename from test-resources/template-autogenerated/test15/docker-compose.yml rename to internal/testdata/nginxphp/docker-compose.yml diff --git a/test-resources/template-autogenerated/test2/lagoon.yml b/internal/testdata/nginxphp/lagoon.nginx-1.yml similarity index 70% rename from test-resources/template-autogenerated/test2/lagoon.yml rename to internal/testdata/nginxphp/lagoon.nginx-1.yml index 50c4efe5..26364829 100644 --- a/test-resources/template-autogenerated/test2/lagoon.yml +++ b/internal/testdata/nginxphp/lagoon.nginx-1.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test2/docker-compose.yml +docker-compose-yaml: ../internal/testdata/nginxphp/docker-compose.nginx-1.yml routes: autogenerate: diff --git a/test-resources/template-dbaas/test1/lagoon.yml b/internal/testdata/nginxphp/lagoon.nginx-2.yml similarity index 59% rename from test-resources/template-dbaas/test1/lagoon.yml rename to internal/testdata/nginxphp/lagoon.nginx-2.yml index 0282e0c4..e6b20a46 100644 --- a/test-resources/template-dbaas/test1/lagoon.yml +++ b/internal/testdata/nginxphp/lagoon.nginx-2.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-dbaas/test1/docker-compose.yml +docker-compose-yaml: ../internal/testdata/nginxphp/docker-compose.nginx-1.yml environment_variables: git_sha: "true" diff --git a/test-resources/template-autogenerated/test8/lagoon.yml b/internal/testdata/nginxphp/lagoon.servicename.yml similarity index 62% rename from test-resources/template-autogenerated/test8/lagoon.yml rename to internal/testdata/nginxphp/lagoon.servicename.yml index c3e29962..a9a9fb75 100644 --- a/test-resources/template-autogenerated/test8/lagoon.yml +++ b/internal/testdata/nginxphp/lagoon.servicename.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test8/docker-compose.yml +docker-compose-yaml: ../internal/testdata/nginxphp/docker-compose.servicename.yml routes: autogenerate: @@ -11,5 +11,5 @@ environment_variables: environments: main: routes: - - node: + - nginx: - example.com diff --git a/test-resources/template-autogenerated/test1/lagoon.yml b/internal/testdata/nginxphp/lagoon.yml similarity index 62% rename from test-resources/template-autogenerated/test1/lagoon.yml rename to internal/testdata/nginxphp/lagoon.yml index 9be28e6c..a2006fe2 100644 --- a/test-resources/template-autogenerated/test1/lagoon.yml +++ b/internal/testdata/nginxphp/lagoon.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test1/docker-compose.yml +docker-compose-yaml: ../internal/testdata/nginxphp/docker-compose.yml routes: autogenerate: @@ -11,5 +11,5 @@ environment_variables: environments: main: routes: - - node: + - nginx: - example.com diff --git a/test-resources/template-autogenerated/test1-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-1/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test1-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-1/node.yaml diff --git a/test-resources/template-autogenerated/test12-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-10/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test12-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-10/node.yaml diff --git a/test-resources/template-autogenerated/test13-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-11/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test13-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-11/node.yaml diff --git a/test-resources/template-autogenerated/test18-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-12/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test18-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-12/node.yaml diff --git a/test-resources/template-autogenerated/test19-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-13/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test19-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-13/node.yaml diff --git a/test-resources/template-autogenerated/test23-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-14/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test23-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-14/node.yaml diff --git a/test-resources/template-autogenerated/test2-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-2/node.yaml similarity index 84% rename from test-resources/template-autogenerated/test2-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-2/node.yaml index c0c6cd9e..aee8b569 100644 --- a/test-resources/template-autogenerated/test2-results/node.yaml +++ b/internal/testdata/node/autogen-templates/ingress-2/node.yaml @@ -10,7 +10,6 @@ metadata: lagoon.sh/prHeadBranch: main lagoon.sh/prNumber: "123" lagoon.sh/version: v2.7.x - monitor.stakater.com/enabled: "false" nginx.ingress.kubernetes.io/server-snippet: | add_header X-Robots-Tag "noindex, nofollow"; nginx.ingress.kubernetes.io/ssl-redirect: "true" @@ -22,15 +21,15 @@ metadata: helm.sh/chart: autogenerated-ingress-0.1.0 lagoon.sh/autogenerated: "true" lagoon.sh/buildType: pullrequest - lagoon.sh/environment: main - lagoon.sh/environmentType: production + lagoon.sh/environment: pr-123 + lagoon.sh/environmentType: development lagoon.sh/project: example-project lagoon.sh/service: node lagoon.sh/service-type: node name: node spec: rules: - - host: node-example-project-main.example.com + - host: node-example-project-pr-123.example.com http: paths: - backend: @@ -42,7 +41,7 @@ spec: pathType: Prefix tls: - hosts: - - node-example-project-main.example.com + - node-example-project-pr-123.example.com secretName: node-tls status: loadBalancer: {} diff --git a/test-resources/template-autogenerated/test4-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-3/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test4-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-3/node.yaml diff --git a/test-resources/template-autogenerated/test5-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-4/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test5-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-4/node.yaml diff --git a/test-resources/template-autogenerated/test24-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-5/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test24-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-5/node.yaml diff --git a/test-resources/template-autogenerated/test8-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-6/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test8-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-6/node.yaml diff --git a/test-resources/template-autogenerated/test9-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-7/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test9-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-7/node.yaml diff --git a/test-resources/template-autogenerated/test10-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-8/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test10-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-8/node.yaml diff --git a/test-resources/template-autogenerated/test11-results/node.yaml b/internal/testdata/node/autogen-templates/ingress-9/node.yaml similarity index 100% rename from test-resources/template-autogenerated/test11-results/node.yaml rename to internal/testdata/node/autogen-templates/ingress-9/node.yaml diff --git a/test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-1/k8up-lagoon-backup-schedule.yaml similarity index 100% rename from test-resources/template-backups/test2-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/node/backup-templates/backup-1/k8up-lagoon-backup-schedule.yaml diff --git a/internal/testdata/node/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml new file mode 100644 index 00000000..ee99ff5b --- /dev/null +++ b/internal/testdata/node/backup-templates/backup-2/k8up-lagoon-backup-schedule.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: backup.appuio.ch/v1alpha1 +kind: Schedule +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: k8up-lagoon-backup-schedule + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: k8up-schedule + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: development + lagoon.sh/project: example-project + lagoon.sh/service: k8up-lagoon-backup-schedule + lagoon.sh/service-type: k8up-schedule + lagoon.sh/template: k8up-schedule-0.1.0 + name: k8up-lagoon-backup-schedule +spec: + backend: + repoPasswordSecretRef: + key: repo-pw + name: baas-repo-pw + s3: + bucket: baas-example-project + backup: + resources: {} + schedule: 48 22 * * * + check: + resources: {} + schedule: 48 5 * * 1 + prune: + resources: {} + retention: + keepDaily: 7 + keepMonthly: 1 + keepWeekly: 6 + schedule: 48 3 * * 0 + resourceRequirementsTemplate: {} +status: {} diff --git a/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-3/k8up-lagoon-backup-schedule.yaml similarity index 94% rename from test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/node/backup-templates/backup-3/k8up-lagoon-backup-schedule.yaml index a15cdf97..9868b515 100644 --- a/test-resources/template-backups/test4-results/k8up-lagoon-backup-schedule.yaml +++ b/internal/testdata/node/backup-templates/backup-3/k8up-lagoon-backup-schedule.yaml @@ -13,7 +13,7 @@ metadata: app.kubernetes.io/managed-by: build-deploy-tool app.kubernetes.io/name: k8up-schedule lagoon.sh/buildType: pullrequest - lagoon.sh/environment: main + lagoon.sh/environment: pr-123 lagoon.sh/environmentType: development lagoon.sh/project: example-project lagoon.sh/service: k8up-lagoon-backup-schedule @@ -38,14 +38,14 @@ spec: schedule: 3,33 12 * * * check: resources: {} - schedule: 48 5 * * 1 + schedule: 17 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 48 3 * * 0 + schedule: 17 4 * * 0 resourceRequirementsTemplate: {} status: {} --- diff --git a/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-4/k8up-lagoon-backup-schedule.yaml similarity index 93% rename from test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/node/backup-templates/backup-4/k8up-lagoon-backup-schedule.yaml index caa3a96f..ffbde593 100644 --- a/test-resources/template-backups/test5-results/k8up-lagoon-backup-schedule.yaml +++ b/internal/testdata/node/backup-templates/backup-4/k8up-lagoon-backup-schedule.yaml @@ -13,7 +13,7 @@ metadata: app.kubernetes.io/managed-by: build-deploy-tool app.kubernetes.io/name: k8up-schedule lagoon.sh/buildType: pullrequest - lagoon.sh/environment: main + lagoon.sh/environment: pr-123 lagoon.sh/environmentType: development lagoon.sh/project: example-project lagoon.sh/service: k8up-lagoon-backup-schedule @@ -32,14 +32,14 @@ spec: schedule: 3,33 12 * * * check: resources: {} - schedule: 48 5 * * 1 + schedule: 17 7 * * 1 prune: resources: {} retention: keepDaily: 7 keepMonthly: 1 keepWeekly: 6 - schedule: 48 3 * * 0 + schedule: 17 4 * * 0 resourceRequirementsTemplate: {} status: {} --- diff --git a/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-5/k8up-lagoon-backup-schedule.yaml similarity index 92% rename from test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/node/backup-templates/backup-5/k8up-lagoon-backup-schedule.yaml index e26c30ae..40b7fb29 100644 --- a/test-resources/template-backups/test3-results/k8up-lagoon-backup-schedule.yaml +++ b/internal/testdata/node/backup-templates/backup-5/k8up-lagoon-backup-schedule.yaml @@ -34,10 +34,9 @@ spec: prune: resources: {} retention: - keepDaily: 10 - keepHourly: 10 - keepMonthly: 10 - keepWeekly: 10 + keepDaily: 7 + keepMonthly: 1 + keepWeekly: 6 schedule: 48 3 * * 0 resourceRequirementsTemplate: {} status: {} diff --git a/test-resources/template-backups/test7-results/k8up-lagoon-backup-schedule.yaml b/internal/testdata/node/backup-templates/backup-6/k8up-lagoon-backup-schedule.yaml similarity index 100% rename from test-resources/template-backups/test7-results/k8up-lagoon-backup-schedule.yaml rename to internal/testdata/node/backup-templates/backup-6/k8up-lagoon-backup-schedule.yaml diff --git a/test-resources/template-autogenerated/test6/docker-compose.yml b/internal/testdata/node/docker-compose.autogen-1.yml similarity index 95% rename from test-resources/template-autogenerated/test6/docker-compose.yml rename to internal/testdata/node/docker-compose.autogen-1.yml index 943c4351..1d1311eb 100644 --- a/test-resources/template-autogenerated/test6/docker-compose.yml +++ b/internal/testdata/node/docker-compose.autogen-1.yml @@ -18,4 +18,4 @@ services: networks: amazeeio-network: - external: true \ No newline at end of file + external: true diff --git a/test-resources/template-autogenerated/test7/docker-compose.yml b/internal/testdata/node/docker-compose.autogen-2.yml similarity index 95% rename from test-resources/template-autogenerated/test7/docker-compose.yml rename to internal/testdata/node/docker-compose.autogen-2.yml index 1ca091de..4d4abe45 100644 --- a/test-resources/template-autogenerated/test7/docker-compose.yml +++ b/internal/testdata/node/docker-compose.autogen-2.yml @@ -18,4 +18,4 @@ services: networks: amazeeio-network: - external: true \ No newline at end of file + external: true diff --git a/test-resources/template-autogenerated/test19/docker-compose.yml b/internal/testdata/node/docker-compose.autogen-3.yml similarity index 100% rename from test-resources/template-autogenerated/test19/docker-compose.yml rename to internal/testdata/node/docker-compose.autogen-3.yml diff --git a/test-resources/template-autogenerated/test13/docker-compose.yml b/internal/testdata/node/docker-compose.none.yml similarity index 94% rename from test-resources/template-autogenerated/test13/docker-compose.yml rename to internal/testdata/node/docker-compose.none.yml index a6462abd..edaf9cd4 100644 --- a/test-resources/template-autogenerated/test13/docker-compose.yml +++ b/internal/testdata/node/docker-compose.none.yml @@ -17,4 +17,4 @@ services: networks: amazeeio-network: - external: true \ No newline at end of file + external: true diff --git a/test-resources/identify-feature/alltest/docker-compose.yml b/internal/testdata/node/docker-compose.yml similarity index 100% rename from test-resources/identify-feature/alltest/docker-compose.yml rename to internal/testdata/node/docker-compose.yml diff --git a/test-resources/template-ingress/test1-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-1/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test1-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-1/example.com.yaml diff --git a/test-resources/template-ingress/test10-results/main2.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-10/main-sb.example.com.yaml similarity index 77% rename from test-resources/template-ingress/test10-results/main2.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-10/main-sb.example.com.yaml index 53517c65..96176579 100644 --- a/test-resources/template-ingress/test10-results/main2.example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-10/main-sb.example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main2 + lagoon.sh/branch: main-sb lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "false" monitor.stakater.com/overridePath: / @@ -14,21 +14,21 @@ metadata: creationTimestamp: null labels: activestandby.lagoon.sh/migrate: "false" - app.kubernetes.io/instance: main2.example.com + app.kubernetes.io/instance: main-sb.example.com app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: custom-ingress helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main2 + lagoon.sh/environment: main-sb lagoon.sh/environmentType: production lagoon.sh/project: example-project - lagoon.sh/service: main2.example.com + lagoon.sh/service: main-sb.example.com lagoon.sh/service-type: custom-ingress - name: main2.example.com + name: main-sb.example.com spec: rules: - - host: main2.example.com + - host: main-sb.example.com http: paths: - backend: @@ -40,7 +40,7 @@ spec: pathType: Prefix tls: - hosts: - - main2.example.com - secretName: main2.example.com-tls + - main-sb.example.com + secretName: main-sb.example.com-tls status: loadBalancer: {} diff --git a/test-resources/template-ingress/test10-results/standby.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-10/standby.example.com.yaml similarity index 95% rename from test-resources/template-ingress/test10-results/standby.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-10/standby.example.com.yaml index 0fa3ec56..df53f3ec 100644 --- a/test-resources/template-ingress/test10-results/standby.example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-10/standby.example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main2 + lagoon.sh/branch: main-sb lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -23,7 +23,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main2 + lagoon.sh/environment: main-sb lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test12-results/test1.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-11/test1.example.com.yaml similarity index 94% rename from test-resources/template-ingress/test12-results/test1.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-11/test1.example.com.yaml index af1c4ab8..1fad72ed 100644 --- a/test-resources/template-ingress/test12-results/test1.example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-11/test1.example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "false" - lagoon.sh/branch: main + lagoon.sh/branch: noyamlroutes lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: /bypass-cache @@ -23,7 +23,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: noyamlroutes lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test13-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-12/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test13-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-12/example.com.yaml diff --git a/internal/testdata/node/ingress-templates/ingress-13/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-13/example.com.yaml new file mode 100644 index 00000000..d0547a85 --- /dev/null +++ b/internal/testdata/node/ingress-templates/ingress-13/example.com.yaml @@ -0,0 +1,52 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + acme.cert-manager.io/http01-ingress-class: custom-ingress + fastly.amazee.io/watch: "false" + ingress.kubernetes.io/ssl-redirect: "true" + kubernetes.io/tls-acme: "true" + lagoon.sh/branch: ingressclass + lagoon.sh/version: v2.7.x + monitor.stakater.com/enabled: "true" + monitor.stakater.com/overridePath: / + nginx.ingress.kubernetes.io/ssl-redirect: "true" + uptimerobot.monitor.stakater.com/alert-contacts: alertcontact + uptimerobot.monitor.stakater.com/interval: "60" + uptimerobot.monitor.stakater.com/status-pages: statuspageid + creationTimestamp: null + labels: + activestandby.lagoon.sh/migrate: "false" + app.kubernetes.io/instance: example.com + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: custom-ingress + helm.sh/chart: custom-ingress-0.1.0 + lagoon.sh/autogenerated: "false" + lagoon.sh/buildType: branch + lagoon.sh/environment: ingressclass + lagoon.sh/environmentType: production + lagoon.sh/primaryIngress: "true" + lagoon.sh/project: example-project + lagoon.sh/service: example.com + lagoon.sh/service-type: custom-ingress + name: example.com +spec: + ingressClassName: custom-ingress + rules: + - host: example.com + http: + paths: + - backend: + service: + name: node + port: + name: http + path: / + pathType: Prefix + tls: + - hosts: + - example.com + secretName: example.com-tls +status: + loadBalancer: {} diff --git a/test-resources/template-ingress/test14-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-14/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test14-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-14/example.com.yaml diff --git a/test-resources/template-ingress/test15-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-15/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test15-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-15/example.com.yaml diff --git a/test-resources/template-ingress/test16-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-16/example.com.yaml similarity index 96% rename from test-resources/template-ingress/test16-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-16/example.com.yaml index 7424cf1e..3b5470ae 100644 --- a/test-resources/template-ingress/test16-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-16/example.com.yaml @@ -8,7 +8,7 @@ metadata: fastly.amazee.io/watch: "true" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: hsts lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -27,7 +27,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: hsts lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test17-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-17/example.com.yaml similarity index 96% rename from test-resources/template-ingress/test17-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-17/example.com.yaml index f21534da..991f5ac8 100644 --- a/test-resources/template-ingress/test17-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-17/example.com.yaml @@ -8,7 +8,7 @@ metadata: fastly.amazee.io/watch: "true" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: hsts2 lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -27,7 +27,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: hsts2 lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test7-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-18/example.com.yaml similarity index 95% rename from test-resources/template-ingress/test7-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-18/example.com.yaml index 457648e1..371745c0 100644 --- a/test-resources/template-ingress/test7-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-18/example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: tworoutes lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -23,7 +23,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: tworoutes lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test18-results/www.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-18/www.example.com.yaml similarity index 94% rename from test-resources/template-ingress/test18-results/www.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-18/www.example.com.yaml index 31b9beb3..7d778633 100644 --- a/test-resources/template-ingress/test18-results/www.example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-18/www.example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: tworoutes lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "false" monitor.stakater.com/overridePath: / @@ -20,7 +20,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: tworoutes lagoon.sh/environmentType: production lagoon.sh/project: example-project lagoon.sh/service: www.example.com diff --git a/test-resources/template-ingress/test19-results/performance.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-19/performance.example.com.yaml similarity index 100% rename from test-resources/template-ingress/test19-results/performance.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-19/performance.example.com.yaml diff --git a/test-resources/template-ingress/test2-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-2/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test2-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-2/example.com.yaml diff --git a/test-resources/template-ingress/test20-results/performance.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-20/performance.example.com.yaml similarity index 100% rename from test-resources/template-ingress/test20-results/performance.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-20/performance.example.com.yaml diff --git a/test-resources/template-ingress/test21-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-21/example.com.yaml similarity index 95% rename from test-resources/template-ingress/test21-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-21/example.com.yaml index ffa20d7e..e681d12d 100644 --- a/test-resources/template-ingress/test21-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-21/example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: alternativename lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -23,7 +23,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: alternativename lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test22-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-22/example.com.yaml similarity index 94% rename from test-resources/template-ingress/test22-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-22/example.com.yaml index 28bb7e42..d773b30e 100644 --- a/test-resources/template-ingress/test22-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-22/example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "false" - lagoon.sh/branch: main + lagoon.sh/branch: wildcard lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "false" monitor.stakater.com/overridePath: / @@ -20,7 +20,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: wildcard lagoon.sh/environmentType: production lagoon.sh/project: example-project lagoon.sh/service: wildcard-example.com diff --git a/test-resources/template-ingress/test3-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-3/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test3-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-3/example.com.yaml diff --git a/test-resources/template-ingress/test18-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-4/example.com.yaml similarity index 100% rename from test-resources/template-ingress/test18-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-4/example.com.yaml diff --git a/test-resources/template-ingress/test5-results/multiproject1.com.yaml b/internal/testdata/node/ingress-templates/ingress-5/multiproject1.com.yaml similarity index 100% rename from test-resources/template-ingress/test5-results/multiproject1.com.yaml rename to internal/testdata/node/ingress-templates/ingress-5/multiproject1.com.yaml diff --git a/test-resources/template-ingress/test6-results/multiproject2.com.yaml b/internal/testdata/node/ingress-templates/ingress-6/multiproject2.com.yaml similarity index 100% rename from test-resources/template-ingress/test6-results/multiproject2.com.yaml rename to internal/testdata/node/ingress-templates/ingress-6/multiproject2.com.yaml diff --git a/test-resources/template-ingress/test4-results/example.com.yaml b/internal/testdata/node/ingress-templates/ingress-7/example.com.yaml similarity index 95% rename from test-resources/template-ingress/test4-results/example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-7/example.com.yaml index 457648e1..371745c0 100644 --- a/test-resources/template-ingress/test4-results/example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-7/example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: tworoutes lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "true" monitor.stakater.com/overridePath: / @@ -23,7 +23,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: tworoutes lagoon.sh/environmentType: production lagoon.sh/primaryIngress: "true" lagoon.sh/project: example-project diff --git a/test-resources/template-ingress/test7-results/www.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-7/www.example.com.yaml similarity index 94% rename from test-resources/template-ingress/test7-results/www.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-7/www.example.com.yaml index 31b9beb3..7d778633 100644 --- a/test-resources/template-ingress/test7-results/www.example.com.yaml +++ b/internal/testdata/node/ingress-templates/ingress-7/www.example.com.yaml @@ -6,7 +6,7 @@ metadata: fastly.amazee.io/watch: "false" ingress.kubernetes.io/ssl-redirect: "true" kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main + lagoon.sh/branch: tworoutes lagoon.sh/version: v2.7.x monitor.stakater.com/enabled: "false" monitor.stakater.com/overridePath: / @@ -20,7 +20,7 @@ metadata: helm.sh/chart: custom-ingress-0.1.0 lagoon.sh/autogenerated: "false" lagoon.sh/buildType: branch - lagoon.sh/environment: main + lagoon.sh/environment: tworoutes lagoon.sh/environmentType: production lagoon.sh/project: example-project lagoon.sh/service: www.example.com diff --git a/test-resources/template-ingress/test8-results/customdomain-will-be-main-domain.com.yaml b/internal/testdata/node/ingress-templates/ingress-8/customdomain-will-be-main-domain.com.yaml similarity index 100% rename from test-resources/template-ingress/test8-results/customdomain-will-be-main-domain.com.yaml rename to internal/testdata/node/ingress-templates/ingress-8/customdomain-will-be-main-domain.com.yaml diff --git a/test-resources/template-ingress/test8-results/customdomain-will-be-not-be-main-domain.com.yaml b/internal/testdata/node/ingress-templates/ingress-8/customdomain-will-be-not-be-main-domain.com.yaml similarity index 100% rename from test-resources/template-ingress/test8-results/customdomain-will-be-not-be-main-domain.com.yaml rename to internal/testdata/node/ingress-templates/ingress-8/customdomain-will-be-not-be-main-domain.com.yaml diff --git a/test-resources/template-ingress/test9-results/active.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-9/active.example.com.yaml similarity index 100% rename from test-resources/template-ingress/test9-results/active.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-9/active.example.com.yaml diff --git a/test-resources/template-ingress/test9-results/main.example.com.yaml b/internal/testdata/node/ingress-templates/ingress-9/main.example.com.yaml similarity index 100% rename from test-resources/template-ingress/test9-results/main.example.com.yaml rename to internal/testdata/node/ingress-templates/ingress-9/main.example.com.yaml diff --git a/test-resources/template-ingress/test9/lagoon.yml b/internal/testdata/node/lagoon.activestandby.yml similarity index 71% rename from test-resources/template-ingress/test9/lagoon.yml rename to internal/testdata/node/lagoon.activestandby.yml index 62de5500..989a014e 100644 --- a/test-resources/template-ingress/test9/lagoon.yml +++ b/internal/testdata/node/lagoon.activestandby.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-ingress/test9/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml environment_variables: git_sha: "true" @@ -18,7 +18,7 @@ environments: routes: - node: - main.example.com - main2: + main-sb: routes: - node: - - main2.example.com + - main-sb.example.com diff --git a/test-resources/template-autogenerated/test22/lagoon.yml b/internal/testdata/node/lagoon.autogen-1.yml similarity index 70% rename from test-resources/template-autogenerated/test22/lagoon.yml rename to internal/testdata/node/lagoon.autogen-1.yml index c2c577f6..59e41789 100644 --- a/test-resources/template-autogenerated/test22/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-1.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test22/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test3/lagoon.yml b/internal/testdata/node/lagoon.autogen-2.yml similarity index 70% rename from test-resources/template-autogenerated/test3/lagoon.yml rename to internal/testdata/node/lagoon.autogen-2.yml index 70b0757b..373e85f4 100644 --- a/test-resources/template-autogenerated/test3/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-2.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test3/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test4/lagoon.yml b/internal/testdata/node/lagoon.autogen-3.yml similarity index 67% rename from test-resources/template-autogenerated/test4/lagoon.yml rename to internal/testdata/node/lagoon.autogen-3.yml index 10b99906..d57c4d1b 100644 --- a/test-resources/template-autogenerated/test4/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-3.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test4/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.autogen-1.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test7/lagoon.yml b/internal/testdata/node/lagoon.autogen-4.yml similarity index 70% rename from test-resources/template-autogenerated/test7/lagoon.yml rename to internal/testdata/node/lagoon.autogen-4.yml index fc193720..4a17f112 100644 --- a/test-resources/template-autogenerated/test7/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-4.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test7/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.autogen-2.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test12/lagoon.yml b/internal/testdata/node/lagoon.autogen-5.yml similarity index 64% rename from test-resources/template-autogenerated/test12/lagoon.yml rename to internal/testdata/node/lagoon.autogen-5.yml index 3f971f1c..a2d65bec 100644 --- a/test-resources/template-autogenerated/test12/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-5.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test12/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test5/lagoon.yml b/internal/testdata/node/lagoon.autogen-6.yml similarity index 67% rename from test-resources/template-autogenerated/test5/lagoon.yml rename to internal/testdata/node/lagoon.autogen-6.yml index 1795ce66..874130b3 100644 --- a/test-resources/template-autogenerated/test5/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-6.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test5/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.none.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test18/lagoon.yml b/internal/testdata/node/lagoon.autogen-7.yml similarity index 69% rename from test-resources/template-autogenerated/test18/lagoon.yml rename to internal/testdata/node/lagoon.autogen-7.yml index f0a68b2d..0da39080 100644 --- a/test-resources/template-autogenerated/test18/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-7.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test18/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test19/lagoon.yml b/internal/testdata/node/lagoon.autogen-8.yml similarity index 64% rename from test-resources/template-autogenerated/test19/lagoon.yml rename to internal/testdata/node/lagoon.autogen-8.yml index 554a603f..e03471a0 100644 --- a/test-resources/template-autogenerated/test19/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-8.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test19/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.autogen-3.yml routes: autogenerate: diff --git a/test-resources/template-autogenerated/test24/lagoon.yml b/internal/testdata/node/lagoon.autogen-9.yml similarity index 67% rename from test-resources/template-autogenerated/test24/lagoon.yml rename to internal/testdata/node/lagoon.autogen-9.yml index c0b30d81..0fe4f520 100644 --- a/test-resources/template-autogenerated/test24/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-9.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test24/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: diff --git a/test-resources/identify-ingress/test12/lagoon.yml b/internal/testdata/node/lagoon.autogen-prefixes-1.yml similarity index 62% rename from test-resources/identify-ingress/test12/lagoon.yml rename to internal/testdata/node/lagoon.autogen-prefixes-1.yml index 8c6fa6a9..1acdb5e3 100644 --- a/test-resources/identify-ingress/test12/lagoon.yml +++ b/internal/testdata/node/lagoon.autogen-prefixes-1.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test12/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml routes: autogenerate: @@ -15,4 +15,4 @@ environments: main: routes: - node: - - example.com + - example.com \ No newline at end of file diff --git a/test-resources/template-ingress/test20/lagoon.yml b/internal/testdata/node/lagoon.polysite-pr.yml similarity index 83% rename from test-resources/template-ingress/test20/lagoon.yml rename to internal/testdata/node/lagoon.polysite-pr.yml index 9f9a3b18..f1689a8f 100644 --- a/test-resources/template-ingress/test20/lagoon.yml +++ b/internal/testdata/node/lagoon.polysite-pr.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/template-ingress/test20/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml environment_variables: git_sha: 'true' @@ -32,4 +32,4 @@ example-project2: pr-4841: routes: - nginx: - - performance2.example.com + - performance2.example.com \ No newline at end of file diff --git a/test-resources/identify-ingress/test6/lagoon.yml b/internal/testdata/node/lagoon.polysite.yml similarity index 56% rename from test-resources/identify-ingress/test6/lagoon.yml rename to internal/testdata/node/lagoon.polysite.yml index df59c458..de37de5e 100644 --- a/test-resources/identify-ingress/test6/lagoon.yml +++ b/internal/testdata/node/lagoon.polysite.yml @@ -1,4 +1,4 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test6/docker-compose.yml +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml environment_variables: git_sha: "true" @@ -15,3 +15,11 @@ multiproject2: routes: - node: - multiproject2.com + +multiproject3: + environments: + autogendisabled: + autogenerateRoutes: false + routes: + - node: + - example.com \ No newline at end of file diff --git a/internal/testdata/node/lagoon.yml b/internal/testdata/node/lagoon.yml new file mode 100644 index 00000000..8acb00ed --- /dev/null +++ b/internal/testdata/node/lagoon.yml @@ -0,0 +1,74 @@ +docker-compose-yaml: ../internal/testdata/node/docker-compose.yml + +routes: + autogenerate: + enabled: true + insecure: Redirect + +environment_variables: + git_sha: "true" + +environments: + main: + routes: + - node: + - example.com + + autogendisabled: + autogenerateRoutes: false + routes: + - node: + - example.com + + tworoutes: + routes: + - node: + - example.com + - www.example.com + + branch/routes: + routes: + - node: + - customdomain-will-be-main-domain.com + - customdomain-will-be-not-be-main-domain.com + + ingressclass: + routes: + - node: + - example.com: + ingressClass: "custom-ingress" + hsts: + routes: + - node: + - example.com: + hstsEnabled: true + hstsMaxAge: 10000 + + hsts2: + routes: + - node: + - example.com: + hstsEnabled: true + hstsMaxAge: 10000 + hstsIncludeSubdomains: true + hstsPreload: true + + pr-4841: + routes: + - nginx: + - performance.example.com + + alternativename: + routes: + - node: + - example.com: + alternativenames: + - www.example.com + - en.example.com + + wildcard: + routes: + - node: + - example.com: + tls-acme: false + wildcard: true \ No newline at end of file diff --git a/internal/testdata/testdata.go b/internal/testdata/testdata.go new file mode 100644 index 00000000..07db2cd4 --- /dev/null +++ b/internal/testdata/testdata.go @@ -0,0 +1,237 @@ +package testdata + +import ( + "encoding/json" + "os" + "time" + + "github.com/spf13/cobra" + "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" + generator "github.com/uselagoon/build-deploy-tool/internal/generator" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/machinery/utils/namespace" +) + +// basic data structure for test data using the generator +type TestData struct { + AlertContact string + StatusPageID string + ProjectName string + EnvironmentName string + Branch string + PRNumber string + PRHeadBranch string + PRBaseBranch string + EnvironmentType string + BuildType string + ActiveEnvironment string + StandbyEnvironment string + CacheNoCache string + ServiceID string + SecretPrefix string + IngressClass string + ProjectVars string + EnvVars string + ProjectVariables []lagoon.EnvironmentVariable + EnvVariables []lagoon.EnvironmentVariable + LagoonVersion string + LagoonYAML string + ValuesFilePath string + K8UPVersion string + DefaultBackupSchedule string + ControllerDevSchedule string + ControllerPRSchedule string + Namespace string +} + +// helper function to set up all the environment variables from provided testdata +func SetupEnvironment(rootCmd cobra.Command, templatePath string, t TestData) (generator.GeneratorInput, error) { + err := os.Setenv("MONITORING_ALERTCONTACT", t.AlertContact) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("MONITORING_STATUSPAGEID", t.StatusPageID) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("PROJECT", t.ProjectName) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("ENVIRONMENT", t.EnvironmentName) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("BRANCH", t.Branch) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("PR_NUMBER", t.PRNumber) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("PR_HEAD_BRANCH", t.PRHeadBranch) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("PR_BASE_BRANCH", t.PRBaseBranch) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("ENVIRONMENT_TYPE", t.EnvironmentType) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("BUILD_TYPE", t.BuildType) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("ACTIVE_ENVIRONMENT", t.ActiveEnvironment) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("STANDBY_ENVIRONMENT", t.StandbyEnvironment) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("LAGOON_FASTLY_NOCACHE_SERVICE_ID", t.CacheNoCache) + if err != nil { + return generator.GeneratorInput{}, err + } + pv, _ := json.Marshal(t.ProjectVariables) + err = os.Setenv("LAGOON_PROJECT_VARIABLES", string(pv)) + if err != nil { + return generator.GeneratorInput{}, err + } + ev, _ := json.Marshal(t.EnvVariables) + err = os.Setenv("LAGOON_ENVIRONMENT_VARIABLES", string(ev)) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("LAGOON_VERSION", t.LagoonVersion) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("LAGOON_FEATURE_FLAG_DEFAULT_INGRESS_CLASS", t.IngressClass) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("LAGOON_FEATURE_BACKUP_DEV_SCHEDULE", t.ControllerDevSchedule) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("LAGOON_FEATURE_BACKUP_PR_SCHEDULE", t.ControllerPRSchedule) + if err != nil { + return generator.GeneratorInput{}, err + } + err = os.Setenv("DEFAULT_BACKUP_SCHEDULE", t.DefaultBackupSchedule) + if err != nil { + return generator.GeneratorInput{}, err + } + + generator, err := generator.GenerateInput(rootCmd, false) + if err != nil { + return generator, err + } + generator.LagoonYAML = t.LagoonYAML + generator.SavedTemplatesPath = templatePath + // add dbaasclient overrides for tests + generator.DBaaSClient = dbaasclient.NewClient(dbaasclient.Client{ + RetryMax: 5, + RetryWaitMin: time.Duration(10) * time.Millisecond, + RetryWaitMax: time.Duration(50) * time.Millisecond, + }) + + generator.Namespace = namespace.GenerateNamespaceName("", t.EnvironmentName, t.ProjectName, "", "lagoon", false) + + generator.BackupConfiguration.K8upVersion = t.K8UPVersion + + return generator, nil +} + +func GetSeedData(t TestData, defaultProjectVariables bool) TestData { + // set up the default values, but all values are overwriteable via the input + rt := TestData{ + AlertContact: "alertcontact", // will be deprecated eventually + StatusPageID: "statuspageid", // will be deprecated eventually + ProjectName: "example-project", + EnvironmentType: "production", + BuildType: "branch", + LagoonVersion: "v2.7.x", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SYSTEM_ROUTER_PATTERN", + Value: "${service}-${project}-${environment}.example.com", + Scope: "internal_system", + }, + }, + K8UPVersion: "v1", + } + if t.ProjectName != "" { + rt.ProjectName = t.ProjectName + } + if t.EnvironmentName != "" { + rt.EnvironmentName = t.EnvironmentName + } + if t.Branch != "" { + rt.Branch = t.Branch + } + if t.EnvironmentType != "" { + rt.EnvironmentType = t.EnvironmentType + } + if t.BuildType != "" { + rt.BuildType = t.BuildType + } + if t.PRNumber != "" { + rt.PRNumber = t.PRNumber + } + if t.PRHeadBranch != "" { + rt.PRHeadBranch = t.PRHeadBranch + } + if t.PRBaseBranch != "" { + rt.PRBaseBranch = t.PRBaseBranch + } + if t.LagoonVersion != "" { + rt.LagoonVersion = t.LagoonVersion + } + if t.LagoonYAML != "" { + rt.LagoonYAML = t.LagoonYAML + } + if t.ProjectVariables != nil && defaultProjectVariables { + rt.ProjectVariables = append(rt.ProjectVariables, t.ProjectVariables...) + } else if !defaultProjectVariables { + rt.ProjectVariables = t.ProjectVariables + } + if t.EnvVariables != nil { + rt.EnvVariables = append(rt.EnvVariables, t.EnvVariables...) + } + if t.ActiveEnvironment != "" { + rt.ActiveEnvironment = t.ActiveEnvironment + } + if t.StandbyEnvironment != "" { + rt.StandbyEnvironment = t.StandbyEnvironment + } + if t.IngressClass != "" { + rt.IngressClass = t.IngressClass + } + if t.K8UPVersion != "" { + rt.K8UPVersion = t.K8UPVersion + } + if t.DefaultBackupSchedule != "" { + rt.DefaultBackupSchedule = t.DefaultBackupSchedule + } + if t.ControllerDevSchedule != "" { + rt.ControllerDevSchedule = t.ControllerDevSchedule + } + if t.ControllerPRSchedule != "" { + rt.ControllerPRSchedule = t.ControllerPRSchedule + } + // will be deprecated eventually + if t.AlertContact != "" { + rt.AlertContact = t.AlertContact + } + if t.StatusPageID != "" { + rt.StatusPageID = t.StatusPageID + } + return rt +} diff --git a/test-resources/identify-feature/alltest/lagoon.yml b/test-resources/identify-feature/alltest/lagoon.yml deleted file mode 100644 index 95c7e33c..00000000 --- a/test-resources/identify-feature/alltest/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-feature/alltest/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test1/docker-compose.yml b/test-resources/identify-ingress/test1/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test1/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test1/lagoon.yml b/test-resources/identify-ingress/test1/lagoon.yml deleted file mode 100644 index 11014a8f..00000000 --- a/test-resources/identify-ingress/test1/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test1/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test10/docker-compose.yml b/test-resources/identify-ingress/test10/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test10/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test10/lagoon.yml b/test-resources/identify-ingress/test10/lagoon.yml deleted file mode 100644 index 33b7645e..00000000 --- a/test-resources/identify-ingress/test10/lagoon.yml +++ /dev/null @@ -1,24 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test10/docker-compose.yml - -environment_variables: - git_sha: "true" - -production_routes: - active: - routes: - - node: - - active.example.com - standby: - routes: - - node: - - standby.example.com - -environments: - main: - routes: - - node: - - main.example.com - main2: - routes: - - node: - - main2.example.com diff --git a/test-resources/identify-ingress/test11/docker-compose.yml b/test-resources/identify-ingress/test11/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test11/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test11/lagoon.yml b/test-resources/identify-ingress/test11/lagoon.yml deleted file mode 100644 index f5b41214..00000000 --- a/test-resources/identify-ingress/test11/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test11/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test12/docker-compose.yml b/test-resources/identify-ingress/test12/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test12/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test13/docker-compose.yml b/test-resources/identify-ingress/test13/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test13/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test13/lagoon.yml b/test-resources/identify-ingress/test13/lagoon.yml deleted file mode 100644 index 3cdc7fad..00000000 --- a/test-resources/identify-ingress/test13/lagoon.yml +++ /dev/null @@ -1,14 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test13/docker-compose.yml - -routes: - autogenerate: - enabled: false - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test14/docker-compose.yml b/test-resources/identify-ingress/test14/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test14/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test14/lagoon.yml b/test-resources/identify-ingress/test14/lagoon.yml deleted file mode 100644 index 9593676f..00000000 --- a/test-resources/identify-ingress/test14/lagoon.yml +++ /dev/null @@ -1,5 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test14/docker-compose.yml - -environment_variables: - git_sha: "true" - diff --git a/test-resources/identify-ingress/test15/docker-compose.yml b/test-resources/identify-ingress/test15/docker-compose.yml deleted file mode 100644 index 017ea5a9..00000000 --- a/test-resources/identify-ingress/test15/docker-compose.yml +++ /dev/null @@ -1,153 +0,0 @@ -version: '2.3' - -x-lagoon-project: - # Lagoon project name (leave `&lagoon-project` when you edit this) - &lagoon-project $PROJECT_NAME - -x-environment: - &default-environment - # Environment ID - ENVIRONMENT_TYPE_ID: $ENVIRONMENT_TYPE_ID - # Machine name of the lagoon project. - LAGOON_PROJECT: *lagoon-project - # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io - LAGOON_ROUTE: &default-url http://$LAGOON_ROUTE - # Uncomment if you like to have the system behave like in production - LAGOON_ENVIRONMENT_TYPE: $LAGOON_ENVIRONMENT_TYPE - # The current Git branch of the Lagoon environment. - # LAGOON_GIT_BRANCH: $LAGOON_GIT_BRANCH - # Enable Xdebug within the .env file, then `make down` to reload the env. - XDEBUG_ENABLE: $XDEBUG_ENABLE - # The entrypoint script attempts to autodetect the DOCKERHOST for xdebug. - # If it fails to detect your host, the following override is available: - # DOCKERHOST: host.docker.internal - # Increase PHP memory limit. - PHP_MEMORY_LIMIT: 768M - -x-site-branch: - &site-branch $LAGOON_GIT_BRANCH - -x-user: - &default-user - user: $DEFAULT_USER_ID - -services: - - cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) - build: - context: . - dockerfile: .lagoon/cli.dockerfile - args: - ENVIRONMENT_TYPE_ID: ${ENVIRONMENT_TYPE_ID} - DOCKER_CLI_IMAGE_URI: ${DOCKER_CLI_IMAGE_URI} - image: *lagoon-project # this image will be reused as `CLI_IMAGE` in subsequent Docker builds - container_name: ${PROJECT_NAME}_cli - labels: - # Lagoon Labels - lagoon.type: cli-persistent - lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container - lagoon.persistent: /app/docroot/sites/default/files/ # location where the persistent storage should be mounted - user: root - environment: - << : *default-environment # loads the defined environment variables from the top - volumes: - - ./.lagoon/scripts/bash_prompts.rc:/home/.bashrc - - ./.lagoon/scripts/color_grid.sh:/home/color_grid.sh - volumes_from: - - container:amazeeio-ssh-agent - - nginx: - build: - context: . - dockerfile: .lagoon/nginx.dockerfile - args: - CLI_IMAGE: *lagoon-project - DOCKER_NGINX_IMAGE_URI: ${DOCKER_NGINX_IMAGE_URI} - LAGOON_GIT_BRANCH: *site-branch - container_name: ${PROJECT_NAME}_nginx - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.name: nginx - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - # LAGOON_LOCALDEV_URL: nginx-${LAGOON_ROUTE} - LAGOON_LOCALDEV_URL: *default-url - networks: - - amazeeio-network - - default - volumes: - - ./.lagoon/nginx/nginx-http.conf:/etc/nginx/conf.d/000-nginx-http.conf - - ./.lagoon/nginx/app.conf:/etc/nginx/conf.d/app.conf - - php: - build: - context: . - dockerfile: .lagoon/php.dockerfile - args: - CLI_IMAGE: *lagoon-project - DOCKER_PHP_IMAGE_URI: ${DOCKER_PHP_IMAGE_URI} - container_name: ${PROJECT_NAME}_php - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files - lagoon.name: nginx - lagoon.deployment.servicetype: php - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - - mariadb: - image: amazeeio/mariadb-drupal - container_name: ${PROJECT_NAME}_db - labels: - lagoon.type: mariadb - ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` - << : *default-user # uses the defined user from top - environment: - << : *default-environment - volumes: - # - .lagoon/mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here. - # - /path/to/mariadb/data/on/host:/var/lib/mysql # Use bind mount - - mysql:/var/lib/mysql - - # redis: - # image: amazeeio/redis - # labels: - # lagoon.type: redis - # << : *default-user # uses the defined user from top - # environment: - # << : *default-environment - - # solr7: - # # The DOCKERFILE makes use of this amazeeio image as a base and then loads our own config files into it. - # # Update the .lagoon/solr/7/solr-conf files before building to make changes to SOLR. - # # image: amazeeio/solr:7.7-drupal-latest - # build: - # context: . - # dockerfile: ./.lagoon/solr/7/solr.dockerfile - # labels: - # lagoon.type: solr - # ports: - # - "8983" # exposes the port 8983 with a random local port, find it with `docker-compose port solr 8983` - # environment: - # << : *default-environment - # volumes: - # # - ./lagoon/solr/7/solr-conf/:/solr-conf/conf/ - # - solr7:/var/solr - -networks: - amazeeio-network: - external: true - -volumes: - app: - # Add a volume for the DB so it persists between shutdowns. - mysql: - solr7: \ No newline at end of file diff --git a/test-resources/identify-ingress/test15/lagoon.yml b/test-resources/identify-ingress/test15/lagoon.yml deleted file mode 100644 index b5d40304..00000000 --- a/test-resources/identify-ingress/test15/lagoon.yml +++ /dev/null @@ -1,66 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test15/docker-compose.yml -environments: - master: - cronjobs: - - command: drush cron - name: drush cron - schedule: '*/15 * * * *' - service: cli -lagoon-sync: - drupalconfig: - config: - syncpath: /app/config/default - files: - config: - sync-directory: /app/docroot/sites/default/files - mariadb: - config: - database: $MARIADB_DATABASE - hostname: $MARIADB_HOST - password: $MARIADB_PASSWORD - port: $MARIADB_PORT - username: $MARIADB_USERNAME - local: - config: - database: drupal - hostname: mariadb - password: drupal - port: '3306' - username: drupal -project: project-name -routes: - insecure: Redirect -tasks: - post-rollout: - - run: - command: "if tables=$(drush sqlq \"show tables like 'node';\" | awk '{print $1}' | grep node | wc -l) && [ $tables -eq 0 ]; then\n drush site-install bi_gds_profile install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL --yes --debug\nfi\n" - name: Install Drupal if not installed - service: cli - - run: - command: "if tables=$(drush sqlq \"show tables like 'node';\" | awk '{print $1}' | grep node | wc -l) && [ $tables -eq 1 ]; then\n drush updb --yes\nfi\n" - name: drush updb - service: cli - - run: - command: drush -y cr - name: drush cr - service: cli - - run: - command: "if [ -f \"/app/config/default/core.extension.yml\" ]; then\n drush cim sync --yes\nfi\n" - name: drush cim - service: cli - - run: - command: drush -y cr - name: drush cr - service: cli - - run: - command: drush en lagoon_logs --yes - name: drush en lagoon_logs --yes - service: cli - - run: - command: drush en clamav --yes - name: drush en clamav --yes - service: cli - - run: - command: drush -y cr - name: drush cr - service: cli \ No newline at end of file diff --git a/test-resources/identify-ingress/test16/docker-compose.yml b/test-resources/identify-ingress/test16/docker-compose.yml deleted file mode 100644 index 946ec1b0..00000000 --- a/test-resources/identify-ingress/test16/docker-compose.yml +++ /dev/null @@ -1,146 +0,0 @@ -version: '2.3' - -x-example-image-version: - &example-image-version ${EXAMPLE_IMAGE_VERSION:-4.x} - -x-project: - &project ${PROJECT_NAME:-mysite} - -x-volumes: - &default-volumes - volumes: - - .:/app:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - - ./docroot/sites/default/files:/app/docroot/sites/default/files:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - -x-environment: - &default-environment - LAGOON_PROJECT: *project - DRUPAL_HASH_SALT: fakehashsaltfakehashsaltfakehashsalt - LAGOON_LOCALDEV_URL: ${LOCALDEV_URL:-http://mysite.docker.amazee.io} - LAGOON_ROUTE: ${LOCALDEV_URL:-http://mysite.docker.amazee.io} - GITHUB_TOKEN: ${GITHUB_TOKEN:-} - EXAMPLE_KEY: ${EXAMPLE_KEY:-} - EXAMPLE_IMAGE_VERSION: ${EXAMPLE_IMAGE_VERSION:-latest} - LAGOON_ENVIRONMENT_TYPE: ${LAGOON_ENVIRONMENT_TYPE:-local} - DRUPAL_REFRESH_SEARCHAPI: ${DRUPAL_REFRESH_SEARCHAPI:-} - EXAMPLE_INGRESS_PSK: ${EXAMPLE_INGRESS_PSK:-} - EXAMPLE_INGRESS_HEADER: ${EXAMPLE_INGRESS_HEADER:-} - EXAMPLE_INGRESS_ENABLED: ${EXAMPLE_INGRESS_ENABLED:-} - REDIS_CACHE_PREFIX: "tide_" - DB_ALIAS: ${DB_ALIAS:-bay.production} - - -services: - - cli: - build: - context: . - dockerfile: .docker/Dockerfile.cli - args: - COMPOSER: ${COMPOSER:-composer.json} - EXAMPLE_IMAGE_VERSION: *example-image-version - image: *project - environment: - << : *default-environment - << : *default-volumes - volumes_from: ### Local overrides to mount host SSH keys. Automatically removed in CI. - - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. - labels: - lagoon.type: cli-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.name: nginx-php - lagoon.persistent.size: 5Gi - - nginx: - build: - context: . - dockerfile: .docker/Dockerfile.nginx-drupal - args: - CLI_IMAGE: *project - EXAMPLE_IMAGE_VERSION: *example-image-version - << : *default-volumes - environment: - << : *default-environment - depends_on: - - cli - networks: - - amazeeio-network - - default - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.size: 5Gi - lagoon.name: nginx-php - expose: - - "8080" - php: - build: - context: . - dockerfile: .docker/Dockerfile.php - args: - CLI_IMAGE: *project - EXAMPLE_IMAGE_VERSION: *example-image-version - environment: - << : *default-environment - << : *default-volumes - depends_on: - - cli - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.size: 5Gi - lagoon.name: nginx-php - - mariadb: - image: amazeeio/mariadb-drupal - environment: - << : *default-environment - ports: - - "3306" # Find port on host with `ahoy info` or `docker-compose port mariadb 3306` - labels: - lagoon.type: mariadb-shared - - redis: - image: amazeeio/redis - labels: - lagoon.type: redis - - elasticsearch: - build: - context: . - dockerfile: .docker/Dockerfile.elasticsearch - args: - - ES_TPL=${ES_TPL:-elasticsearch.yml} - environment: - - discovery.type=single-node - labels: - lagoon.type: none - - chrome: - image: selenium/standalone-chrome:3.141.59-oxygen - shm_size: '1gb' - environment: - << : *default-environment - << : *default-volumes - depends_on: - - cli - labels: - lagoon.type: none - - clamav: - image: clamav/clamav:${EXAMPLE_IMAGE_VERSION:-4.x} - environment: - << : *default-environment - ports: - - "3310" - labels: - lagoon.type: none - - -networks: - amazeeio-network: - external: true - -volumes: - app: {} - files: {} \ No newline at end of file diff --git a/test-resources/identify-ingress/test16/lagoon.yml b/test-resources/identify-ingress/test16/lagoon.yml deleted file mode 100644 index ca84a886..00000000 --- a/test-resources/identify-ingress/test16/lagoon.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -docker-compose-yaml: ../test-resources/template-autogenerated/test20/docker-compose.yml - -project: content-example-com - -environments: - production: - cronjobs: - - name: drush cron - schedule: "*/15 * * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "content.example.com": - monitoring-path: "/api/v1" - tls-acme: 'false' - insecure: Allow - master: - cronjobs: - - name: drush cron - schedule: "0 1,4 * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "master.content.example.com": - tls-acme: 'false' - insecure: Allow - develop: - cronjobs: - - name: drush cron - schedule: "0 1,4 * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "develop.content.example.com": - tls-acme: 'false' - insecure: Allow diff --git a/test-resources/identify-ingress/test17/docker-compose.yml b/test-resources/identify-ingress/test17/docker-compose.yml deleted file mode 100644 index 4343ba9a..00000000 --- a/test-resources/identify-ingress/test17/docker-compose.yml +++ /dev/null @@ -1,119 +0,0 @@ -version: '2.3' - -x-volumes: - &default-volumes - # Define all volumes you would like to have real-time mounted into the docker containers - volumes: - - .:/app:delegated ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - - files:/app/web/sites/default/files - -x-environment: - &default-environment - # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io - LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-drupal9-varnish}.docker.amazee.io - # Uncomment if you like to have the system behave like in production - #LAGOON_ENVIRONMENT_TYPE: production - # Uncomment to enable xdebug and then restart via `docker-compose up -d` - #XDEBUG_ENABLE: "true" - -x-user: - &default-user - # The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000` - user: '1000' - -volumes: - files: - {} - db: - {} - -services: - - cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) - build: - context: . - dockerfile: lagoon/cli.dockerfile - image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal9-varnish}-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds - labels: - # Lagoon Labels - lagoon.type: cli-persistent - lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container - lagoon.persistent: /app/web/sites/default/files/ # location where the persistent storage should be mounted - lando.type: php-cli-drupal - << : *default-volumes # loads the defined volumes from the top - user: root - volumes_from: ### mount the ssh-agent from the pygmy or cachalot ssh-agent. Automatically removed in CI. - - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. - environment: - << : *default-environment # loads the defined environment variables from the top - - nginx: - build: - context: . - dockerfile: lagoon/nginx.dockerfile - args: - CLI_IMAGE: *cli-image # Inject the name of the cli image - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: nginx-drupal - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - LAGOON_LOCALDEV_URL: nginx-${COMPOSE_PROJECT_NAME:-drupal9-varnish} # generate another route for nginx, by default we go to varnish - networks: - - amazeeio-network - - default - - php: - build: - context: . - dockerfile: lagoon/php.dockerfile - args: - CLI_IMAGE: *cli-image - labels: - lagoon.type: nginx-php-persistent - lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: php-fpm - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - - mariadb: - image: uselagoon/mariadb-10.5-drupal:latest - labels: - lagoon.type: mariadb - lando.type: mariadb-drupal - ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` - << : *default-user # uses the defined user from top - environment: - << : *default-environment - volumes: - - db:/var/lib/mysql - - varnish: - image: uselagoon/varnish-5-drupal:latest - labels: - lagoon.type: varnish - lando.type: varnish-drupal - links: - - nginx # links varnish to the nginx in this docker-compose project, or it would try to connect to any nginx running in docker - << : *default-user # uses the defined user from top - environment: - << : *default-environment - VARNISH_BYPASS: "true" # by default we bypass varnish, change to 'false' or remove in order to tell varnish to cache if possible - networks: - - amazeeio-network - - default - -networks: - amazeeio-network: - external: true diff --git a/test-resources/identify-ingress/test17/lagoon.yml b/test-resources/identify-ingress/test17/lagoon.yml deleted file mode 100644 index 2ac5394c..00000000 --- a/test-resources/identify-ingress/test17/lagoon.yml +++ /dev/null @@ -1 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test17/docker-compose.yml diff --git a/test-resources/identify-ingress/test18/docker-compose.yml b/test-resources/identify-ingress/test18/docker-compose.yml deleted file mode 100644 index 8620df9d..00000000 --- a/test-resources/identify-ingress/test18/docker-compose.yml +++ /dev/null @@ -1,104 +0,0 @@ -version: '2.3' - -x-volumes: - &default-volumes - # Define all volumes you would like to have real-time mounted into the docker containers - volumes: - - .:/app:delegated ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - - files:/app/web/sites/default/files - -x-environment: - &default-environment - # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io - LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-drupal9-varnish}.docker.amazee.io - # Uncomment if you like to have the system behave like in production - #LAGOON_ENVIRONMENT_TYPE: production - # Uncomment to enable xdebug and then restart via `docker-compose up -d` - #XDEBUG_ENABLE: "true" - -x-user: - &default-user - # The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000` - user: '1000' - -volumes: - files: - {} - db: - {} - -services: - - cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) - build: - context: . - dockerfile: lagoon/cli.dockerfile - image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal9-varnish}-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds - labels: - # Lagoon Labels - lagoon.type: cli-persistent - lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container - lagoon.persistent: /app/web/sites/default/files/ # location where the persistent storage should be mounted - lando.type: php-cli-drupal - << : *default-volumes # loads the defined volumes from the top - user: root - volumes_from: ### mount the ssh-agent from the pygmy or cachalot ssh-agent. Automatically removed in CI. - - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. - environment: - << : *default-environment # loads the defined environment variables from the top - - nginx: - build: - context: . - dockerfile: lagoon/nginx.dockerfile - args: - CLI_IMAGE: *cli-image # Inject the name of the cli image - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: nginx-drupal - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - LAGOON_LOCALDEV_URL: nginx-${COMPOSE_PROJECT_NAME:-drupal9-varnish} # generate another route for nginx, by default we go to varnish - networks: - - amazeeio-network - - default - - php: - build: - context: . - dockerfile: lagoon/php.dockerfile - args: - CLI_IMAGE: *cli-image - labels: - lagoon.type: nginx-php-persistent - lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: php-fpm - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - - mariadb: - image: uselagoon/mariadb-10.5-drupal:latest - labels: - lagoon.type: mariadb - lando.type: mariadb-drupal - ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` - << : *default-user # uses the defined user from top - environment: - << : *default-environment - volumes: - - db:/var/lib/mysql - -networks: - amazeeio-network: - external: true diff --git a/test-resources/identify-ingress/test2/docker-compose.yml b/test-resources/identify-ingress/test2/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test2/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test2/lagoon.yml b/test-resources/identify-ingress/test2/lagoon.yml deleted file mode 100644 index 5488ac78..00000000 --- a/test-resources/identify-ingress/test2/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test2/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test3/docker-compose.yml b/test-resources/identify-ingress/test3/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test3/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test3/lagoon.yml b/test-resources/identify-ingress/test3/lagoon.yml deleted file mode 100644 index b64b8d08..00000000 --- a/test-resources/identify-ingress/test3/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test3/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test4/docker-compose.yml b/test-resources/identify-ingress/test4/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test4/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test4/lagoon.yml b/test-resources/identify-ingress/test4/lagoon.yml deleted file mode 100644 index 09628cc2..00000000 --- a/test-resources/identify-ingress/test4/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test4/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/identify-ingress/test5/docker-compose.yml b/test-resources/identify-ingress/test5/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test5/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test5/lagoon.yml b/test-resources/identify-ingress/test5/lagoon.yml deleted file mode 100644 index 6116b5bd..00000000 --- a/test-resources/identify-ingress/test5/lagoon.yml +++ /dev/null @@ -1,17 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test5/docker-compose.yml - -environment_variables: - git_sha: "true" - -multiproject1: - environments: - multiproject: - routes: - - node: - - multiproject1.com -multiproject2: - environments: - multiproject: - routes: - - node: - - multiproject2.com diff --git a/test-resources/identify-ingress/test6/docker-compose.yml b/test-resources/identify-ingress/test6/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test6/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test7/docker-compose.yml b/test-resources/identify-ingress/test7/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test7/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test7/lagoon.yml b/test-resources/identify-ingress/test7/lagoon.yml deleted file mode 100644 index 78d82084..00000000 --- a/test-resources/identify-ingress/test7/lagoon.yml +++ /dev/null @@ -1,11 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test7/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com - - www.example.com diff --git a/test-resources/identify-ingress/test8/docker-compose.yml b/test-resources/identify-ingress/test8/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test8/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test8/lagoon.yml b/test-resources/identify-ingress/test8/lagoon.yml deleted file mode 100644 index 208ae326..00000000 --- a/test-resources/identify-ingress/test8/lagoon.yml +++ /dev/null @@ -1,8 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test8/docker-compose.yml - -environments: - branch/routes: - routes: - - node: - - customdomain-will-be-main-domain.com - - customdomain-will-be-not-be-main-domain.com diff --git a/test-resources/identify-ingress/test9/docker-compose.yml b/test-resources/identify-ingress/test9/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/identify-ingress/test9/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/identify-ingress/test9/lagoon.yml b/test-resources/identify-ingress/test9/lagoon.yml deleted file mode 100644 index df3a1958..00000000 --- a/test-resources/identify-ingress/test9/lagoon.yml +++ /dev/null @@ -1,24 +0,0 @@ -docker-compose-yaml: ../test-resources/identify-ingress/test9/docker-compose.yml - -environment_variables: - git_sha: "true" - -production_routes: - active: - routes: - - node: - - active.example.com - standby: - routes: - - node: - - standby.example.com - -environments: - main: - routes: - - node: - - main.example.com - main2: - routes: - - node: - - main2.example.com diff --git a/test-resources/template-autogenerated/test1/docker-compose.yml b/test-resources/template-autogenerated/test1/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test1/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test10/docker-compose.yml b/test-resources/template-autogenerated/test10/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test10/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test10/lagoon.yml b/test-resources/template-autogenerated/test10/lagoon.yml deleted file mode 100644 index ee4ca0a4..00000000 --- a/test-resources/template-autogenerated/test10/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test10/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test11/docker-compose.yml b/test-resources/template-autogenerated/test11/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test11/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test11/lagoon.yml b/test-resources/template-autogenerated/test11/lagoon.yml deleted file mode 100644 index f2751c1e..00000000 --- a/test-resources/template-autogenerated/test11/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test11/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test12/docker-compose.yml b/test-resources/template-autogenerated/test12/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test12/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test13/lagoon.yml b/test-resources/template-autogenerated/test13/lagoon.yml deleted file mode 100644 index e0f067a9..00000000 --- a/test-resources/template-autogenerated/test13/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test13/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test14/docker-compose.yml b/test-resources/template-autogenerated/test14/docker-compose.yml deleted file mode 100644 index a6462abd..00000000 --- a/test-resources/template-autogenerated/test14/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: none - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test14/lagoon.yml b/test-resources/template-autogenerated/test14/lagoon.yml deleted file mode 100644 index 96825292..00000000 --- a/test-resources/template-autogenerated/test14/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test14/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test15/lagoon.yml b/test-resources/template-autogenerated/test15/lagoon.yml deleted file mode 100644 index acf07736..00000000 --- a/test-resources/template-autogenerated/test15/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test15/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test16/lagoon.yml b/test-resources/template-autogenerated/test16/lagoon.yml deleted file mode 100644 index d3969d75..00000000 --- a/test-resources/template-autogenerated/test16/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test16/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test18/docker-compose.yml b/test-resources/template-autogenerated/test18/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test18/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test2/docker-compose.yml b/test-resources/template-autogenerated/test2/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test2/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test20/lagoon.yml b/test-resources/template-autogenerated/test20/lagoon.yml deleted file mode 100644 index ca84a886..00000000 --- a/test-resources/template-autogenerated/test20/lagoon.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -docker-compose-yaml: ../test-resources/template-autogenerated/test20/docker-compose.yml - -project: content-example-com - -environments: - production: - cronjobs: - - name: drush cron - schedule: "*/15 * * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "content.example.com": - monitoring-path: "/api/v1" - tls-acme: 'false' - insecure: Allow - master: - cronjobs: - - name: drush cron - schedule: "0 1,4 * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "master.content.example.com": - tls-acme: 'false' - insecure: Allow - develop: - cronjobs: - - name: drush cron - schedule: "0 1,4 * * *" - command: 'drush cron' - service: cli - - routes: - - nginx-php: - - "develop.content.example.com": - tls-acme: 'false' - insecure: Allow diff --git a/test-resources/template-autogenerated/test23/docker-compose.yml b/test-resources/template-autogenerated/test23/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test23/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test23/lagoon.yml b/test-resources/template-autogenerated/test23/lagoon.yml deleted file mode 100644 index 6d3a5828..00000000 --- a/test-resources/template-autogenerated/test23/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test23/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test24/docker-compose.yml b/test-resources/template-autogenerated/test24/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test24/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test25/docker-compose.yml b/test-resources/template-autogenerated/test25/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test25/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test25/lagoon.yml b/test-resources/template-autogenerated/test25/lagoon.yml deleted file mode 100644 index 37d0d852..00000000 --- a/test-resources/template-autogenerated/test25/lagoon.yml +++ /dev/null @@ -1,18 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test6/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - allowPullrequests: false - -environment_variables: - git_sha: "true" - -example-project: - environments: - main: - autogenerateRoutes: false - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test26/docker-compose.yml b/test-resources/template-autogenerated/test26/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test26/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test26/lagoon.yml b/test-resources/template-autogenerated/test26/lagoon.yml deleted file mode 100644 index f39f216d..00000000 --- a/test-resources/template-autogenerated/test26/lagoon.yml +++ /dev/null @@ -1,17 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test6/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - allowPullrequests: false - -environment_variables: - git_sha: "true" - -environments: - main: - autogenerateRoutes: false - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test3/docker-compose.yml b/test-resources/template-autogenerated/test3/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test3/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test4/docker-compose.yml b/test-resources/template-autogenerated/test4/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test4/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test5/docker-compose.yml b/test-resources/template-autogenerated/test5/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test5/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test6/lagoon.yml b/test-resources/template-autogenerated/test6/lagoon.yml deleted file mode 100644 index f0e9319b..00000000 --- a/test-resources/template-autogenerated/test6/lagoon.yml +++ /dev/null @@ -1,16 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test6/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - allowPullrequests: false - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-autogenerated/test7-results/node.yaml b/test-resources/template-autogenerated/test7-results/node.yaml deleted file mode 100644 index edc3b5c2..00000000 --- a/test-resources/template-autogenerated/test7-results/node.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - fastly.amazee.io/watch: "false" - ingress.kubernetes.io/ssl-redirect: "true" - kubernetes.io/tls-acme: "true" - lagoon.sh/branch: main - lagoon.sh/version: v2.7.x - monitor.stakater.com/enabled: "false" - nginx.ingress.kubernetes.io/server-snippet: | - add_header X-Robots-Tag "noindex, nofollow"; - nginx.ingress.kubernetes.io/ssl-redirect: "true" - creationTimestamp: null - labels: - app.kubernetes.io/instance: node - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/name: autogenerated-ingress - helm.sh/chart: autogenerated-ingress-0.1.0 - lagoon.sh/autogenerated: "true" - lagoon.sh/buildType: branch - lagoon.sh/environment: main - lagoon.sh/environmentType: production - lagoon.sh/project: example-project - lagoon.sh/service: node - lagoon.sh/service-type: node - name: node -spec: - rules: - - host: node-example-project-main.example.com - http: - paths: - - backend: - service: - name: node - port: - name: http - path: / - pathType: Prefix - tls: - - hosts: - - node-example-project-main.example.com - secretName: node-tls -status: - loadBalancer: {} diff --git a/test-resources/template-autogenerated/test8/docker-compose.yml b/test-resources/template-autogenerated/test8/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test8/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test9/docker-compose.yml b/test-resources/template-autogenerated/test9/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-autogenerated/test9/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-autogenerated/test9/lagoon.yml b/test-resources/template-autogenerated/test9/lagoon.yml deleted file mode 100644 index 4c2b4e02..00000000 --- a/test-resources/template-autogenerated/test9/lagoon.yml +++ /dev/null @@ -1,15 +0,0 @@ -docker-compose-yaml: ../test-resources/template-autogenerated/test9/docker-compose.yml - -routes: - autogenerate: - enabled: true - insecure: Redirect - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test1/docker-compose.yml b/test-resources/template-backups/test1/docker-compose.yml deleted file mode 100644 index e116c1d3..00000000 --- a/test-resources/template-backups/test1/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - - mariadb: - image: uselagoon/mariadb-10.5-drupal:latest - labels: - lagoon.type: mariadb - lando.type: mariadb-drupal - ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` - - elasticsearch: - image: uselagoon/elasticsearch-7:latest - labels: - lagoon.type: elasticsearch - lando.type: elasticsearch - ports: - - "9200" # exposes the port 9200 with a random local port, find it with `docker-compose port elasticsearch 9200` - volumes: - - search:/usr/share/elasticsearch/data - -networks: - amazeeio-network: - external: true - -volumes: - search: - {} \ No newline at end of file diff --git a/test-resources/template-backups/test1/lagoon.yml b/test-resources/template-backups/test1/lagoon.yml deleted file mode 100644 index cb01eb0e..00000000 --- a/test-resources/template-backups/test1/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test1/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test2/docker-compose.yml b/test-resources/template-backups/test2/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test2/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test2/lagoon.yml b/test-resources/template-backups/test2/lagoon.yml deleted file mode 100644 index cc2852c8..00000000 --- a/test-resources/template-backups/test2/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test2/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test3/docker-compose.yml b/test-resources/template-backups/test3/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test3/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test3/lagoon.yml b/test-resources/template-backups/test3/lagoon.yml deleted file mode 100644 index 2a16df9c..00000000 --- a/test-resources/template-backups/test3/lagoon.yml +++ /dev/null @@ -1,17 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test3/docker-compose.yml - -backup-retention: - production: - hourly: 10 - daily: 10 - weekly: 10 - monthly: 10 - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test4/docker-compose.yml b/test-resources/template-backups/test4/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test4/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test4/lagoon.yml b/test-resources/template-backups/test4/lagoon.yml deleted file mode 100644 index 0c02681c..00000000 --- a/test-resources/template-backups/test4/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test4/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test5/docker-compose.yml b/test-resources/template-backups/test5/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test5/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test5/lagoon.yml b/test-resources/template-backups/test5/lagoon.yml deleted file mode 100644 index 059e7f07..00000000 --- a/test-resources/template-backups/test5/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test5/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test6/docker-compose.yml b/test-resources/template-backups/test6/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test6/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test6/lagoon.yml b/test-resources/template-backups/test6/lagoon.yml deleted file mode 100644 index 06e2319f..00000000 --- a/test-resources/template-backups/test6/lagoon.yml +++ /dev/null @@ -1,20 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test6/docker-compose.yml - -backup-retention: - production: - hourly: 10 - daily: 10 - weekly: 16 - monthly: 12 - -backup-schedule: - production: "M/15 5 * * 0" - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-backups/test7/docker-compose.yml b/test-resources/template-backups/test7/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-backups/test7/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-backups/test7/lagoon.yml b/test-resources/template-backups/test7/lagoon.yml deleted file mode 100644 index ec232e42..00000000 --- a/test-resources/template-backups/test7/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-backups/test7/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-dbaas/test1/docker-compose.yml b/test-resources/template-dbaas/test1/docker-compose.yml deleted file mode 100644 index 51ec1413..00000000 --- a/test-resources/template-dbaas/test1/docker-compose.yml +++ /dev/null @@ -1,121 +0,0 @@ -version: '2.3' - -x-volumes: - &default-volumes - # Define all volumes you would like to have real-time mounted into the docker containers - volumes: - - .:/app:delegated ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - - files:/app/web/sites/default/files - -x-environment: - &default-environment - # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io - LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-drupal9-example-advanced}.docker.amazee.io - # Uncomment if you like to have the system behave like in production - #LAGOON_ENVIRONMENT_TYPE: production - # Uncomment to enable xdebug and then restart via `docker-compose up -d` - #XDEBUG_ENABLE: "true" - -x-user: - &default-user - # The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000` - user: '1000' - -volumes: - files: - {} - -services: - - cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) - build: - context: . - dockerfile: lagoon/cli.dockerfile - image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal9-example-advanced}-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds - labels: - # Lagoon Labels - lagoon.type: cli-persistent - lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container - lagoon.persistent: /app/web/sites/default/files/ # location where the persistent storage should be mounted - lando.type: php-cli-drupal - << : *default-volumes # loads the defined volumes from the top - user: root - volumes_from: ### mount the ssh-agent from the pygmy or cachalot ssh-agent. Automatically removed in CI. - - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. - environment: - << : *default-environment # loads the defined environment variables from the top - - nginx: - build: - context: . - dockerfile: lagoon/nginx.dockerfile - args: - CLI_IMAGE: *cli-image # Inject the name of the cli image - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: nginx-drupal - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - LAGOON_LOCALDEV_URL: *default-url - networks: - - amazeeio-network - - default - - php: - build: - context: . - dockerfile: lagoon/php.dockerfile - args: - CLI_IMAGE: *cli-image - labels: - lagoon.type: nginx-php-persistent - lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon - lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too - lando.type: php-fpm - << : *default-volumes # loads the defined volumes from the top - << : *default-user # uses the defined user from top - depends_on: - - cli # basically just tells docker-compose to build the cli first - environment: - << : *default-environment # loads the defined environment variables from the top - - mariadb: - image: uselagoon/mariadb-10.5-drupal:latest - labels: - lagoon.type: mariadb - lando.type: mariadb-drupal - ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` - << : *default-user # uses the defined user from top - environment: - << : *default-environment - - redis: - image: uselagoon/redis-5:latest - labels: - lagoon.type: redis - lando.type: redis - ports: - - "6379" # exposes the port 6379 with a random local port, find it with `docker-compose port redis 6379` - << : *default-user # uses the defined user from top - environment: - << : *default-environment - - solr: - image: uselagoon/solr-7.7-drupal:latest - labels: - lagoon.type: solr - lando.type: solr-drupal - ports: - - "8983" # exposes the port 8983 with a random local port, find it with `docker-compose port solr 8983` - environment: - << : *default-environment - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test1/docker-compose.yml b/test-resources/template-ingress/test1/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test1/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test1/lagoon.yml b/test-resources/template-ingress/test1/lagoon.yml deleted file mode 100644 index 7d4c3bd8..00000000 --- a/test-resources/template-ingress/test1/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test1/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test10/docker-compose.yml b/test-resources/template-ingress/test10/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test10/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test10/lagoon.yml b/test-resources/template-ingress/test10/lagoon.yml deleted file mode 100644 index 603e8c67..00000000 --- a/test-resources/template-ingress/test10/lagoon.yml +++ /dev/null @@ -1,24 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test10/docker-compose.yml - -environment_variables: - git_sha: "true" - -production_routes: - active: - routes: - - node: - - active.example.com - standby: - routes: - - node: - - standby.example.com - -environments: - main: - routes: - - node: - - main.example.com - main2: - routes: - - node: - - main2.example.com diff --git a/test-resources/template-ingress/test11/docker-compose.yml b/test-resources/template-ingress/test11/docker-compose.yml deleted file mode 100644 index 946ec1b0..00000000 --- a/test-resources/template-ingress/test11/docker-compose.yml +++ /dev/null @@ -1,146 +0,0 @@ -version: '2.3' - -x-example-image-version: - &example-image-version ${EXAMPLE_IMAGE_VERSION:-4.x} - -x-project: - &project ${PROJECT_NAME:-mysite} - -x-volumes: - &default-volumes - volumes: - - .:/app:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - - ./docroot/sites/default/files:/app/docroot/sites/default/files:${VOLUME_FLAGS:-delegated} ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. - -x-environment: - &default-environment - LAGOON_PROJECT: *project - DRUPAL_HASH_SALT: fakehashsaltfakehashsaltfakehashsalt - LAGOON_LOCALDEV_URL: ${LOCALDEV_URL:-http://mysite.docker.amazee.io} - LAGOON_ROUTE: ${LOCALDEV_URL:-http://mysite.docker.amazee.io} - GITHUB_TOKEN: ${GITHUB_TOKEN:-} - EXAMPLE_KEY: ${EXAMPLE_KEY:-} - EXAMPLE_IMAGE_VERSION: ${EXAMPLE_IMAGE_VERSION:-latest} - LAGOON_ENVIRONMENT_TYPE: ${LAGOON_ENVIRONMENT_TYPE:-local} - DRUPAL_REFRESH_SEARCHAPI: ${DRUPAL_REFRESH_SEARCHAPI:-} - EXAMPLE_INGRESS_PSK: ${EXAMPLE_INGRESS_PSK:-} - EXAMPLE_INGRESS_HEADER: ${EXAMPLE_INGRESS_HEADER:-} - EXAMPLE_INGRESS_ENABLED: ${EXAMPLE_INGRESS_ENABLED:-} - REDIS_CACHE_PREFIX: "tide_" - DB_ALIAS: ${DB_ALIAS:-bay.production} - - -services: - - cli: - build: - context: . - dockerfile: .docker/Dockerfile.cli - args: - COMPOSER: ${COMPOSER:-composer.json} - EXAMPLE_IMAGE_VERSION: *example-image-version - image: *project - environment: - << : *default-environment - << : *default-volumes - volumes_from: ### Local overrides to mount host SSH keys. Automatically removed in CI. - - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. - labels: - lagoon.type: cli-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.name: nginx-php - lagoon.persistent.size: 5Gi - - nginx: - build: - context: . - dockerfile: .docker/Dockerfile.nginx-drupal - args: - CLI_IMAGE: *project - EXAMPLE_IMAGE_VERSION: *example-image-version - << : *default-volumes - environment: - << : *default-environment - depends_on: - - cli - networks: - - amazeeio-network - - default - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.size: 5Gi - lagoon.name: nginx-php - expose: - - "8080" - php: - build: - context: . - dockerfile: .docker/Dockerfile.php - args: - CLI_IMAGE: *project - EXAMPLE_IMAGE_VERSION: *example-image-version - environment: - << : *default-environment - << : *default-volumes - depends_on: - - cli - labels: - lagoon.type: nginx-php-persistent - lagoon.persistent: /app/docroot/sites/default/files/ - lagoon.persistent.size: 5Gi - lagoon.name: nginx-php - - mariadb: - image: amazeeio/mariadb-drupal - environment: - << : *default-environment - ports: - - "3306" # Find port on host with `ahoy info` or `docker-compose port mariadb 3306` - labels: - lagoon.type: mariadb-shared - - redis: - image: amazeeio/redis - labels: - lagoon.type: redis - - elasticsearch: - build: - context: . - dockerfile: .docker/Dockerfile.elasticsearch - args: - - ES_TPL=${ES_TPL:-elasticsearch.yml} - environment: - - discovery.type=single-node - labels: - lagoon.type: none - - chrome: - image: selenium/standalone-chrome:3.141.59-oxygen - shm_size: '1gb' - environment: - << : *default-environment - << : *default-volumes - depends_on: - - cli - labels: - lagoon.type: none - - clamav: - image: clamav/clamav:${EXAMPLE_IMAGE_VERSION:-4.x} - environment: - << : *default-environment - ports: - - "3310" - labels: - lagoon.type: none - - -networks: - amazeeio-network: - external: true - -volumes: - app: {} - files: {} \ No newline at end of file diff --git a/test-resources/template-ingress/test12/docker-compose.yml b/test-resources/template-ingress/test12/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test12/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test12/lagoon.yml b/test-resources/template-ingress/test12/lagoon.yml deleted file mode 100644 index 6e937dd6..00000000 --- a/test-resources/template-ingress/test12/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test12/docker-compose.yml - -environment_variables: - git_sha: "true" - -# environments: -# main: -# routes: -# - node: -# - example.com diff --git a/test-resources/template-ingress/test13/docker-compose.yml b/test-resources/template-ingress/test13/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test13/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test13/lagoon.yml b/test-resources/template-ingress/test13/lagoon.yml deleted file mode 100644 index 739440a7..00000000 --- a/test-resources/template-ingress/test13/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test13/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test14/docker-compose.yml b/test-resources/template-ingress/test14/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test14/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test14/lagoon.yml b/test-resources/template-ingress/test14/lagoon.yml deleted file mode 100644 index cd57b8ab..00000000 --- a/test-resources/template-ingress/test14/lagoon.yml +++ /dev/null @@ -1,11 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test14/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com: - ingressClass: "custom-ingress" diff --git a/test-resources/template-ingress/test15/docker-compose.yml b/test-resources/template-ingress/test15/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test15/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test15/lagoon.yml b/test-resources/template-ingress/test15/lagoon.yml deleted file mode 100644 index 96757f31..00000000 --- a/test-resources/template-ingress/test15/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test15/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test16/docker-compose.yml b/test-resources/template-ingress/test16/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test16/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test16/lagoon.yml b/test-resources/template-ingress/test16/lagoon.yml deleted file mode 100644 index 060dcbd9..00000000 --- a/test-resources/template-ingress/test16/lagoon.yml +++ /dev/null @@ -1,12 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test16/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com: - hstsEnabled: true - hstsMaxAge: 10000 diff --git a/test-resources/template-ingress/test17/docker-compose.yml b/test-resources/template-ingress/test17/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test17/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test17/lagoon.yml b/test-resources/template-ingress/test17/lagoon.yml deleted file mode 100644 index 827de650..00000000 --- a/test-resources/template-ingress/test17/lagoon.yml +++ /dev/null @@ -1,14 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test17/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com: - hstsEnabled: true - hstsMaxAge: 10000 - hstsIncludeSubdomains: true - hstsPreload: true diff --git a/test-resources/template-ingress/test18/docker-compose.yml b/test-resources/template-ingress/test18/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test18/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test18/lagoon.yml b/test-resources/template-ingress/test18/lagoon.yml deleted file mode 100644 index 19608662..00000000 --- a/test-resources/template-ingress/test18/lagoon.yml +++ /dev/null @@ -1,11 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test18/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com - - www.example.com diff --git a/test-resources/template-ingress/test19/docker-compose.yml b/test-resources/template-ingress/test19/docker-compose.yml deleted file mode 100644 index 4a3c3e66..00000000 --- a/test-resources/template-ingress/test19/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.2' -services: - node: - build: - context: . - dockerfile: Dockerfile - labels: - lagoon.type: node - nginx: - build: - context: . - dockerfile: .nginx/Dockerfile - labels: - lagoon.type: nginx \ No newline at end of file diff --git a/test-resources/template-ingress/test19/lagoon.yml b/test-resources/template-ingress/test19/lagoon.yml deleted file mode 100644 index 086ef776..00000000 --- a/test-resources/template-ingress/test19/lagoon.yml +++ /dev/null @@ -1,22 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test19/docker-compose.yml - -environment_variables: - git_sha: 'true' - -tasks: - post-rollout: - - run: - name: Call - command: node /app/.lagoon/run-post.js || true - service: node - -environments: - develop: - routes: - - nginx: - - develop.example.com - - app.develop.example.com - pr-4841: - routes: - - nginx: - - performance.example.com diff --git a/test-resources/template-ingress/test2/docker-compose.yml b/test-resources/template-ingress/test2/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test2/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test2/lagoon.yml b/test-resources/template-ingress/test2/lagoon.yml deleted file mode 100644 index 472999ad..00000000 --- a/test-resources/template-ingress/test2/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test2/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test20/docker-compose.yml b/test-resources/template-ingress/test20/docker-compose.yml deleted file mode 100644 index 4a3c3e66..00000000 --- a/test-resources/template-ingress/test20/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.2' -services: - node: - build: - context: . - dockerfile: Dockerfile - labels: - lagoon.type: node - nginx: - build: - context: . - dockerfile: .nginx/Dockerfile - labels: - lagoon.type: nginx \ No newline at end of file diff --git a/test-resources/template-ingress/test21/docker-compose.yml b/test-resources/template-ingress/test21/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test21/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test21/lagoon.yml b/test-resources/template-ingress/test21/lagoon.yml deleted file mode 100644 index cb50c4cc..00000000 --- a/test-resources/template-ingress/test21/lagoon.yml +++ /dev/null @@ -1,13 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test21/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com: - alternativenames: - - www.example.com - - en.example.com diff --git a/test-resources/template-ingress/test22/docker-compose.yml b/test-resources/template-ingress/test22/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test22/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test22/lagoon.yml b/test-resources/template-ingress/test22/lagoon.yml deleted file mode 100644 index 9f44e4c6..00000000 --- a/test-resources/template-ingress/test22/lagoon.yml +++ /dev/null @@ -1,12 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test22/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com: - tls-acme: false - wildcard: true diff --git a/test-resources/template-ingress/test3/docker-compose.yml b/test-resources/template-ingress/test3/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test3/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test3/lagoon.yml b/test-resources/template-ingress/test3/lagoon.yml deleted file mode 100644 index 0667e9a2..00000000 --- a/test-resources/template-ingress/test3/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test3/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test4/docker-compose.yml b/test-resources/template-ingress/test4/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test4/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test4/lagoon.yml b/test-resources/template-ingress/test4/lagoon.yml deleted file mode 100644 index df98473b..00000000 --- a/test-resources/template-ingress/test4/lagoon.yml +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test4/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com diff --git a/test-resources/template-ingress/test5/docker-compose.yml b/test-resources/template-ingress/test5/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test5/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test5/lagoon.yml b/test-resources/template-ingress/test5/lagoon.yml deleted file mode 100644 index 82dd632f..00000000 --- a/test-resources/template-ingress/test5/lagoon.yml +++ /dev/null @@ -1,17 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test5/docker-compose.yml - -environment_variables: - git_sha: "true" - -multiproject1: - environments: - multiproject: - routes: - - node: - - multiproject1.com -multiproject2: - environments: - multiproject: - routes: - - node: - - multiproject2.com diff --git a/test-resources/template-ingress/test6/docker-compose.yml b/test-resources/template-ingress/test6/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test6/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test6/lagoon.yml b/test-resources/template-ingress/test6/lagoon.yml deleted file mode 100644 index da8476d1..00000000 --- a/test-resources/template-ingress/test6/lagoon.yml +++ /dev/null @@ -1,17 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test6/docker-compose.yml - -environment_variables: - git_sha: "true" - -multiproject1: - environments: - multiproject: - routes: - - node: - - multiproject1.com -multiproject2: - environments: - multiproject: - routes: - - node: - - multiproject2.com diff --git a/test-resources/template-ingress/test7/docker-compose.yml b/test-resources/template-ingress/test7/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test7/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test7/lagoon.yml b/test-resources/template-ingress/test7/lagoon.yml deleted file mode 100644 index a1aaed78..00000000 --- a/test-resources/template-ingress/test7/lagoon.yml +++ /dev/null @@ -1,11 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test7/docker-compose.yml - -environment_variables: - git_sha: "true" - -environments: - main: - routes: - - node: - - example.com - - www.example.com diff --git a/test-resources/template-ingress/test8/docker-compose.yml b/test-resources/template-ingress/test8/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test8/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file diff --git a/test-resources/template-ingress/test8/lagoon.yml b/test-resources/template-ingress/test8/lagoon.yml deleted file mode 100644 index 1065916a..00000000 --- a/test-resources/template-ingress/test8/lagoon.yml +++ /dev/null @@ -1,8 +0,0 @@ -docker-compose-yaml: ../test-resources/template-ingress/test8/docker-compose.yml - -environments: - branch/routes: - routes: - - node: - - customdomain-will-be-main-domain.com - - customdomain-will-be-not-be-main-domain.com diff --git a/test-resources/template-ingress/test9/docker-compose.yml b/test-resources/template-ingress/test9/docker-compose.yml deleted file mode 100644 index 85386270..00000000 --- a/test-resources/template-ingress/test9/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '2' -services: - node: - networks: - - amazeeio-network - - default - build: - context: . - dockerfile: node.dockerfile - labels: - lagoon.type: node - volumes: - - .:/app:delegated - environment: - - LAGOON_LOCALDEV_HTTP_PORT=3000 - - LAGOON_ROUTE=http://node.docker.amazee.io - -networks: - amazeeio-network: - external: true \ No newline at end of file