From 1f68b8966d456ce122e0dbb9920d80523470aaff Mon Sep 17 00:00:00 2001 From: Grraahaam <72856427+Grraahaam@users.noreply.github.com> Date: Tue, 10 Jan 2023 14:57:22 +0100 Subject: [PATCH 01/24] fix(front): translation typos --- frontend/public/locales/en/integrations.json | 2 +- frontend/public/locales/en/settings-members.json | 2 +- frontend/public/locales/en/signup.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/public/locales/en/integrations.json b/frontend/public/locales/en/integrations.json index b72f9d87b..1fc92ca4e 100644 --- a/frontend/public/locales/en/integrations.json +++ b/frontend/public/locales/en/integrations.json @@ -4,7 +4,7 @@ "no-integrations1": "You don't have any integrations set up yet. When you do, they will appear here.", "no-integrations2": "To start, click on any of the options below. It takes 5 clicks to set up.", "available": "Platform & Cloud Integrations", - "available-text1": "Click on the itegration you want to connect. This will let your environment variables flow automatically into selected third-party services.", + "available-text1": "Click on the integration you want to connect. This will let your environment variables flow automatically into selected third-party services.", "available-text2": "Note: during an integration with Heroku, for security reasons, it is impossible to maintain end-to-end encryption. In theory, this lets Infisical decrypt yor environment variables. In practice, we can assure you that this will never be done, and it allows us to protect your secrets from bad actors online. The core Infisical service will always stay end-to-end encrypted. With any questions, reach out support@infisical.com.", "cloud-integrations": "Cloud Integrations", "framework-integrations": "Framework Integrations", diff --git a/frontend/public/locales/en/settings-members.json b/frontend/public/locales/en/settings-members.json index 91f4686e7..f0b6e586e 100644 --- a/frontend/public/locales/en/settings-members.json +++ b/frontend/public/locales/en/settings-members.json @@ -1,4 +1,4 @@ { "title": "Project Members", - "description": "This pages shows the members of the selected project." + "description": "This page shows the members of the selected project." } diff --git a/frontend/public/locales/en/signup.json b/frontend/public/locales/en/signup.json index 0fbc92951..0cdbe310b 100644 --- a/frontend/public/locales/en/signup.json +++ b/frontend/public/locales/en/signup.json @@ -1,7 +1,7 @@ { "title": "Sign Up", "og-title": "Replace .env files with 1 line of code. Sign Up for Infisical in 3 minutes.", - "og-description": "Infisical a simple end-to-end encrypted platform that enables teams to sync and manage API-keys and environemntal variables. Works with Node.js, Next.js, Gatsby, Nest.js...", + "og-description": "Infisical a simple end-to-end encrypted platform that enables teams to sync and manage API-keys and environemntal variables. Works with Node.js, Next.js, Gatsby, Nest.js...", "signup": "Sign Up", "already-have-account": "Have an account? Log in", "forgot-password": "Forgot your password?", From 68c3b508e3c002537888819cd8353b0cc4e96c00 Mon Sep 17 00:00:00 2001 From: Grraahaam <72856427+Grraahaam@users.noreply.github.com> Date: Tue, 10 Jan 2023 14:57:37 +0100 Subject: [PATCH 02/24] fix(doc): readme typos --- README.md | 2 +- i18n/README.en.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aaafca43a..2876c6ee8 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,6 @@ Infisical officially launched as v.1.0 on November 21st, 2022. There are a lot o ## ๐ŸŒŽ Translations -Infisical is currently aviable in English and Korean. Help us translate Infisical to your language! +Infisical is currently available in English and Korean. Help us translate Infisical to your language! You can find all the info in [this issue](https://github.com/Infisical/infisical/issues/181). \ No newline at end of file diff --git a/i18n/README.en.md b/i18n/README.en.md index ac2f2a5b5..fb907e302 100644 --- a/i18n/README.en.md +++ b/i18n/README.en.md @@ -325,6 +325,6 @@ Infisical officially launched as v.1.0 on November 21st, 2022. However, a lot of ## ๐ŸŒŽ Translations -Infisical is currently aviable in English and Korean. Help us translate Infisical to your language! +Infisical is currently available in English and Korean. Help us translate Infisical to your language! You can find all the info in [this issue](https://github.com/Infisical/infisical/issues/181). \ No newline at end of file From b1ccb93d8583ca11525a1a3a8db8408152140a61 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 09:19:55 -0500 Subject: [PATCH 03/24] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index db182c24a..4654f6a00 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Push to Docker Hub +name: Push frontend and backend to Dockerhub on: [workflow_dispatch] From d1467348d16068264088ab2c161bd149ffc4fcee Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 09:21:13 -0500 Subject: [PATCH 04/24] Update release_build.yml --- .github/workflows/release_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index da2a29435..df00c5c92 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -1,4 +1,4 @@ -name: Go releaser +name: Build and release CLI on: push: From 5409bdb0cbc03867d1f06acb8d0509875bfb8592 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 10:37:53 -0500 Subject: [PATCH 05/24] Add local cache --- .github/workflows/docker-image.yml | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4654f6a00..ee1dc7d13 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,6 +17,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -28,6 +35,8 @@ jobs: load: true context: backend tags: infisical/backend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: โป Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -45,6 +54,13 @@ jobs: tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest platforms: linux/amd64,linux/arm64 + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache frontend-image: name: Build frontend image @@ -60,6 +76,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -71,6 +94,8 @@ jobs: load: true context: frontend tags: infisical/frontend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - name: โป Spawn frontend container @@ -92,3 +117,10 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From b10e28b9b56f064bb2e56657b4786db0cf6b8c02 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 10:44:51 -0500 Subject: [PATCH 06/24] set push to false to test cache --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ee1dc7d13..bc54e43a3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,7 +49,7 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: true + push: false context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest @@ -110,7 +110,7 @@ jobs: - name: ๐Ÿ—๏ธ Build frontend and push uses: docker/build-push-action@v3 with: - push: true + push: false context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest From c81320c09d7d90a8f6a855dde605c582ee353d22 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:14:40 -0500 Subject: [PATCH 07/24] remove frontend testing --- .github/workflows/docker-image.yml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bc54e43a3..a0d7ae792 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -91,32 +91,14 @@ jobs: - name: ๐Ÿ“ฆ Build frontend and export to Docker uses: docker/build-push-action@v3 with: - load: true + # load: true + push: false context: frontend tags: infisical/frontend:test cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - name: โป Spawn frontend container - run: | - docker run -d --rm --name infisical-frontend-test infisical/frontend:test - - name: ๐Ÿงช Test frontend image - run: | - ./.github/resources/healthcheck.sh infisical-frontend-test - - name: โป Shut down frontend container - run: | - docker stop infisical-frontend-test - - name: ๐Ÿ—๏ธ Build frontend and push - uses: docker/build-push-action@v3 - with: - push: false - context: frontend - tags: infisical/frontend:${{ steps.commit.outputs.short }}, - infisical/frontend:latest - platforms: linux/amd64,linux/arm64 - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 From 07e6eb88ea68b15c75a9a62cbaa83ab488bab110 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:21:14 -0500 Subject: [PATCH 08/24] use github cache --- .github/workflows/docker-image.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a0d7ae792..d8cf08045 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -76,13 +76,6 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -95,8 +88,8 @@ jobs: push: false context: frontend tags: infisical/frontend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix From e7c75b544d45319cac7ef39dfb2eddd2d792534e Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 10 Jan 2023 08:35:14 -0800 Subject: [PATCH 09/24] Fixed the discrepancies between projectIds in url and local storage --- frontend/components/basic/Layout.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index 48399cdce..d539fce3f 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -211,9 +211,11 @@ export default function Layout({ children }: LayoutProps) { const intendedWorkspaceId = router.asPath .split("/") [router.asPath.split("/").length - 1].split("?")[0]; + + localStorage.setItem("projectData.id", intendedWorkspaceId); // If a user is not a member of a workspace they are trying to access, just push them to one of theirs if ( - intendedWorkspaceId != "heroku" && + !["heroku", "vercel", "github", "netlify"].includes(intendedWorkspaceId) && !userWorkspaces .map((workspace: { _id: string }) => workspace._id) .includes(intendedWorkspaceId) @@ -259,14 +261,14 @@ export default function Layout({ children }: LayoutProps) { .split("/") [router.asPath.split("/").length - 1].split("?")[0] ) { - router.push( - "/dashboard/" + - workspaceMapping[workspaceSelected as any] - ); localStorage.setItem( "projectData.id", `${workspaceMapping[workspaceSelected as any]}` ); + router.push( + "/dashboard/" + + workspaceMapping[workspaceSelected as any] + ); } } catch (error) { console.log(error); From 3eb2209eb83dd4ebff9384074da80ef430ade91b Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:35:58 -0500 Subject: [PATCH 10/24] add cache to build after test step --- .github/workflows/docker-image.yml | 35 ++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d8cf08045..b2cda6fe5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -76,6 +76,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -84,12 +91,32 @@ jobs: - name: ๐Ÿ“ฆ Build frontend and export to Docker uses: docker/build-push-action@v3 with: - # load: true - push: false + load: true context: frontend tags: infisical/frontend:test - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - name: โป Spawn frontend container + run: | + docker run -d --rm --name infisical-frontend-test infisical/frontend:test + - name: ๐Ÿงช Test frontend image + run: | + ./.github/resources/healthcheck.sh infisical-frontend-test + - name: โป Shut down frontend container + run: | + docker stop infisical-frontend-test + - name: ๐Ÿ—๏ธ Build frontend and push + uses: docker/build-push-action@v3 + with: + push: false + context: frontend + tags: infisical/frontend:${{ steps.commit.outputs.short }}, + infisical/frontend:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix From e4d302b7e1a67a537acdce45dd28a0f4b84a55c2 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:56:42 -0500 Subject: [PATCH 11/24] Add cache to build step in backend --- .github/workflows/docker-image.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b2cda6fe5..579f6bd46 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,11 +49,13 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: false + push: push context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 @@ -110,7 +112,7 @@ jobs: - name: ๐Ÿ—๏ธ Build frontend and push uses: docker/build-push-action@v3 with: - push: false + push: true context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest From 97f77dcadaee81edc7917e0adcfd64f0956eb291 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:59:17 -0500 Subject: [PATCH 12/24] set push to true for backend workflow --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 579f6bd46..e138c83f9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,7 +49,7 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: push + push: true context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest From be8a274e5a6613b8d4628dc5ff1365479f4f77c5 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 13:20:37 -0500 Subject: [PATCH 13/24] create separate frontend workflow --- .../workflows/push-frontend-image-docker.yml | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .github/workflows/push-frontend-image-docker.yml diff --git a/.github/workflows/push-frontend-image-docker.yml b/.github/workflows/push-frontend-image-docker.yml new file mode 100644 index 000000000..1b948f19b --- /dev/null +++ b/.github/workflows/push-frontend-image-docker.yml @@ -0,0 +1,130 @@ +name: Push frontend to Dockerhub + +on: [workflow_dispatch] + +jobs: + # backend-image: + # name: Build backend image + # runs-on: ubuntu-latest + + # steps: + # - name: โ˜๏ธ Checkout source + # uses: actions/checkout@v3 + # - name: Save commit hashes for tag + # id: commit + # uses: pr-mpt/actions-commit-hash@v2 + # - name: ๐Ÿ”ง Set up QEMU + # uses: docker/setup-qemu-action@v2 + # - name: ๐Ÿ”ง Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + # - name: Cache Docker layers + # uses: actions/cache@v3 + # with: + # path: /tmp/.buildx-cache + # key: ${{ runner.os }}-buildx-${{ github.sha }} + # restore-keys: | + # ${{ runner.os }}-buildx- + # - name: ๐Ÿ‹ Login to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: ๐Ÿ“ฆ Build backend and export to Docker + # uses: docker/build-push-action@v3 + # with: + # load: true + # context: backend + # tags: infisical/backend:test + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - name: โป Spawn backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull + # - name: ๐Ÿงช Test backend image + # run: | + # ./.github/resources/healthcheck.sh infisical-backend-test + # - name: โป Shut down backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml down + # - name: ๐Ÿ—๏ธ Build backend and push + # uses: docker/build-push-action@v3 + # with: + # push: true + # context: backend + # tags: infisical/backend:${{ steps.commit.outputs.short }}, + # infisical/backend:latest + # platforms: linux/amd64,linux/arm64 + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + frontend-image: + name: Build frontend image + runs-on: ubuntu-latest + + steps: + - name: โ˜๏ธ Checkout source + uses: actions/checkout@v3 + - name: Save commit hashes for tag + id: commit + uses: pr-mpt/actions-commit-hash@v2 + - name: ๐Ÿ”ง Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: ๐Ÿ‹ Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: ๐Ÿ“ฆ Build frontend and export to Docker + uses: docker/build-push-action@v3 + with: + load: true + context: frontend + tags: infisical/frontend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - name: โป Spawn frontend container + run: | + docker run -d --rm --name infisical-frontend-test infisical/frontend:test + - name: ๐Ÿงช Test frontend image + run: | + ./.github/resources/healthcheck.sh infisical-frontend-test + - name: โป Shut down frontend container + run: | + docker stop infisical-frontend-test + - name: ๐Ÿ—๏ธ Build frontend and push + uses: docker/build-push-action@v3 + with: + push: true + context: frontend + tags: infisical/frontend:${{ steps.commit.outputs.short }}, + infisical/frontend:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From b8edcab0d598fb1138bce7703a825d18f0cbdbd5 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 13:25:34 -0500 Subject: [PATCH 14/24] delete push-frontend-image-docker --- .../workflows/push-frontend-image-docker.yml | 130 ------------------ 1 file changed, 130 deletions(-) delete mode 100644 .github/workflows/push-frontend-image-docker.yml diff --git a/.github/workflows/push-frontend-image-docker.yml b/.github/workflows/push-frontend-image-docker.yml deleted file mode 100644 index 1b948f19b..000000000 --- a/.github/workflows/push-frontend-image-docker.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: Push frontend to Dockerhub - -on: [workflow_dispatch] - -jobs: - # backend-image: - # name: Build backend image - # runs-on: ubuntu-latest - - # steps: - # - name: โ˜๏ธ Checkout source - # uses: actions/checkout@v3 - # - name: Save commit hashes for tag - # id: commit - # uses: pr-mpt/actions-commit-hash@v2 - # - name: ๐Ÿ”ง Set up QEMU - # uses: docker/setup-qemu-action@v2 - # - name: ๐Ÿ”ง Set up Docker Buildx - # uses: docker/setup-buildx-action@v2 - # - name: Cache Docker layers - # uses: actions/cache@v3 - # with: - # path: /tmp/.buildx-cache - # key: ${{ runner.os }}-buildx-${{ github.sha }} - # restore-keys: | - # ${{ runner.os }}-buildx- - # - name: ๐Ÿ‹ Login to Docker Hub - # uses: docker/login-action@v2 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} - # - name: ๐Ÿ“ฆ Build backend and export to Docker - # uses: docker/build-push-action@v3 - # with: - # load: true - # context: backend - # tags: infisical/backend:test - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - name: โป Spawn backend container and dependencies - # run: | - # docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull - # - name: ๐Ÿงช Test backend image - # run: | - # ./.github/resources/healthcheck.sh infisical-backend-test - # - name: โป Shut down backend container and dependencies - # run: | - # docker compose -f .github/resources/docker-compose.be-test.yml down - # - name: ๐Ÿ—๏ธ Build backend and push - # uses: docker/build-push-action@v3 - # with: - # push: true - # context: backend - # tags: infisical/backend:${{ steps.commit.outputs.short }}, - # infisical/backend:latest - # platforms: linux/amd64,linux/arm64 - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - frontend-image: - name: Build frontend image - runs-on: ubuntu-latest - - steps: - - name: โ˜๏ธ Checkout source - uses: actions/checkout@v3 - - name: Save commit hashes for tag - id: commit - uses: pr-mpt/actions-commit-hash@v2 - - name: ๐Ÿ”ง Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: ๐Ÿ”ง Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: ๐Ÿ‹ Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: ๐Ÿ“ฆ Build frontend and export to Docker - uses: docker/build-push-action@v3 - with: - load: true - context: frontend - tags: infisical/frontend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - name: โป Spawn frontend container - run: | - docker run -d --rm --name infisical-frontend-test infisical/frontend:test - - name: ๐Ÿงช Test frontend image - run: | - ./.github/resources/healthcheck.sh infisical-frontend-test - - name: โป Shut down frontend container - run: | - docker stop infisical-frontend-test - - name: ๐Ÿ—๏ธ Build frontend and push - uses: docker/build-push-action@v3 - with: - push: true - context: frontend - tags: infisical/frontend:${{ steps.commit.outputs.short }}, - infisical/frontend:latest - platforms: linux/amd64,linux/arm64 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache From a3db20cacf09cb9d3b73e63cc1e5c0079355c2d6 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 10 Jan 2023 10:55:52 -0800 Subject: [PATCH 15/24] Fixed the bug with wrong project id in local storage --- frontend/components/basic/Layout.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index d539fce3f..de58a90fa 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -212,7 +212,12 @@ export default function Layout({ children }: LayoutProps) { .split("/") [router.asPath.split("/").length - 1].split("?")[0]; - localStorage.setItem("projectData.id", intendedWorkspaceId); + if ( + !["heroku", "vercel", "github", "netlify"].includes(intendedWorkspaceId) + ) { + localStorage.setItem("projectData.id", intendedWorkspaceId); + } + // If a user is not a member of a workspace they are trying to access, just push them to one of theirs if ( !["heroku", "vercel", "github", "netlify"].includes(intendedWorkspaceId) && From 1dbd121aa4ac236faa717088bc3c4b538cd63279 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 14:30:40 -0500 Subject: [PATCH 16/24] Try different keys for workflow cache --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e138c83f9..e3e477be1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -21,9 +21,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: backend-${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx- + backend-${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -82,9 +82,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: frontend-${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx- + frontend-${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: From 946fbe4716f5dbd3cf389e67863aff2cee0de471 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 10 Jan 2023 11:39:34 -0800 Subject: [PATCH 17/24] Disabled integrations for now --- backend/src/variables/integration.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/variables/integration.ts b/backend/src/variables/integration.ts index 00e817c57..ed18c5a2a 100644 --- a/backend/src/variables/integration.ts +++ b/backend/src/variables/integration.ts @@ -48,7 +48,7 @@ const INTEGRATION_OPTIONS = [ name: 'Vercel', slug: 'vercel', image: 'Vercel', - isAvailable: true, + isAvailable: false, type: 'vercel', clientId: '', clientSlug: CLIENT_SLUG_VERCEL, @@ -58,7 +58,7 @@ const INTEGRATION_OPTIONS = [ name: 'Netlify', slug: 'netlify', image: 'Netlify', - isAvailable: true, + isAvailable: false, type: 'oauth2', clientId: CLIENT_ID_NETLIFY, docsLink: '' @@ -67,7 +67,7 @@ const INTEGRATION_OPTIONS = [ name: 'GitHub', slug: 'github', image: 'GitHub', - isAvailable: true, + isAvailable: false, type: 'oauth2', clientId: CLIENT_ID_GITHUB, docsLink: '' From 63a739d626498ef5066306b0192d12776ae1d640 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 10 Jan 2023 12:48:27 -0800 Subject: [PATCH 18/24] Removed posthog logs --- frontend/components/analytics/posthog.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/components/analytics/posthog.ts b/frontend/components/analytics/posthog.ts index e0dedc7fb..8482eeb06 100644 --- a/frontend/components/analytics/posthog.ts +++ b/frontend/components/analytics/posthog.ts @@ -9,7 +9,6 @@ export const initPostHog = () => { if (typeof window !== 'undefined') { // @ts-ignore if (ENV == 'production' && TELEMETRY_CAPTURING_ENABLED) { - console.log("Outside of posthog", "POSTHOG_API_KEY", POSTHOG_API_KEY, "POSTHOG_HOST", POSTHOG_HOST) posthog.init(POSTHOG_API_KEY, { api_host: POSTHOG_HOST }); From fbe2297ed640ff74066175a9b30ee489aecaad84 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 16:28:48 -0500 Subject: [PATCH 19/24] Add depot --- .github/workflows/docker-image.yml | 50 ++++++------------------------ 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e3e477be1..0df455697 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,26 +17,19 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: backend-${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - backend-${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Depot CLI + uses: depot/setup-action@v1 - name: ๐Ÿ“ฆ Build backend and export to Docker - uses: docker/build-push-action@v3 + uses: depot/build-push-action@v1 with: load: true context: backend tags: infisical/backend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: โป Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -47,22 +40,13 @@ jobs: run: | docker compose -f .github/resources/docker-compose.be-test.yml down - name: ๐Ÿ—๏ธ Build backend and push - uses: docker/build-push-action@v3 + uses: depot/build-push-action@v1 with: push: true context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest platforms: linux/amd64,linux/arm64 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache frontend-image: name: Build frontend image @@ -78,26 +62,19 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: frontend-${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - frontend-${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Depot CLI + uses: depot/setup-action@v1 - name: ๐Ÿ“ฆ Build frontend and export to Docker - uses: docker/build-push-action@v3 + uses: depot/build-push-action@v1 with: load: true context: frontend tags: infisical/frontend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - name: โป Spawn frontend container @@ -110,21 +87,12 @@ jobs: run: | docker stop infisical-frontend-test - name: ๐Ÿ—๏ธ Build frontend and push - uses: docker/build-push-action@v3 + uses: depot/build-push-action@v1 with: push: true context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest platforms: linux/amd64,linux/arm64 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} \ No newline at end of file From db639b1a89de43d4d2b55613f202d7887c84e486 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 16:31:02 -0500 Subject: [PATCH 20/24] add project id to depot --- .github/workflows/docker-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0df455697..4757329e3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -27,6 +27,7 @@ jobs: - name: ๐Ÿ“ฆ Build backend and export to Docker uses: depot/build-push-action@v1 with: + project: 64mmf0n610 load: true context: backend tags: infisical/backend:test @@ -42,6 +43,7 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: depot/build-push-action@v1 with: + project: 64mmf0n610 push: true context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, @@ -73,6 +75,7 @@ jobs: uses: depot/build-push-action@v1 with: load: true + project: 64mmf0n610 context: frontend tags: infisical/frontend:test build-args: | @@ -89,6 +92,7 @@ jobs: - name: ๐Ÿ—๏ธ Build frontend and push uses: depot/build-push-action@v1 with: + project: 64mmf0n610 push: true context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, From 7fde55414a5a1abb9477b4e4c46a15493e43084c Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 16:36:06 -0500 Subject: [PATCH 21/24] add depot token --- .github/workflows/docker-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4757329e3..7bb65ca87 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -28,6 +28,7 @@ jobs: uses: depot/build-push-action@v1 with: project: 64mmf0n610 + token: ${{ secrets.DEPOT_PROJECT_TOKEN }} load: true context: backend tags: infisical/backend:test @@ -44,6 +45,7 @@ jobs: uses: depot/build-push-action@v1 with: project: 64mmf0n610 + token: ${{ secrets.DEPOT_PROJECT_TOKEN }} push: true context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, @@ -75,6 +77,7 @@ jobs: uses: depot/build-push-action@v1 with: load: true + token: ${{ secrets.DEPOT_PROJECT_TOKEN }} project: 64mmf0n610 context: frontend tags: infisical/frontend:test @@ -94,6 +97,7 @@ jobs: with: project: 64mmf0n610 push: true + token: ${{ secrets.DEPOT_PROJECT_TOKEN }} context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest From e51046fe62f4880f94d09db96a85f6d910a3e191 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 16:47:09 -0500 Subject: [PATCH 22/24] remove QEMU --- .github/workflows/docker-image.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7bb65ca87..ab7b939e7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,8 +13,6 @@ jobs: - name: Save commit hashes for tag id: commit uses: pr-mpt/actions-commit-hash@v2 - - name: ๐Ÿ”ง Set up QEMU - uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: ๐Ÿ‹ Login to Docker Hub @@ -62,8 +60,6 @@ jobs: - name: Save commit hashes for tag id: commit uses: pr-mpt/actions-commit-hash@v2 - - name: ๐Ÿ”ง Set up QEMU - uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: ๐Ÿ‹ Login to Docker Hub From 3fd5b521bbd0b16925dca620a4b1a3410e27d45d Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 10 Jan 2023 14:08:02 -0800 Subject: [PATCH 23/24] Removed service token logs --- frontend/components/basic/dialog/AddServiceTokenDialog.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/components/basic/dialog/AddServiceTokenDialog.js b/frontend/components/basic/dialog/AddServiceTokenDialog.js index f9ef6d27c..177911973 100644 --- a/frontend/components/basic/dialog/AddServiceTokenDialog.js +++ b/frontend/components/basic/dialog/AddServiceTokenDialog.js @@ -73,8 +73,6 @@ const AddServiceTokenDialog = ({ tag }); - console.log('newServiceToken', newServiceToken); - setServiceTokens(serviceTokens.concat([newServiceToken.serviceTokenData])); setServiceToken(newServiceToken.serviceToken + "." + randomBytes); }; From 9ce4a52b8da0057c2450cd7af93a8c5758c2476b Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 19:07:41 -0500 Subject: [PATCH 24/24] Remove posthog for sev2 --- .../src/controllers/v2/secretController.ts | 212 +++++++++--------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/backend/src/controllers/v2/secretController.ts b/backend/src/controllers/v2/secretController.ts index b993d3811..c2cf45f9a 100644 --- a/backend/src/controllers/v2/secretController.ts +++ b/backend/src/controllers/v2/secretController.ts @@ -7,7 +7,7 @@ const { ValidationError } = mongoose.Error; import { BadRequestError, InternalServerError, UnauthorizedRequestError, ValidationError as RouteValidationError } from '../../utils/errors'; import { AnyBulkWriteOperation } from 'mongodb'; import { SECRET_PERSONAL, SECRET_SHARED } from "../../variables"; -import { postHogClient } from '../../services'; +// import { postHogClient } from '../../services'; /** * Create secret for workspace with id [workspaceId] and environment [environment] @@ -42,19 +42,19 @@ export const createSecret = async (req: Request, res: Response) => { throw RouteValidationError({ message: error.message, stack: error.stack }) } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets added', - distinctId: req.user.email, - properties: { - numberOfSecrets: 1, - workspaceId, - environment, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets added', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: 1, + // workspaceId, + // environment, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } res.status(200).send({ secret @@ -103,19 +103,19 @@ export const createSecrets = async (req: Request, res: Response) => { throw InternalServerError({ message: "Unable to process your batch create request. Please try again", stack: bulkCreateError.stack }) } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets added', - distinctId: req.user.email, - properties: { - numberOfSecrets: (secretsToCreate ?? []).length, - workspaceId, - environment, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets added', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: (secretsToCreate ?? []).length, + // workspaceId, + // environment, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } res.status(200).send({ secrets @@ -158,19 +158,19 @@ export const deleteSecrets = async (req: Request, res: Response) => { throw InternalServerError() } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets deleted', - distinctId: req.user.email, - properties: { - numberOfSecrets: numSecretsDeleted, - environment: environmentName, - workspaceId, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets deleted', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: numSecretsDeleted, + // environment: environmentName, + // workspaceId, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } res.status(200).send() } @@ -183,19 +183,19 @@ export const deleteSecrets = async (req: Request, res: Response) => { export const deleteSecret = async (req: Request, res: Response) => { await Secret.findByIdAndDelete(req._secret._id) - if (postHogClient) { - postHogClient.capture({ - event: 'secrets deleted', - distinctId: req.user.email, - properties: { - numberOfSecrets: 1, - workspaceId: req._secret.workspace.toString(), - environment: req._secret.environment, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets deleted', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: 1, + // workspaceId: req._secret.workspace.toString(), + // environment: req._secret.environment, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } res.status(200).send({ secret: req._secret @@ -252,19 +252,19 @@ export const updateSecrets = async (req: Request, res: Response) => { throw InternalServerError() } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets modified', - distinctId: req.user.email, - properties: { - numberOfSecrets: (secretsModificationsRequested ?? []).length, - environment: environmentName, - workspaceId, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets modified', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: (secretsModificationsRequested ?? []).length, + // environment: environmentName, + // workspaceId, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } return res.status(200).send() } @@ -304,19 +304,19 @@ export const updateSecret = async (req: Request, res: Response) => { throw RouteValidationError({ message: "Unable to apply modifications, please try again", stack: error.stack }) } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets modified', - distinctId: req.user.email, - properties: { - numberOfSecrets: 1, - environment: environmentName, - workspaceId, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets modified', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: 1, + // environment: environmentName, + // workspaceId, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } return res.status(200).send(singleModificationUpdate) } @@ -354,19 +354,19 @@ export const getSecrets = async (req: Request, res: Response) => { throw RouteValidationError({ message: "Failed to get secrets, please try again", stack: err.stack }) } - if (postHogClient) { - postHogClient.capture({ - event: 'secrets pulled', - distinctId: req.user.email, - properties: { - numberOfSecrets: (secrets ?? []).length, - environment, - workspaceId, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets pulled', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: (secrets ?? []).length, + // environment, + // workspaceId, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } return res.json(secrets) } @@ -378,20 +378,20 @@ export const getSecrets = async (req: Request, res: Response) => { * @returns */ export const getSecret = async (req: Request, res: Response) => { - if (postHogClient) { - postHogClient.capture({ - event: 'secrets pulled', - distinctId: req.user.email, - properties: { - numberOfSecrets: 1, - workspaceId: req._secret.workspace.toString(), - environment: req._secret.environment, - channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', - userAgent: req.headers?.['user-agent'] - } - }); - } - + // if (postHogClient) { + // postHogClient.capture({ + // event: 'secrets pulled', + // distinctId: req.user.email, + // properties: { + // numberOfSecrets: 1, + // workspaceId: req._secret.workspace.toString(), + // environment: req._secret.environment, + // channel: req.headers?.['user-agent']?.toLowerCase().includes('mozilla') ? 'web' : 'cli', + // userAgent: req.headers?.['user-agent'] + // } + // }); + // } + return res.status(200).send({ secret: req._secret });