@@ -639,3 +639,41 @@ port-forwards: pf-keycloak pf-api pf-ssh pf-ui
639
639
.PHONY : run-tests
640
640
run-tests :
641
641
$(HELM ) test --namespace lagoon-core --timeout 30m lagoon-test
642
+
643
+ # kind/seed-data is a way to seed a lagoon-core
644
+ # CORE_APP_VERSION_OR_TREEISH = heads/main
645
+ CORE_APP_VERSION_OR_TREEISH = heads/remove-data-watcher-pusher
646
+
647
+ .PHONY : kind/seed-data
648
+ kind/seed-data : install-lagoon
649
+ ifeq (,$(subst ",,$(CORE_APP_VERSION_OR_TREEISH ) ) )
650
+ $(eval CORE_APP_VERSION_OR_TREEISH = tags/$(shell $(HELM) search repo lagoon/lagoon-core -o json | $(JQ) -r '.[]|.app_version'))
651
+ endif
652
+ @echo "Loading API seed data" && \
653
+ export LAGOON_LEGACY_ADMIN=$$(docker run \
654
+ -e JWTSECRET="$$($(KUBECTL) get secret -n lagoon-core lagoon-core-secrets -o jsonpath="{.data.JWTSECRET}" | base64 --decode)" \
655
+ -e JWTAUDIENCE=api.dev \
656
+ -e JWTUSER=localadmin \
657
+ uselagoon/tests \
658
+ python3 /ansible/tasks/api/admin_token.py) && \
659
+ export SSH_PORTAL_HOST="$$($(KUBECTL) -n lagoon get services lagoon-remote-ssh-portal -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" && \
660
+ export SSH_PORTAL_PORT="$$($(KUBECTL) -n lagoon get services lagoon-remote-ssh-portal -o jsonpath='{.spec.ports[0].port}')" && \
661
+ export CONSOLE_URL="https://kubernetes.default.svc/" && \
662
+ export KUBERNETES_TOKEN="$$($(KUBECTL) get secret -n lagoon lagoon-remote-ssh-core-token -o jsonpath="{.data.token}" | base64 --decode)" && \
663
+ export ROUTER_PATTERN="\$${project}.\$${environment}.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" && \
664
+ curl -sSLo /tmp/seed.gql https://raw.githubusercontent.com/uselagoon/lagoon/refs/$(CORE_APP_VERSION_OR_TREEISH)/local-dev/seed-data/00-populate-kubernetes.gql && \
665
+ export SEED_DATA=$$(envsubst < /tmp/seed.gql | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g' | awk -F'\n' '{if(NR == 1) {printf $$0} else {printf "\\n"$$0}}') && \
666
+ export SEED_DATA_JSON="{\"query\": \"$$SEED_DATA\"}" && \
667
+ wget --quiet --header "Content-Type : application/json" --header "Authorization: bearer $${LAGOON_LEGACY_ADMIN}" "http://lagoon-api.$$($(KUBECTL ) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}') .nip.io/graphql" --post-data "$$SEED_DATA_JSON" --content-on-error -O - && \
668
+ echo " Loading API seed users" && \
669
+ curl -sSLo /tmp/seed-users.sh https://raw.githubusercontent.com/uselagoon/lagoon/refs/$(CORE_APP_VERSION_OR_TREEISH ) /local-dev/seed-data/seed-users.sh && \
670
+ cat /tmp/seed-users.sh \
671
+ | $(KUBECTL ) -n lagoon-core exec -i $$($(KUBECTL ) -n lagoon-core get pods \
672
+ -l app.kubernetes.io/component=lagoon-core-keycloak -o json | $(JQ ) -r ' .items[0].metadata.name' ) -- sh -c " cat > /tmp/seed-users.sh" && \
673
+ $(KUBECTL ) -n lagoon-core exec -it $$($(KUBECTL ) -n lagoon-core get pods -l app.kubernetes.io/component=lagoon-core-keycloak -o json | $(JQ ) -r '.items[0].metadata.name') -- bash ' /tmp/seed-users.sh' \
674
+ && echo " You will be able to log in with these seed user email addresses and the passwords will be the same as the email address" \
675
+ && echo " eg. [email protected] has the password [email protected] " \
676
+ && echo " " \
677
+ && echo " If you want to create an example SSO identity provider and example user, run make k3d/example-sso" \
678
+ && echo " If you want to configure simple webauthn browswer flow, run make k3d/configure-webauthn" \
679
+ && echo " "
0 commit comments