From 4fd9fc62212f2a4dd760cacbc5d984a43fd557f6 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 17:26:28 -0500 Subject: [PATCH 01/38] fix: update delete_post endpoint to include db dependency and add initial tests for main route --- papi.py | 4 ++-- test_papi.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test_papi.py diff --git a/papi.py b/papi.py index bda569c..3b4fbd9 100644 --- a/papi.py +++ b/papi.py @@ -92,8 +92,8 @@ async def update_post(id: str, post: dict,db: Session = Depends(get_db)): db.refresh(db_post) return {"message":"Post updated successfully","post":db_post} -@app.delete("/posts/{id}",db: Session = Depends(get_db)) -async def delete_post(id: str, post: dict): +@app.delete("/posts/{id}") +async def delete_post(id: str, post: dict,db: Session = Depends(get_db)): db_post = db.query(Post).filter(Post.id == id).first() db.delete(db_post) db.commit() diff --git a/test_papi.py b/test_papi.py new file mode 100644 index 0000000..a244f7d --- /dev/null +++ b/test_papi.py @@ -0,0 +1,12 @@ +#!/bin/env python3 + +from fastapi.testclient import TestClient + +import papi +client = TestClient(papi) + + +def test_read_main(): + response = client.get("/") + assert response.status_code == 200 + assert response.json() == {"message": "Hello World"} \ No newline at end of file -- 2.43.0 From dfacc384d580d0eef74c4cd3bfdbbe1983b77a19 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:41:36 -0500 Subject: [PATCH 02/38] feat: add deployment step to build and push workflow using Helm --- .gitea/workflows/build-and-push.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 3db58d9..975367c 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -26,4 +26,12 @@ jobs: - run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image + - name: 'Deploy' + uses: deliverybot/helm@v1 + with: + release: 'nginx' + namespace: 'default' + chart: 'papi-helm' + env: + KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' -- 2.43.0 From e9c88d14ceb496cbf82444c64d8b7bc5a1c1768a Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:44:22 -0500 Subject: [PATCH 03/38] feat: add helm upgrade command to build and push workflow for deployment --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 975367c..ebac294 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -34,4 +34,4 @@ jobs: chart: 'papi-helm' env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - + run: helm upgrade papi ./papi-helm/ --install --namespace default --set image.tag=${{ steps.extract_branch.outputs.branch }} --kubeconfig $KUBECONFIG_FILE -- 2.43.0 From 81a48930960c384a92111989f4aaf9d9fd4c66a9 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:47:51 -0500 Subject: [PATCH 04/38] fix: remove redundant Helm action from build and push workflow --- .gitea/workflows/build-and-push.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index ebac294..ed5643e 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -27,11 +27,6 @@ jobs: - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - name: 'Deploy' - uses: deliverybot/helm@v1 - with: - release: 'nginx' - namespace: 'default' - chart: 'papi-helm' env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' run: helm upgrade papi ./papi-helm/ --install --namespace default --set image.tag=${{ steps.extract_branch.outputs.branch }} --kubeconfig $KUBECONFIG_FILE -- 2.43.0 From ecd679cbf469d56a921d698f3dc91343857c095b Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:53:52 -0500 Subject: [PATCH 05/38] feat: update build and push workflow to use Helm for deployment --- .gitea/workflows/build-and-push.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index ed5643e..069232c 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -27,6 +27,12 @@ jobs: - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - name: 'Deploy' + uses: deliverybot/helm@v1 + with: + release: 'papi' + namespace: 'default' + chart: 'papi-helm/Chart.yaml' + token: '${{ github.token }}' + value-files: ['papi-helm/values.yaml'] env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: helm upgrade papi ./papi-helm/ --install --namespace default --set image.tag=${{ steps.extract_branch.outputs.branch }} --kubeconfig $KUBECONFIG_FILE -- 2.43.0 From 5139e277a43bea97ed5d69bd67f84c748fb4d4bb Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:56:06 -0500 Subject: [PATCH 06/38] fix: remove unnecessary blank line in build and push workflow configuration --- .gitea/workflows/build-and-push.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 069232c..acb115e 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -13,7 +13,6 @@ on: - qa - jobs: build: runs-on: ubuntu-latest -- 2.43.0 From 9a17f836108dc0b36a9333882ed8d6adf1b6521e Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:56:56 -0500 Subject: [PATCH 07/38] fix: rename workflow to Build and Push to Private Registry2 --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index acb115e..e1a6ee5 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry +name: Build and Push to Private Registry2 on: -- 2.43.0 From f9c7e45dbdc744cadfeb05773e718192b29e9cf0 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 20:58:30 -0500 Subject: [PATCH 08/38] fix: rename workflow to Build and Push to Private Registry3 --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index e1a6ee5..0a87a7f 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry2 +name: Build and Push to Private Registry3 on: -- 2.43.0 From 5589fc3a755d528bfb14771d0c6bbe25c0dceb52 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:02:52 -0500 Subject: [PATCH 09/38] fix: rename workflow to Build and Push to Private Registry and update Helm deployment action --- .gitea/workflows/build-and-push.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 0a87a7f..d5045c7 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry3 +name: Build and Push to Private Registry on: @@ -13,6 +13,7 @@ on: - qa + jobs: build: runs-on: ubuntu-latest @@ -26,12 +27,12 @@ jobs: - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - name: 'Deploy' - uses: deliverybot/helm@v1 + uses: 'peter-evans/k8s-deploy@v1' with: release: 'papi' namespace: 'default' chart: 'papi-helm/Chart.yaml' - token: '${{ github.token }}' - value-files: ['papi-helm/values.yaml'] + values: 'papi-helm/values.yaml' env: - KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' + KUBECONFIG_FILE: '${{ secrets.KUBECONFIG}}' + -- 2.43.0 From 8c8bc5f30e727df42d5e0e3a0b519684626b7e58 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:07:03 -0500 Subject: [PATCH 10/38] feat: update deployment process to use Helm for chart installation --- .gitea/workflows/build-and-push.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index d5045c7..b8312c2 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -26,13 +26,7 @@ jobs: - run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - - name: 'Deploy' - uses: 'peter-evans/k8s-deploy@v1' - with: - release: 'papi' - namespace: 'default' - chart: 'papi-helm/Chart.yaml' - values: 'papi-helm/values.yaml' - env: + - env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG}}' + run: curl https://fairfaxmedia.net/helm -O /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 2ab68111d5e39f83e7d54c7ef2d42961b61dd6cb Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:07:57 -0500 Subject: [PATCH 11/38] fix: remove redundant Helm deployment step from build and push workflow --- .gitea/workflows/build-and-push.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index b8312c2..d54cc5e 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -25,8 +25,4 @@ jobs: - uses: actions/checkout@v3 - run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - - env: - KUBECONFIG_FILE: '${{ secrets.KUBECONFIG}}' - run: curl https://fairfaxmedia.net/helm -O /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char - + - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image \ No newline at end of file -- 2.43.0 From 45f32222b778b562027a5c467ac39ed04742b110 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:08:33 -0500 Subject: [PATCH 12/38] feat: add Helm deployment step to build and push workflow --- .gitea/workflows/build-and-push.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index d54cc5e..cc37330 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -25,4 +25,8 @@ jobs: - uses: actions/checkout@v3 - run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image \ No newline at end of file + - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image + - env: + KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' + run: curl https://fairfaxmedia.net/helm -O /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + -- 2.43.0 From 142e4736cad3745b7a032f693c9eecc35c7664aa Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:09:42 -0500 Subject: [PATCH 13/38] fix: correct curl command option for Helm installation in build and push workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index cc37330..d42eab3 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,5 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -O /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From d13d06b1f9dfd6d446795f353a538b96b452fefd Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:10:56 -0500 Subject: [PATCH 14/38] fix: add kubeconfig option to Helm upgrade command in build and push workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index d42eab3..96d84f9 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,5 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} --kubeconfig $KUBECONFIG # Deploy the Helm char -- 2.43.0 From d32800f71866006339a89e75e92fd9977eac6fb7 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:13:48 -0500 Subject: [PATCH 15/38] fix: reorder kubeconfig option in Helm upgrade command in build and push workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 96d84f9..4819b67 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,5 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} --kubeconfig $KUBECONFIG # Deploy the Helm char + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm --kubeconfig $KUBECONFIG upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 22ad8be19ddfd38e063631aa2eb6b8bb1ca3e473 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:14:35 -0500 Subject: [PATCH 16/38] fix: update KUBECONFIG variable reference in Helm upgrade command in build and push workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 4819b67..78b61f1 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,5 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm --kubeconfig $KUBECONFIG upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm --kubeconfig $KUBECONFIG_FILE upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From c6ccb18c4f27b83a2bd75b7e660c67697a9cba0f Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:25:59 -0500 Subject: [PATCH 17/38] fix: update KUBECONFIG variable and streamline Helm upgrade command in build and push workflow --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 78b61f1..f252f17 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -27,6 +27,6 @@ jobs: - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: - KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm --kubeconfig $KUBECONFIG_FILE upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + KUBECONFIG: '${{ secrets.KUBECONFIG }}' + run: echo "curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 48a4c2d13f15689b7d83c79ff1100bdb72b28b78 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:26:45 -0500 Subject: [PATCH 18/38] fix: remove unnecessary echo command in Helm upgrade step of build and push workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index f252f17..3eefd30 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,5 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo "curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From d6a886f9ab7ba5d6dff4fc2561a095ea9b2e457b Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:27:33 -0500 Subject: [PATCH 19/38] fix: comment out Helm upgrade command for debugging in build and push workflow --- .gitea/workflows/build-and-push.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 3eefd30..e9fa517 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,5 +28,6 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: ls -lh /run/secrets + #run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From c2317b07765f5087076dbf0194526403829f92f0 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:29:02 -0500 Subject: [PATCH 20/38] fix: add descriptive names to Docker registry steps in build and push workflow --- .gitea/workflows/build-and-push.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index e9fa517..cd4f42a 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -24,10 +24,13 @@ jobs: id: extract_branch - uses: actions/checkout@v3 - run: docker login kube-reg.fairfaxmedia.net -u docker -p ${{ secrets.DOCK_REG_AUTH }} # Login to private registry + name: Login to private registry - run: docker build -t kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} . # Build the Docker image + name: Build Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image + name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: ls -lh /run/secrets + run: sleep 1800 #run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From f12c4bbde420429b0eef346c522982c6f3ed6562 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:38:53 -0500 Subject: [PATCH 21/38] fix: update Helm installation steps and adjust KUBECONFIG handling in build and push workflow --- .gitea/workflows/build-and-push.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index cd4f42a..43176e8 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -31,6 +31,8 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: sleep 1800 - #run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: echo $KUBECONFIG > /run/secrets/kubeconfig + #run: sleep 1800 + run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm + run: /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 2f0a4a49d38739310a40cf8b5e136edbb530c490 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:39:48 -0500 Subject: [PATCH 22/38] fix: correct workflow name in build and push configuration --- .gitea/workflows/build-and-push.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 43176e8..b9b7247 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry +name: Build and Push to Private Registry4 on: @@ -36,3 +36,4 @@ jobs: run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm run: /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + -- 2.43.0 From 45e431e84074da3c45ece02ac5724d3ec53e5cd8 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:40:17 -0500 Subject: [PATCH 23/38] fix: correct workflow name in build and push configuration --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index b9b7247..dd09d65 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry4 +name: Build and Push to Private Registry on: -- 2.43.0 From 3eb4cdb90cf3fefdadb11e39985f1df8502e68a1 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:42:03 -0500 Subject: [PATCH 24/38] fix: update workflow name in build and push configuration --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index dd09d65..136fe05 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry +name: Build and Push to Private Registry5 on: -- 2.43.0 From 313ec0eb83130eae2b1830cf94536ad719dfbd8a Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:44:25 -0500 Subject: [PATCH 25/38] fix: update workflow name in build and push configuration --- .gitea/workflows/build-and-push.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 136fe05..817a4ba 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,8 +2,7 @@ -name: Build and Push to Private Registry5 - +name: Build and Push to Private Registry11 on: push: -- 2.43.0 From 90d40025e2208d6b2716e81c5bf148e20fd74527 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:46:33 -0500 Subject: [PATCH 26/38] fix: streamline Helm installation and deployment commands in build and push workflow --- .gitea/workflows/build-and-push.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 817a4ba..00bf49c 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,9 +30,8 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > /run/secrets/kubeconfig - #run: sleep 1800 - run: curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm - run: /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + run: echo $KUBECONFIG > /run/secrets/kubeconfig && \ + curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && \ + /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From f6341b42d7ea2a3cdce1f8e252806d99d7daa69f Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:47:18 -0500 Subject: [PATCH 27/38] fix: update workflow name in build and push configuration --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 00bf49c..5a26482 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -2,7 +2,7 @@ -name: Build and Push to Private Registry11 +name: Build and Push to Private Registry101 on: push: -- 2.43.0 From 869d00dbc3a88ae562f92653729abe40acd92662 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:48:18 -0500 Subject: [PATCH 28/38] fix: update kubeconfig path in Helm deployment commands --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 5a26482..2be7395 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,8 +30,8 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > /run/secrets/kubeconfig && \ + run: echo $KUBECONFIG > /tmp/kubeconfig && \ curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && \ - /usr/local/bin/helm upgrade --kubeconfig /run/secrets/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + /usr/local/bin/helm upgrade --kubeconfig /tmp/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From d96799e32a2ecdf6dcd99f42d45a01669363b348 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:49:07 -0500 Subject: [PATCH 29/38] fix: format Helm deployment command for better readability --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 2be7395..24b0e55 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,8 +30,8 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > /tmp/kubeconfig && \ - curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && \ + run: echo $KUBECONFIG > /tmp/kubeconfig && + curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --kubeconfig /tmp/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 70b282c14f79840d299b295a57d9e883e919a83d Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:50:21 -0500 Subject: [PATCH 30/38] fix: update kubeconfig path and streamline Helm upgrade command in build workflow --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 24b0e55..7489bd1 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,8 +30,8 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > /tmp/kubeconfig && + run: echo $KUBECONFIG > .kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && - /usr/local/bin/helm upgrade --kubeconfig /tmp/kubeconfig --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 035bf6c5192f1ad63ec4d2bb00f79d05cc32f4e1 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:51:06 -0500 Subject: [PATCH 31/38] fix: update kubeconfig path in build workflow to use HOME directory --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 7489bd1..0a1cfbe 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,7 +30,7 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > .kube/config && + run: echo $KUBECONFIG > $HOME/.kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 6905e3528cbcb3ae81382d68251d1c4599050618 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:51:43 -0500 Subject: [PATCH 32/38] fix: ensure .kube directory exists before writing kubeconfig in build workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 0a1cfbe..2238e11 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -30,7 +30,7 @@ jobs: name: Push Docker image - env: KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: echo $KUBECONFIG > $HOME/.kube/config && + run: mkdir -p $HOME/.kube &&echo $KUBECONFIG > $HOME/.kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 4a2f612192f42ef12969337e30dd476000c74da5 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:54:56 -0500 Subject: [PATCH 33/38] fix: update KUBECONFIG to use base64 encoded value in build workflow --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 2238e11..17dfa0f 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -29,8 +29,8 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image name: Push Docker image - env: - KUBECONFIG: '${{ secrets.KUBECONFIG }}' - run: mkdir -p $HOME/.kube &&echo $KUBECONFIG > $HOME/.kube/config && + KUBECONFIG: '${{ secrets.KUBEB64 }}' + run: mkdir -p $HOME/.kube &&echo "$KUBECONFIG" | base64 -d > $HOME/.kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char -- 2.43.0 From 5e1416c0b8880e7b0f2157b45a73edf37ebc1067 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:56:21 -0500 Subject: [PATCH 34/38] fix: correct typo in Helm upgrade command comment in build workflow --- .gitea/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 17dfa0f..48db5cb 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -32,6 +32,6 @@ jobs: KUBECONFIG: '${{ secrets.KUBEB64 }}' run: mkdir -p $HOME/.kube &&echo "$KUBECONFIG" | base64 -d > $HOME/.kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && - /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm char + /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm chart -- 2.43.0 From 53524eed52fb24fb0ef85855687307ce0e40d136 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 21:57:08 -0500 Subject: [PATCH 35/38] fix: update environment variable name for base64 KUBECONFIG in build workflow --- .gitea/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 48db5cb..c99725e 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -29,8 +29,8 @@ jobs: - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image name: Push Docker image - env: - KUBECONFIG: '${{ secrets.KUBEB64 }}' - run: mkdir -p $HOME/.kube &&echo "$KUBECONFIG" | base64 -d > $HOME/.kube/config && + KUBEB64: '${{ secrets.KUBEB64 }}' + run: mkdir -p $HOME/.kube &&echo "$KUBEB64" | base64 -d > $HOME/.kube/config && curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm chart -- 2.43.0 From d4b5752a1e47e260094acd16624a3a542adc6fcb Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 22:03:13 -0500 Subject: [PATCH 36/38] fix: comment out Helm upgrade command in build workflow --- .gitea/workflows/build-and-push.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index c99725e..b29285e 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -28,10 +28,10 @@ jobs: name: Build Docker image - run: docker push kube-reg.fairfaxmedia.net/papi/svc1:${{ steps.extract_branch.outputs.branch }} # Push the Docker image name: Push Docker image - - env: - KUBEB64: '${{ secrets.KUBEB64 }}' - run: mkdir -p $HOME/.kube &&echo "$KUBEB64" | base64 -d > $HOME/.kube/config && - curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && - /usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm chart + #- env: + #KUBEB64: '${{ secrets.KUBEB64 }}' + #run: mkdir -p $HOME/.kube &&echo "$KUBEB64" | base64 -d > $HOME/.kube/config && + #curl https://fairfaxmedia.net/helm -o /usr/local/bin/helm && chmod +xxx /usr/local/bin/helm && + #/usr/local/bin/helm upgrade --install papi papi-helm/ --set image.tag=${{ steps.extract_branch.outputs.branch }} # Deploy the Helm chart -- 2.43.0 From eca4c72c0a306ababd0b8933506ce2d5c5a9022d Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Sun, 16 Feb 2025 22:16:14 -0500 Subject: [PATCH 37/38] feat: refactor build and deployment scripts; update service type to ClusterIP and add ingress configurations --- build.sh | 9 --------- deploy.dev.sh | 2 ++ papi-helm/v.dev.yaml | 7 +++++++ papi-helm/v.prod.yaml | 11 +++++++++++ papi-helm/v.qa.yaml | 7 +++++++ papi-helm/values.yaml | 12 +----------- 6 files changed, 28 insertions(+), 20 deletions(-) delete mode 100644 build.sh create mode 100644 deploy.dev.sh create mode 100644 papi-helm/v.dev.yaml create mode 100644 papi-helm/v.prod.yaml create mode 100644 papi-helm/v.qa.yaml diff --git a/build.sh b/build.sh deleted file mode 100644 index 8f2d93b..0000000 --- a/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -REG=192.168.1.134:5000 -NS=papi -IMG=svc1 -TAG=dev -DIMG=${REG}/${NS}/${IMG}:${TAG} -docker build -f Dockerfile -t ${DIMG} . - -docker push ${DIMG} \ No newline at end of file diff --git a/deploy.dev.sh b/deploy.dev.sh new file mode 100644 index 0000000..1c4056c --- /dev/null +++ b/deploy.dev.sh @@ -0,0 +1,2 @@ +#!/bin/bash +helm upgrade papi ./papi-helm/ -f ./papi-helm/v.dev.yaml diff --git a/papi-helm/v.dev.yaml b/papi-helm/v.dev.yaml new file mode 100644 index 0000000..bae8507 --- /dev/null +++ b/papi-helm/v.dev.yaml @@ -0,0 +1,7 @@ +ingress: + enabled: true + hosts: + - host: papi.kube-dev.fairfaxmedia.net + paths: + - path: / + pathType: ImplementationSpecific \ No newline at end of file diff --git a/papi-helm/v.prod.yaml b/papi-helm/v.prod.yaml new file mode 100644 index 0000000..e5a0d41 --- /dev/null +++ b/papi-helm/v.prod.yaml @@ -0,0 +1,11 @@ +ingress: + enabled: true + hosts: + - host: papi.fairfaxmedia.net + paths: + - path: / + pathType: ImplementationSpecific + - host: papi.kube.fairfaxmedia.net + paths: + - path: / + pathType: ImplementationSpecific \ No newline at end of file diff --git a/papi-helm/v.qa.yaml b/papi-helm/v.qa.yaml new file mode 100644 index 0000000..5c76701 --- /dev/null +++ b/papi-helm/v.qa.yaml @@ -0,0 +1,7 @@ +ingress: + enabled: true + hosts: + - host: papi.kube-qa.fairfaxmedia.net + paths: + - path: / + pathType: ImplementationSpecific \ No newline at end of file diff --git a/papi-helm/values.yaml b/papi-helm/values.yaml index 4213baf..ac886a9 100644 --- a/papi-helm/values.yaml +++ b/papi-helm/values.yaml @@ -52,7 +52,7 @@ securityContext: {} # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ service: # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types - type: NodePort + type: ClusterIP # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports port: 8912 @@ -63,16 +63,6 @@ ingress: annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - hosts: - - host: papi.fairfaxmedia.net - paths: - - path: / - pathType: ImplementationSpecific - - - host: papi.kube-dev.fairfaxmedia.net - paths: - - path: / - pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: -- 2.43.0 From b3e3d4a6a1d82002f3448e0ae286e8a121f11c66 Mon Sep 17 00:00:00 2001 From: stephen schuresko Date: Mon, 17 Feb 2025 14:26:17 -0500 Subject: [PATCH 38/38] feat: implement CRUD operations for users and posts; add tests and coverage reporting --- .gitignore | 3 ++ Makefile | 19 ++++++++++ hopscotch_collection.json | 1 + papi.py | 42 ++++++++++++++++------ test_papi.py | 73 +++++++++++++++++++++++++++++++++++++-- 5 files changed, 124 insertions(+), 14 deletions(-) create mode 100644 Makefile create mode 100644 hopscotch_collection.json diff --git a/.gitignore b/.gitignore index 597be97..391f3a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ __pycache__ test.db +.coverage +report.xml +coverage.xml \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8b9a1f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +ENV=dev +VER=2 +TAG=${ENV}-${VER} +REGISTRY=kube-reg.fairfaxmedia.net +SVC=papi/svc1 +DOCK_IMG=${REGISTRY}/${SVC}:${TAG} +clean: + rm -rf .pytest_cache + rm -rf .coverage + rm -rf report.xml + rm -rf test.db +coverage: clean + pytest --cov=papi test_papi.py --junitxml=report.xml --cov-report=html --cov-report=xml --cov-report=term --cov-fail-under 90 +docker-img: coverage + docker build -t ${DOCK_IMG} . +docker-push: docker-img + docker push ${DOCK_IMG} +deploy: docker-push + helm upgrade papi ./papi-helm/ -f ./papi-helm/v.${ENV}.yaml --set image.tag=${TAG} \ No newline at end of file diff --git a/hopscotch_collection.json b/hopscotch_collection.json new file mode 100644 index 0000000..42c3ab5 --- /dev/null +++ b/hopscotch_collection.json @@ -0,0 +1 @@ +{"v":1,"name":"test_assignment","folders":[{"v":1,"name":"users","folders":[],"requests":[{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/users","name":"list_users","params":[],"headers":[],"method":"GET","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":null,"body":null}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/users","name":"create_user","params":[],"headers":[],"method":"POST","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"name\":\"test2\",\n \"email\":\"mynameisdeleted@gmail.com\",\n \"password\":\"pass2\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/users/1","name":"update_user","params":[],"headers":[],"method":"PUT","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"name\":\"new name\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/users/1","name":"delete_user","params":[],"headers":[],"method":"DELETE","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"name\":\"new name\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/users/1","name":"get_user","params":[],"headers":[],"method":"GET","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":null,"body":null}}]},{"v":1,"name":"posts","folders":[],"requests":[{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/posts","name":"list_posts","params":[],"headers":[],"method":"GET","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"name\":\"new name\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/posts","name":"create_post","params":[],"headers":[],"method":"POST","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"title\":\"test title\",\n \"content\":\"testing123\",\n \"author_id\":\"1\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/posts/1","name":"get_post","params":[],"headers":[],"method":"GET","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"name\":\"new name\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/posts/1","name":"update_post","params":[],"headers":[],"method":"PUT","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"title\":\"new title\"\n}"}},{"v":"1","endpoint":"https://papi.kube-dev.fairfaxmedia.net/posts/1","name":"delete_post","params":[],"headers":[],"method":"DELETE","auth":{"authType":"none","authActive":true},"preRequestScript":"","testScript":"","body":{"contentType":"application/json","body":"{\n \"title\":\"new title\"\n}"}}]}],"requests":[]} \ No newline at end of file diff --git a/papi.py b/papi.py index 3b4fbd9..4925f3c 100644 --- a/papi.py +++ b/papi.py @@ -2,9 +2,8 @@ from fastapi import FastAPI, Depends import uvicorn from sqlalchemy import create_engine, Column, Integer,String, ForeignKey -from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.engine import URL -from sqlalchemy.orm import sessionmaker, Session +from sqlalchemy.orm import sessionmaker, Session, declarative_base @@ -30,6 +29,7 @@ class User(Base): email = Column(String, unique=True, index=True) password = Column(String) + class Post(Base): __tablename__ = "posts" id = Column(Integer, primary_key=True, index=True) @@ -50,10 +50,11 @@ async def root(): @app.get("/users") async def get_users(db: Session = Depends(get_db)): return db.query(User).all() - #return [{"id":"asdf1234"}] + @app.get("/users/{id}") -async def get_user(id: str): - return {"id": id} +async def get_user(id: str,db: Session = Depends(get_db)): + db_user = db.query(User).filter(User.id == id).first() + return db_user @app.post("/users") async def create_user(user: dict,db: Session = Depends(get_db)): @@ -64,6 +65,30 @@ async def create_user(user: dict,db: Session = Depends(get_db)): db.refresh(db_user) return {"message":"User created successfully","user":db_user} +@app.put("/users/{id}") +async def update_user(id: str, user: dict,db: Session = Depends(get_db)): + db_user = db.query(User).filter(User.id == id).first() + if "name" in user: + db_user.name = user["name"] + if "email" in user: + db_user.email = user["email"] + if "password" in user: + db_user.password = user["password"] + db.commit() + db.refresh(db_user) + return {"message":"User updated successfully","user":db_user} + + + +@app.delete("/users/{id}") +async def delete_user(id: str, db: Session = Depends(get_db)): + db_user = db.query(User).filter(User.id == id).first() + db.delete(db_user) + db.commit() + return {"message":"User deleted successfully","user":db_user} + + + @app.get("/posts") async def get_posts(db: Session = Depends(get_db)): return db.query(Post).all() @@ -93,18 +118,13 @@ async def update_post(id: str, post: dict,db: Session = Depends(get_db)): return {"message":"Post updated successfully","post":db_post} @app.delete("/posts/{id}") -async def delete_post(id: str, post: dict,db: Session = Depends(get_db)): +async def delete_post(id: str, db: Session = Depends(get_db)): db_post = db.query(Post).filter(Post.id == id).first() db.delete(db_post) db.commit() return {"message":"Post deleted successfully","post":db_post} -@app.get("/hello/{name}") -async def say_hello(name: str): - return {"message": f"Hello {name}"} - - if __name__ == "__main__": uvicorn.run("papi:app", host="0.0.0.0", port=8912, reload=True, log_level="debug", diff --git a/test_papi.py b/test_papi.py index a244f7d..3856a74 100644 --- a/test_papi.py +++ b/test_papi.py @@ -2,11 +2,78 @@ from fastapi.testclient import TestClient -import papi -client = TestClient(papi) +from papi import app +client = TestClient(app) def test_read_main(): response = client.get("/") assert response.status_code == 200 - assert response.json() == {"message": "Hello World"} \ No newline at end of file + assert response.json() == {"message": "Hello World"} + +def test_read_users(): + response = client.get("/users") + assert response.status_code == 200 + assert response.json() == [] + + +def test_create_read_delete_user(): + + response = client.post("/users",json={"name":"test","email":"mynameisdeleted@gmail.com","password":"pass2"}) + assert response.status_code == 200 + user=response.json()['user'] + user_id = str(user['id']) + response = client.get("/users/"+user_id) + assert response.status_code == 200 + assert response.json() == user + + update_response = client.put("/users/"+user_id,json={"name":"updated name"}) + #assert update_respose.status_code == 200 + put_user = update_response.json()['user'] + assert put_user['name'] == "updated name" + + update_response = client.put("/users/"+user_id,json={"email":"updated@gmail.com"}) + + put_user = update_response.json()['user'] + assert put_user['email'] == "updated@gmail.com" + + + response = client.delete("/users/"+user_id) + assert response.status_code == 200 + + response = client.get("/users") + assert response.status_code == 200 + assert response.json() == [] + + + + +def test_create_read_delete_post(): + + + response = client.post("/posts",json={"title":"test title","content":"testing123","author_id":"1"}) + assert response.status_code == 200 + post=response.json()['post'] + post_id = str(post['id']) + response = client.get("/posts/"+post_id) + assert response.status_code == 200 + assert response.json() == post + + update_response = client.put("/posts/"+post_id,json={"title":"test title updated"}) + #assert update_respose.status_code == 200 + put_post = update_response.json()['post'] + assert put_post['title'] == "test title updated" + + + update_response = client.put("/posts/"+post_id,json={"content":"updated content"}) + #assert update_respose.status_code == 200 + put_post = update_response.json()['post'] + assert put_post['title'] == "test title updated" + assert put_post['content'] == "updated content" + + response = client.delete("/posts/"+post_id) + assert response.status_code == 200 + + response = client.get("/posts") + assert response.status_code == 200 + assert response.json() == [] \ No newline at end of file -- 2.43.0