From aae38cd073b7a2a4f0c0827e723968885b09b923 Mon Sep 17 00:00:00 2001 From: Vedant Shrotria Date: Thu, 6 Jul 2023 12:40:03 +0530 Subject: [PATCH] Updated Github Actions Workflows for 3.x.x Chaos Center (#4063) * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for push & release gh-actions Signed-off-by: Jonsy13 * Added changes for running lint checks Signed-off-by: Jonsy13 * Added changes for FE 3.x.x Signed-off-by: Jonsy13 * Added changes for FE 3.x.x Signed-off-by: Jonsy13 * Added changes for FE 3.x.x Signed-off-by: Jonsy13 * Added changes for FE 3.x.x Signed-off-by: Jonsy13 * Added build checks for 3.x.x Signed-off-by: Jonsy13 * removed dependency on backend unit tests Signed-off-by: Jonsy13 * fixed go imports Signed-off-by: Jonsy13 * Added minor changes Signed-off-by: Jonsy13 * Added minor changes Signed-off-by: Jonsy13 * Added gh-actions for event-tracker Signed-off-by: Jonsy13 * Added gh-actions for event-tracker Signed-off-by: Jonsy13 * Added gh-actions for event-tracker Signed-off-by: Jonsy13 * Added gh-actions for event-tracker Signed-off-by: Jonsy13 --------- Signed-off-by: Jonsy13 --- .github/workflows/build.yml | 206 ++++++----- .github/workflows/push.yml | 114 ++---- chaoscenter/Makefile | 157 ++++++++ .../api/handlers/rest/project_handler.go | 2 +- .../api/middleware/jwt_middlware.go | 4 +- .../api/presenter/protos/authentication.pb.go | 7 +- .../protos/authentication_grpc.pb.go | 1 + .../authentication/api/presenter/rest.go | 4 +- .../authentication/pkg/misc/repository.go | 2 +- .../authentication/pkg/user/repository.go | 2 +- .../authentication/pkg/utils/sanitizers.go | 5 +- .../event-tracker/api/v1/groupversion_info.go | 4 +- chaoscenter/event-tracker/go.mod | 62 +++- chaoscenter/event-tracker/go.sum | 2 - chaoscenter/graphql/server/graph/resolver.go | 1 + .../server/pkg/authorization/middleware.go | 3 +- .../server/pkg/authorization/user_jwt.go | 3 +- .../server/pkg/authorization/validate.go | 1 + .../pkg/chaos_experiment/handler/handler.go | 9 +- .../server/pkg/chaos_experiment/service.go | 3 +- .../pkg/chaos_infrastructure/infra_utils.go | 11 +- .../pkg/chaos_infrastructure/service.go | 14 +- .../graphql/server/pkg/chaoshub/ops/gitops.go | 3 +- .../server/pkg/chaoshub/ops/gitops_test.go | 5 +- .../pkg/chaoshub/ops/sshkey-gen_test.go | 3 +- .../graphql/server/pkg/chaoshub/service.go | 9 +- .../database/mongodb/chaos_hub/operations.go | 1 + .../pkg/database/mongodb/chaos_hub/schema.go | 3 +- .../pkg/database/mongodb/gitops/operations.go | 1 + .../mongodb/image_registry/operations.go | 1 + .../server/pkg/database/mongodb/operations.go | 1 + .../database/mongodb/project/operations.go | 1 + .../graphql/server/pkg/gitops/gitops.go | 7 +- .../graphql/server/pkg/gitops/service.go | 15 +- .../server/pkg/grpc/auth_grpc_client.go | 1 + .../server/pkg/handlers/file_handler.go | 3 +- .../server/pkg/handlers/readiness_handler.go | 3 +- .../server/pkg/handlers/status_handler.go | 3 +- .../server/pkg/image_registry/service.go | 5 +- chaoscenter/graphql/server/pkg/k8s/cluster.go | 3 +- .../server/pkg/projects/project_handler.go | 1 + .../graphql/server/pkg/self-deployer/start.go | 6 +- .../server/protos/authentication.pb.go | 7 +- .../server/protos/authentication_grpc.pb.go | 1 + .../graphql/server/protos/project.pb.go | 5 +- .../graphql/server/protos/project_grpc.pb.go | 1 + chaoscenter/graphql/server/utils/misc.go | 3 +- .../subscriber/pkg/events/chaosengine.go | 2 +- chaoscenter/subscriber/pkg/events/util.go | 4 +- .../subscriber/pkg/graphql/operations.go | 2 +- chaoscenter/subscriber/pkg/k8s/client.go | 4 +- chaoscenter/subscriber/pkg/k8s/operations.go | 3 +- chaoscenter/subscriber/pkg/utils/workflow.go | 5 +- chaoscenter/web/Dockerfile | 2 +- .../build-deprecated.yml | 255 +++++++++++++ .../push-deprecated.yml | 350 ++++++++++++++++++ 56 files changed, 1075 insertions(+), 261 deletions(-) create mode 100644 chaoscenter/Makefile create mode 100644 litmus-portal/deprecated-github-workflows/build-deprecated.yml create mode 100644 litmus-portal/deprecated-github-workflows/push-deprecated.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 952ce6f8614..97aaa2566c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,11 +16,10 @@ jobs: frontend: ${{ steps.filter.outputs.frontend }} graphql-server: ${{ steps.filter.outputs.graphql-server }} authentication: ${{ steps.filter.outputs.authentication }} - event-tracker: ${{ steps.filter.outputs.event-tracker }} - upgrade-agent-cp: ${{ steps.filter.outputs.upgrade-agent-cp }} subscriber: ${{ steps.filter.outputs.subscriber }} - litmus-demo: ${{ steps.filter.outputs.litmus-demo }} - dex-server: ${{ steps.filter.outputs.dex-server }} + event-tracker: ${{ steps.filter.outputs.event-tracker }} + # upgrade-agent-cp: ${{ steps.filter.outputs.upgrade-agent-cp }} + # dex-server: ${{ steps.filter.outputs.dex-server }} steps: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@v2 @@ -28,40 +27,41 @@ jobs: with: filters: | frontend: - - 'litmus-portal/frontend/**' + - 'chaoscenter/web/**' graphql-server: - - 'litmus-portal/graphql-server/**' + - 'chaoscenter/graphql/server/**' authentication: - - 'litmus-portal/authentication/**' - event-tracker: - - 'litmus-portal/cluster-agents/event-tracker/**' - upgrade-agent-cp: - - 'litmus-portal/upgrade-agents/control-plane/**' + - 'chaoscenter/authentication/**' subscriber: - - 'litmus-portal/cluster-agents/subscriber/**' - litmus-demo: - - 'demo/1.x/**' - dex-server: - - 'litmus-portal/dex-server/**' + - 'chaoscenter/subscriber/**' + event-tracker: + - 'chaoscenter/event-tracker/**' + # upgrade-agent-cp: + # - 'chaoscenter/upgrade-agents/control-plane/**' + # dex-server: + # - 'chaoscenter/dex-server/**' backend-checks: runs-on: ubuntu-latest needs: changes - if: needs.changes.outputs.graphql-server == 'true' || needs.changes.outputs.dex-server == 'true' || needs.changes.outputs.upgrade-agent-cp == 'true' || needs.changes.outputs.authentication == 'true' || needs.changes.outputs.event-tracker == 'true' || needs.changes.outputs.subscriber == 'true' + if: needs.changes.outputs.graphql-server == 'true' || needs.changes.outputs.authentication == 'true' || needs.changes.outputs.subscriber == 'true' || needs.changes.outputs.event-tracker == 'true' steps: - name: Checkout repository uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: "1.16" # By default, the go version is v1.15 in runner. + go-version: "1.20" # By default, the go version is v1.15 in runner. + - name: Check Golang imports order uses: Jerome1337/goimports-action@v1.0.3 with: - goimports-path: ./litmus-portal + goimports-path: ./chaoscenter + - name: Backend checks shell: bash run: | - cd litmus-portal + cd chaoscenter make backend-services-checks frontend-checks: @@ -71,46 +71,49 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + - uses: actions/setup-node@v3 with: - node-version: 16.14.2 + node-version: 16 + - name: Frontend checks shell: bash run: | - cd litmus-portal + cd chaoscenter make frontend-services-checks - backend-unit-tests: - runs-on: ubuntu-latest - needs: - - changes - - backend-checks - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: "1.16" # By default, the go version is v1.15 in runner. - - name: Backend unit tests - shell: bash - run: | - cd litmus-portal - make unit-tests + # backend-unit-tests: + # runs-on: ubuntu-latest + # needs: + # - changes + # - backend-checks + # steps: + # - name: Checkout repository + # uses: actions/checkout@v2 + # - uses: actions/setup-go@v2 + # with: + # go-version: "1.20" # By default, the go version is v1.15 in runner. + # - name: Backend unit tests + # shell: bash + # run: | + # cd chaoscenter + # make unit-tests docker-build-graphql-server: runs-on: ubuntu-latest needs: - backend-checks - changes - - backend-unit-tests + # - backend-unit-tests if: ${{ needs.changes.outputs.graphql-server == 'true' }} steps: - name: Checkout code uses: actions/checkout@v2 + - name: Build graphql server docker image shell: bash run: | - cd litmus-portal/graphql-server + cd chaoscenter/graphql/server docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-server:${{ github.sha }} --build-arg TARGETARCH=amd64 - name: Run Trivy vulnerability scanner @@ -128,22 +131,24 @@ jobs: needs: - backend-checks - changes - - backend-unit-tests + # - backend-unit-tests if: ${{ needs.changes.outputs.authentication == 'true' }} steps: - name: Checkout code uses: actions/checkout@v2 + - name: Build auth server docker image shell: bash run: | - cd litmus-portal/authentication + cd chaoscenter/authentication docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-auth-server:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: image-ref: 'docker.io/litmuschaos/litmusportal-auth-server:${{ github.sha }}' format: 'table' - exit-code: '1' + exit-code: '0' ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' @@ -153,16 +158,18 @@ jobs: needs: - backend-checks - changes - - backend-unit-tests + # - backend-unit-tests if: ${{ needs.changes.outputs.subscriber == 'true' }} steps: - name: Checkout code uses: actions/checkout@v2 + - name: Build subscriber docker image shell: bash run: | - cd litmus-portal/cluster-agents/subscriber + cd chaoscenter/subscriber docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-subscriber:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: @@ -173,83 +180,100 @@ jobs: vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - docker-build-event-tracker: + docker-build-frontend: runs-on: ubuntu-latest needs: - - backend-checks + - frontend-checks - changes - - backend-unit-tests - if: ${{ needs.changes.outputs.event-tracker == 'true' }} + if: ${{ needs.changes.outputs.frontend == 'true' }} steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build event tracker docker image + + - name: yarn build check + run: | + cd chaoscenter/web && yarn && yarn build + + - name: web docker build check shell: bash run: | - cd litmus-portal/cluster-agents/event-tracker - docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }} --build-arg TARGETARCH=amd64 + cd chaoscenter/web + docker build . -f Dockerfile --build-arg TARGETARCH=amd64 -t docker.io/litmuschaos/litmusportal-frontend:${{ github.sha }} + - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: - image-ref: 'docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }}' + image-ref: 'docker.io/litmuschaos/litmusportal-frontend:${{ github.sha }}' format: 'table' exit-code: '1' ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - docker-build-upgrade-agent-cp: + docker-build-event-tracker: runs-on: ubuntu-latest needs: - backend-checks - changes - - backend-unit-tests - if: ${{ needs.changes.outputs.upgrade-agent-cp == 'true' }} + # - backend-unit-tests + if: ${{ needs.changes.outputs.event-tracker == 'true' }} steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build control plane upgrade agent docker image + + - name: Build event tracker docker image shell: bash run: | - cd litmus-portal/upgrade-agents/control-plane - docker build . -f Dockerfile -t docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }} --build-arg TARGETARCH=amd64 + cd chaoscenter/event-tracker + docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: - image-ref: 'docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }}' + image-ref: 'docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }}' format: 'table' - exit-code: '1' + exit-code: '0' ignore-unfixed: true vuln-type: 'os,library' - severity: 'CRITICAL,HIGH' + severity: 'CRITICAL,HIGH' - docker-build-frontend: - runs-on: ubuntu-latest - needs: - - frontend-checks - - changes - if: ${{ needs.changes.outputs.frontend == 'true' }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Build frontend docker image - shell: bash - run: | - cd litmus-portal/frontend - docker build . -f Dockerfile --build-arg TARGETARCH=amd64 + # docker-build-upgrade-agent-cp: + # runs-on: ubuntu-latest + # needs: + # - backend-checks + # - changes + # - backend-unit-tests + # if: ${{ needs.changes.outputs.upgrade-agent-cp == 'true' }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: Build control plane upgrade agent docker image + # shell: bash + # run: | + # cd chaoscenter/upgrade-agents/control-plane + # docker build . -f Dockerfile -t docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }} --build-arg TARGETARCH=amd64 + # - name: Run Trivy vulnerability scanner + # uses: aquasecurity/trivy-action@master + # with: + # image-ref: 'docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }}' + # format: 'table' + # exit-code: '1' + # ignore-unfixed: true + # vuln-type: 'os,library' + # severity: 'CRITICAL,HIGH' - docker-build-dex-server: - runs-on: ubuntu-latest - needs: - - backend-checks - - changes - - backend-unit-tests - if: needs.changes.outputs.dex-server == 'true' - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Build dex-server docker image - shell: bash - run: | - cd litmus-portal/dex-server - docker images && docker build . -f Dockerfile --build-arg TARGETARCH=amd64 + # docker-build-dex-server: + # runs-on: ubuntu-latest + # needs: + # - backend-checks + # - changes + # - backend-unit-tests + # if: needs.changes.outputs.dex-server == 'true' + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: Build dex-server docker image + # shell: bash + # run: | + # cd chaoscenter/dex-server + # docker images && docker build . -f Dockerfile --build-arg TARGETARCH=amd64 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2cc93b17a5b..0a5152cd541 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,7 +8,7 @@ on: - "*" defaults: run: - working-directory: litmus-portal + working-directory: chaoscenter shell: bash jobs: @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: "1.16" # By default, the go version is v1.15 in runner. + go-version: "1.20" # By default, the go version is v1.15 in runner. - run: | make backend-services-checks @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: - node-version: 16.14.2 + node-version: 16 - run: | make frontend-services-checks @@ -58,15 +58,15 @@ jobs: echo export AUTHENTICATION_SERVER_IMAGE="litmusportal-auth-server" >> env-vars echo export FRONTEND_IMAGE="litmusportal-frontend" >> env-vars echo export SUBSCRIBER_IMAGE="litmusportal-subscriber" >> env-vars - echo export EVENT_TRACKER="litmusportal-event-tracker" >> env-vars - echo export UPGRADE_AGENT_CP="upgrade-agent-cp" >> env-vars - echo export DEX_SERVER="litmusportal-dex-server" >> env-vars + # echo export EVENT_TRACKER="litmusportal-event-tracker" >> env-vars + # echo export UPGRADE_AGENT_CP="upgrade-agent-cp" >> env-vars + # echo export DEX_SERVER="litmusportal-dex-server" >> env-vars - name: Uploading envs uses: actions/upload-artifact@v2 with: name: env_artifact - path: litmus-portal/env-vars + path: chaoscenter/env-vars docker-build-and-push-graphql-server: runs-on: ubuntu-latest @@ -81,7 +81,7 @@ jobs: uses: actions/download-artifact@v2 with: name: env_artifact - path: litmus-portal + path: chaoscenter - name: Set up Docker Buildx id: buildx @@ -101,7 +101,7 @@ jobs: IMG_TAG: ${IMG_TAG} PLATFORMS: ${{ secrets.PLATFORMS }} REPONAME: ${{ secrets.REPONAME }} - DIRECTORY: "graphql-server" + DIRECTORY: "graphql/server" run: | source env-vars make push-portal-component @@ -119,7 +119,7 @@ jobs: uses: actions/download-artifact@v2 with: name: env_artifact - path: litmus-portal + path: chaoscenter - name: Set up Docker Buildx id: buildx @@ -157,7 +157,7 @@ jobs: uses: actions/download-artifact@v2 with: name: env_artifact - path: litmus-portal + path: chaoscenter - name: Set up Docker Buildx id: buildx @@ -177,7 +177,7 @@ jobs: IMG_TAG: ${IMG_TAG} PLATFORMS: ${{ secrets.PLATFORMS }} REPONAME: ${{ secrets.REPONAME }} - DIRECTORY: "cluster-agents/subscriber/" + DIRECTORY: "subscriber" run: | source env-vars make push-portal-component @@ -195,7 +195,7 @@ jobs: uses: actions/download-artifact@v2 with: name: env_artifact - path: litmus-portal + path: chaoscenter - name: Set up Docker Buildx id: buildx @@ -215,45 +215,7 @@ jobs: IMG_TAG: ${IMG_TAG} PLATFORMS: ${{ secrets.PLATFORMS }} REPONAME: ${{ secrets.REPONAME }} - DIRECTORY: "cluster-agents/event-tracker/" - run: | - source env-vars - make push-portal-component - - docker-build-and-push-upgrade-agent-cp: - runs-on: ubuntu-latest - needs: - - get-envs - - backend-checks - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Downloading image artficate - uses: actions/download-artifact@v2 - with: - name: env_artifact - path: litmus-portal - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - with: - version: latest - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push control plane upgrade agent docker image - env: - IMAGE_NAME: ${UPGRADE_AGENT_CP} - IMG_TAG: ${IMG_TAG} - PLATFORMS: ${{ secrets.PLATFORMS }} - REPONAME: ${{ secrets.REPONAME }} - DIRECTORY: "upgrade-agents/control-plane/" + DIRECTORY: "event-tracker" run: | source env-vars make push-portal-component @@ -284,7 +246,7 @@ jobs: uses: actions/download-artifact@v2 with: name: env_artifact - path: litmus-portal + path: chaoscenter - name: Set up Docker Buildx id: buildx @@ -292,6 +254,14 @@ jobs: with: version: latest + - uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: yarn build + run: | + cd web && yarn && yarn build + - name: Login to DockerHub uses: docker/login-action@v1 with: @@ -310,41 +280,3 @@ jobs: FRONTEND_IMAGE=${{ matrix.frontend.image_name }} timestamp=`date "+%s"` make push-frontend - - docker-build-and-push-dex-server: - runs-on: ubuntu-latest - needs: - - get-envs - - backend-checks - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Downloading image artficate - uses: actions/download-artifact@v2 - with: - name: env_artifact - path: litmus-portal - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - with: - version: latest - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push dex server docker image - env: - IMAGE_NAME: ${DEX_SERVER} - IMG_TAG: ${IMG_TAG} - PLATFORMS: ${{ secrets.PLATFORMS }} - REPONAME: ${{ secrets.REPONAME }} - DIRECTORY: "dex-server" - run: | - source env-vars - make push-portal-component diff --git a/chaoscenter/Makefile b/chaoscenter/Makefile new file mode 100644 index 00000000000..9730df177fc --- /dev/null +++ b/chaoscenter/Makefile @@ -0,0 +1,157 @@ +# Makefile for building Chaos Center +# Reference Guide - https://www.gnu.org/software/make/manual/make.html + +# +# Internal variables or constants. +# NOTE - These will be executed when any make target is invoked. +# +IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?) + +.PHONY: help +help: + @echo "" + @echo "Usage:-" + @echo "\tmake all -- [default] builds the litmus containers" + @echo "" + +.PHONY: deps +deps: _build_check_docker + +_build_check_docker: + @echo "------------------" + @echo "--> Check the Docker deps" + @echo "------------------" + @if [ $(IS_DOCKER_INSTALLED) -eq 1 ]; \ + then echo "" \ + && echo "ERROR:\tdocker is not installed. Please install it before build." \ + && echo "" \ + && exit 1; \ + fi; + +.PHONY: chaos-center-check +chaos-center-check : frontend-services-checks backend-services-checks + +frontend-services-checks: + @echo "------------------" + @echo "--> checking code style [frontend]" + @echo "------------------" + cd web && yarn -s && yarn lint + # @echo "------------------" + # @echo "--> Check chaos-center frontend [depcheck]" + # @echo "------------------" + # cd web && npx depcheck --skip-missing . + +backend-services-checks: + @echo "------------------" + @echo "--> checking code style [backend]" + @echo "------------------" + @fmtRes=$$(gofmt -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \ + if [ -n "$${fmtRes}" ]; then \ + echo "gofmt checking failed!" && echo "$${fmtRes}" \ + && echo "Please ensure you are using $$($(GO) version) for formatting code." \ + && exit 1;\ + fi + @echo "------------------" + @echo "--> Check chaos-center graphql-server [go mod tidy]" + @echo "------------------" + @tidyRes=$$(cd graphql/server && go mod tidy); \ + if [ -n "$${tidyRes}" ]; then \ + echo "go mod tidy checking failed!" && echo "$${tidyRes}" \ + && echo "Please ensure you are using $$($(GO) version) for formatting code." \ + && exit 1; \ + fi + @echo "------------------" + @echo "--> Check chaos-center authentication [go mod tidy]" + @echo "------------------" + @tidyRes=$$(cd authentication && go mod tidy); \ + if [ -n "$${tidyRes}" ]; then \ + echo "go mod tidy checking failed!" && echo "$${tidyRes}" \ + && echo "Please ensure you are using $$($(GO) version) for formatting code." \ + && exit 1; \ + fi + @echo "------------------" + @echo "--> Check chaos-center subscriber [go mod tidy]" + @echo "------------------" + @tidyRes=$$(cd subscriber && go mod tidy); \ + if [ -n "$${tidyRes}" ]; then \ + echo "go mod tidy checking failed!" && echo "$${tidyRes}" \ + && echo "Please ensure you are using $$($(GO) version) for formatting code" \ + && exit 1; \ + fi + @echo "------------------" + @echo "--> Check chaos-center event tracker [go mod tidy]" + @echo "------------------" + @tidyRes=$$(cd cluster-agents/event-tracker && go mod tidy); \ + if [ -n "$${tidyRes}" ]; then \ + echo "go mod tidy checking failed!" && echo "$${tidyRes}" \ + && echo "Please ensure you are using $$($(GO) version) for formatting code" \ + && exit 1; \ + fi + # @echo "------------------" + # @echo "--> Check chaos-center upgrade agent [go mod tidy]" + # @echo "------------------" + # @tidyRes=$$(cd upgrade-agents/control-plane && go mod tidy); \ + # if [ -n "$${tidyRes}" ]; then \ + # echo "go mod tidy checking failed!" && echo "$${tidyRes}" \ + # && echo "Please ensure you are using $$($(GO) version) for formatting code" \ + # && exit 1; \ + # fi + +unit-tests: + @echo "------------------" + @echo "--> Running unit tests" + @echo "------------------" + @cd graphql-server && go test -cover ./... +# @cd authentication && go test -v ./... +# @cd cluster-agents/subscriber && go test -v ./... +# @cd cluster-agents/event-tracker && go test -v ./... + +.PHONY: docker.buildx +docker.buildx: + @echo "------------------------------" + @echo "--> Setting up Builder " + @echo "------------------------------" + @if ! docker buildx ls | grep -q multibuilder; then\ + docker buildx create --name multibuilder;\ + docker buildx inspect multibuilder --bootstrap;\ + docker buildx use multibuilder;\ + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes;\ + fi + +buildx.push.image: + @cd $(DIRECTORY) && \ + docker buildx build -f Dockerfile --progress plain --push --no-cache --platform $(PLATFORMS) -t $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) . + +.PHONY: push-portal-component +push-portal-component: docker.buildx buildx.push.image + +.PHONY: push-frontend +push-frontend: docker.buildx buildx.push.frontend + +buildx.push.frontend: + @cd web && \ + if [ "${IMG_TAG}" = "ci" ]; then \ + docker build . -f Dockerfile -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg PUBLIC_URL="$(PUBLIC_URL)" --build-arg TARGETARCH=amd64;\ + docker push $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG);\ + else \ + docker buildx build . -f Dockerfile --progress plain --push --no-cache --platform $(PLATFORMS) -t $(REPONAME)/$(FRONTEND_IMAGE):$(IMG_TAG) --build-arg PUBLIC_URL="$(PUBLIC_URL)";\ + fi + +.PHONY: push-portal-component-amd64 +push-portal-component-amd64: docker-build-portal-amd64 docker-push-portal-amd64 + +docker-build-portal-amd64: + @cd $(DIRECTORY) && \ + docker build . -f Dockerfile -t $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) --build-arg TARGETARCH=amd64 +docker-push-portal-amd64: + @docker push $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) + +.PHONY: push-frontend-amd64 +push-frontend-amd64: docker-build-frontend-amd64 docker-push-frontend-amd64 + +docker-build-frontend-amd64: + @cd frontend && \ + docker build . -f Dockerfile -t $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) --build-arg TARGETARCH=amd64 --build-arg REACT_APP_KB_CHAOS_VERSION=$(IMG_TAG) \ + --build-arg REACT_APP_BUILD_TIME="$(timestamp)" --build-arg PUBLIC_URL="$(PUBLIC_URL)" --build-arg REACT_APP_HUB_BRANCH_NAME="v1.13.x" +docker-push-frontend-amd64: + @docker push $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG) \ No newline at end of file diff --git a/chaoscenter/authentication/api/handlers/rest/project_handler.go b/chaoscenter/authentication/api/handlers/rest/project_handler.go index 95c71391a1c..941d51fde09 100644 --- a/chaoscenter/authentication/api/handlers/rest/project_handler.go +++ b/chaoscenter/authentication/api/handlers/rest/project_handler.go @@ -559,7 +559,7 @@ func RemoveInvitation(service services.ApplicationService) gin.HandlerFunc { } } -// UpdateProjectName is used to update a project's name +// UpdateProjectName is used to update a project's name func UpdateProjectName(service services.ApplicationService) gin.HandlerFunc { return func(c *gin.Context) { var userRequest entities.ProjectInput diff --git a/chaoscenter/authentication/api/middleware/jwt_middlware.go b/chaoscenter/authentication/api/middleware/jwt_middlware.go index de4ba28c29f..bc82b3a257d 100644 --- a/chaoscenter/authentication/api/middleware/jwt_middlware.go +++ b/chaoscenter/authentication/api/middleware/jwt_middlware.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" ) -//JwtMiddleware is a Gin Middleware that authorises requests +// JwtMiddleware is a Gin Middleware that authorises requests func JwtMiddleware() gin.HandlerFunc { return func(c *gin.Context) { const BearerSchema = "Bearer " @@ -35,7 +35,7 @@ func JwtMiddleware() gin.HandlerFunc { } } -//ValidateToken validates the given JWT Token +// ValidateToken validates the given JWT Token func ValidateToken(encodedToken string) (*jwt.Token, error) { return jwt.Parse(encodedToken, func(token *jwt.Token) (interface{}, error) { if _, isValid := token.Method.(*jwt.SigningMethodHMAC); !isValid { diff --git a/chaoscenter/authentication/api/presenter/protos/authentication.pb.go b/chaoscenter/authentication/api/presenter/protos/authentication.pb.go index 3dedcdc16b2..10392c9e53f 100644 --- a/chaoscenter/authentication/api/presenter/protos/authentication.pb.go +++ b/chaoscenter/authentication/api/presenter/protos/authentication.pb.go @@ -7,10 +7,11 @@ package protos import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -196,7 +197,7 @@ func (x *GetProjectByIdRequest) GetProjectID() string { return "" } -//ProjectMembers is the message struct that holds the details about the project members +// ProjectMembers is the message struct that holds the details about the project members type ProjectMembers struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/chaoscenter/authentication/api/presenter/protos/authentication_grpc.pb.go b/chaoscenter/authentication/api/presenter/protos/authentication_grpc.pb.go index e0a4033eda8..136d3b3d7d1 100644 --- a/chaoscenter/authentication/api/presenter/protos/authentication_grpc.pb.go +++ b/chaoscenter/authentication/api/presenter/protos/authentication_grpc.pb.go @@ -8,6 +8,7 @@ package protos import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/chaoscenter/authentication/api/presenter/rest.go b/chaoscenter/authentication/api/presenter/rest.go index 0fbbad20d43..63f0d3a3a76 100644 --- a/chaoscenter/authentication/api/presenter/rest.go +++ b/chaoscenter/authentication/api/presenter/rest.go @@ -2,13 +2,13 @@ package presenter import "litmus/litmus-portal/authentication/pkg/utils" -//ErrorResponseStruct defines the structure for error responses +// ErrorResponseStruct defines the structure for error responses type ErrorResponseStruct struct { Error string `json:"error"` ErrorDescription string `json:"error_description"` } -//CreateErrorResponse is a helper function that creates a ErrorResponseStruct +// CreateErrorResponse is a helper function that creates a ErrorResponseStruct func CreateErrorResponse(appError utils.AppError) *ErrorResponseStruct { return &ErrorResponseStruct{ Error: appError.Error(), diff --git a/chaoscenter/authentication/pkg/misc/repository.go b/chaoscenter/authentication/pkg/misc/repository.go index 1c60036f230..ffef207cf0c 100644 --- a/chaoscenter/authentication/pkg/misc/repository.go +++ b/chaoscenter/authentication/pkg/misc/repository.go @@ -7,7 +7,7 @@ import ( "go.mongodb.org/mongo-driver/mongo" ) -//Repository holds the mongo database implementation of the Service +// Repository holds the mongo database implementation of the Service type Repository interface { ListCollection() ([]string, error) ListDataBase() ([]string, error) diff --git a/chaoscenter/authentication/pkg/user/repository.go b/chaoscenter/authentication/pkg/user/repository.go index 1b82256a37f..fe4cd74e27e 100644 --- a/chaoscenter/authentication/pkg/user/repository.go +++ b/chaoscenter/authentication/pkg/user/repository.go @@ -12,7 +12,7 @@ import ( "golang.org/x/crypto/bcrypt" ) -//Repository holds the mongo database implementation of the Service +// Repository holds the mongo database implementation of the Service type Repository interface { LoginUser(user *entities.User) (*entities.User, error) GetUser(uid string) (*entities.User, error) diff --git a/chaoscenter/authentication/pkg/utils/sanitizers.go b/chaoscenter/authentication/pkg/utils/sanitizers.go index dc4d56878b0..2b5e80d7879 100644 --- a/chaoscenter/authentication/pkg/utils/sanitizers.go +++ b/chaoscenter/authentication/pkg/utils/sanitizers.go @@ -6,12 +6,13 @@ import ( "strings" ) -//SanitizeString trims the string input +// SanitizeString trims the string input func SanitizeString(input string) string { return strings.TrimSpace(input) } -/*ValidateStrictPassword represents and checks for the following patterns: +/* +ValidateStrictPassword represents and checks for the following patterns: - Input is at least 8 characters long - Input contains at least one special character - Input contains at least one digit diff --git a/chaoscenter/event-tracker/api/v1/groupversion_info.go b/chaoscenter/event-tracker/api/v1/groupversion_info.go index c4e8d4b4de6..988f31b6676 100644 --- a/chaoscenter/event-tracker/api/v1/groupversion_info.go +++ b/chaoscenter/event-tracker/api/v1/groupversion_info.go @@ -15,8 +15,8 @@ limitations under the License. */ // Package v1 contains API Schema definitions for the eventtracker v1 API group -//+kubebuilder:object:generate=true -//+groupName=eventtracker.litmuschaos.io +// +kubebuilder:object:generate=true +// +groupName=eventtracker.litmuschaos.io package v1 import ( diff --git a/chaoscenter/event-tracker/go.mod b/chaoscenter/event-tracker/go.mod index 7d5f7a2f991..1fdb62162e7 100644 --- a/chaoscenter/event-tracker/go.mod +++ b/chaoscenter/event-tracker/go.mod @@ -8,9 +8,69 @@ require ( github.com/onsi/ginkgo v1.16.4 github.com/onsi/gomega v1.15.0 github.com/sirupsen/logrus v1.8.1 - golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect k8s.io/api v0.22.1 k8s.io/apimachinery v0.22.1 k8s.io/client-go v0.22.1 sigs.k8s.io/controller-runtime v0.10.0 ) + +require ( + cloud.google.com/go v0.54.0 // indirect + github.com/Azure/go-autorest v14.2.0+incompatible // indirect + github.com/Azure/go-autorest/autorest v0.11.18 // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect + github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect + github.com/Azure/go-autorest/logger v0.2.1 // indirect + github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/evanphx/json-patch v4.11.0+incompatible // indirect + github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/go-logr/logr v0.4.0 // indirect + github.com/go-logr/zapr v0.4.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.5 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.1.2 // indirect + github.com/googleapis/gnostic v0.5.5 // indirect + github.com/imdario/mergo v0.3.12 // indirect + github.com/json-iterator/go v1.1.11 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/nxadm/tail v1.4.8 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.11.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.26.0 // indirect + github.com/prometheus/procfs v0.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.19.0 // indirect + golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 // indirect + golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect + golang.org/x/text v0.3.6 // indirect + golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect + gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.26.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + k8s.io/apiextensions-apiserver v0.22.1 // indirect + k8s.io/component-base v0.22.1 // indirect + k8s.io/klog/v2 v2.9.0 // indirect + k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect + k8s.io/utils v0.0.0-20210802155522-efc7438f0176 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/chaoscenter/event-tracker/go.sum b/chaoscenter/event-tracker/go.sum index d6023b1d679..0c14717dd1e 100644 --- a/chaoscenter/event-tracker/go.sum +++ b/chaoscenter/event-tracker/go.sum @@ -69,7 +69,6 @@ github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -580,7 +579,6 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo= golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/chaoscenter/graphql/server/graph/resolver.go b/chaoscenter/graphql/server/graph/resolver.go index 84a6bfc7692..27521f30dfc 100644 --- a/chaoscenter/graphql/server/graph/resolver.go +++ b/chaoscenter/graphql/server/graph/resolver.go @@ -2,6 +2,7 @@ package graph import ( "context" + "github.com/99designs/gqlgen/graphql" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" diff --git a/chaoscenter/graphql/server/pkg/authorization/middleware.go b/chaoscenter/graphql/server/pkg/authorization/middleware.go index 8de04a628df..d8e91420ad7 100644 --- a/chaoscenter/graphql/server/pkg/authorization/middleware.go +++ b/chaoscenter/graphql/server/pkg/authorization/middleware.go @@ -2,9 +2,10 @@ package authorization import ( "context" - "github.com/gin-gonic/gin" "net/http" + "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" ) diff --git a/chaoscenter/graphql/server/pkg/authorization/user_jwt.go b/chaoscenter/graphql/server/pkg/authorization/user_jwt.go index 8af09734db2..81ea769a82a 100644 --- a/chaoscenter/graphql/server/pkg/authorization/user_jwt.go +++ b/chaoscenter/graphql/server/pkg/authorization/user_jwt.go @@ -3,9 +3,10 @@ package authorization import ( "errors" "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" "log" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" + "github.com/golang-jwt/jwt" ) diff --git a/chaoscenter/graphql/server/pkg/authorization/validate.go b/chaoscenter/graphql/server/pkg/authorization/validate.go index 3b71b62af55..a7b5e77329d 100644 --- a/chaoscenter/graphql/server/pkg/authorization/validate.go +++ b/chaoscenter/graphql/server/pkg/authorization/validate.go @@ -3,6 +3,7 @@ package authorization import ( "context" "errors" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/grpc" grpc2 "google.golang.org/grpc" diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go b/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go index 0549277de88..dadee525e95 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go @@ -6,16 +6,17 @@ import ( "encoding/json" "errors" "fmt" + "sort" + "strconv" + "strings" + "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/gitops" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readconcern" "go.mongodb.org/mongo-driver/mongo/writeconcern" - "sort" - "strconv" - "strings" - "time" "github.com/ghodss/yaml" chaosTypes "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1" diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment/service.go b/chaoscenter/graphql/server/pkg/chaos_experiment/service.go index a2a39699597..baac7fb70ec 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment/service.go @@ -5,11 +5,12 @@ import ( "encoding/json" "errors" "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" "strconv" "strings" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" dbChaosExperimentRun "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment_run" "go.mongodb.org/mongo-driver/mongo" diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go index c0779a77d2e..e2b435b47dd 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go @@ -2,6 +2,7 @@ package chaos_infrastructure import ( "fmt" + "github.com/ghodss/yaml" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" @@ -255,11 +256,11 @@ func SendExperimentToSubscriber(projectID string, workflow *model.ChaosExperimen workflowNamespace = utils.Config.InfraNamespace } SendRequestToSubscriber(SubscriberRequests{ - K8sManifest: workflow.ExperimentManifest, - RequestType: reqType, - ProjectID: projectID, - InfraID: workflow.InfraID, - Namespace: workflowNamespace, + K8sManifest: workflow.ExperimentManifest, + RequestType: reqType, + ProjectID: projectID, + InfraID: workflow.InfraID, + Namespace: workflowNamespace, ExternalData: externalData, Username: username, }, *r) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index 7735187863f..775e6340b69 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -4,12 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" - store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/config" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/environments" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/k8s" - "github.com/sirupsen/logrus" "log" "math" "net/http" @@ -17,6 +11,13 @@ import ( "strings" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" + store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/config" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/environments" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/k8s" + "github.com/sirupsen/logrus" + "github.com/google/uuid" "github.com/jinzhu/copier" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" @@ -688,7 +689,6 @@ func (in *infraService) ListInfras(projectID string, request *model.ListInfraReq } newInfras = append(newInfras, &newInfra) - //var updateStatus model.UpdateStatus // Fetching the list of compatible versions diff --git a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go index 1b3b7d4ff9f..0f166030645 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go @@ -2,10 +2,11 @@ package chaoshubops import ( "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "os" "strings" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/transport" diff --git a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go index bf79b7c5b9a..cc8a852100b 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go @@ -2,13 +2,14 @@ package chaoshubops_test import ( "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" - chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" "io/ioutil" "os" "testing" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" + "github.com/gin-gonic/gin" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object" diff --git a/chaoscenter/graphql/server/pkg/chaoshub/ops/sshkey-gen_test.go b/chaoscenter/graphql/server/pkg/chaoshub/ops/sshkey-gen_test.go index 76b928e2d9e..bd05d76aef5 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/sshkey-gen_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/sshkey-gen_test.go @@ -1,9 +1,10 @@ package chaoshubops_test import ( - chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" "testing" + chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" + "github.com/stretchr/testify/assert" ) diff --git a/chaoscenter/graphql/server/pkg/chaoshub/service.go b/chaoscenter/graphql/server/pkg/chaoshub/service.go index 6d417f45abb..4bb8d93eb58 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/service.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/service.go @@ -4,6 +4,11 @@ import ( "context" "errors" "fmt" + "io/ioutil" + "os" + "strconv" + "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/handler" @@ -12,10 +17,6 @@ import ( dbSchemaChaosHub "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" "go.mongodb.org/mongo-driver/mongo" - "io/ioutil" - "os" - "strconv" - "time" "github.com/google/uuid" "github.com/jinzhu/copier" diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/operations.go b/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/operations.go index 0296503bddd..faa8c1faf06 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/operations.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/operations.go @@ -3,6 +3,7 @@ package chaos_hub import ( "context" "fmt" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "go.mongodb.org/mongo-driver/mongo" diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/schema.go b/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/schema.go index f3c667c1736..7e8205f1192 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/schema.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub/schema.go @@ -1,9 +1,10 @@ package chaos_hub import ( + "strconv" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" - "strconv" ) // ChaosHub ... diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/gitops/operations.go b/chaoscenter/graphql/server/pkg/database/mongodb/gitops/operations.go index a44e99b8631..e18f846dee3 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/gitops/operations.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/gitops/operations.go @@ -3,6 +3,7 @@ package gitops import ( "context" "errors" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "go.mongodb.org/mongo-driver/bson" diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/image_registry/operations.go b/chaoscenter/graphql/server/pkg/database/mongodb/image_registry/operations.go index 6dbf30a01cd..789645f9b5b 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/image_registry/operations.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/image_registry/operations.go @@ -2,6 +2,7 @@ package image_registry import ( "context" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "go.mongodb.org/mongo-driver/bson" diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/operations.go b/chaoscenter/graphql/server/pkg/database/mongodb/operations.go index 063ef1e72b9..d5a5606b4e9 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/operations.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/operations.go @@ -2,6 +2,7 @@ package mongodb import ( "context" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/project/operations.go b/chaoscenter/graphql/server/pkg/database/mongodb/project/operations.go index 64b146172fd..6c3a12dd1d6 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/project/operations.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/project/operations.go @@ -2,6 +2,7 @@ package project import ( "context" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/chaoscenter/graphql/server/pkg/gitops/gitops.go b/chaoscenter/graphql/server/pkg/gitops/gitops.go index d7cd746003f..f56e8b859a1 100644 --- a/chaoscenter/graphql/server/pkg/gitops/gitops.go +++ b/chaoscenter/graphql/server/pkg/gitops/gitops.go @@ -5,9 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/gitops" "io" "io/ioutil" "os" @@ -15,6 +12,10 @@ import ( "strings" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/gitops" + "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" diff --git a/chaoscenter/graphql/server/pkg/gitops/service.go b/chaoscenter/graphql/server/pkg/gitops/service.go index f517fff31ac..904c170af61 100644 --- a/chaoscenter/graphql/server/pkg/gitops/service.go +++ b/chaoscenter/graphql/server/pkg/gitops/service.go @@ -4,6 +4,14 @@ import ( "context" "errors" "fmt" + "io/ioutil" + "os" + "path/filepath" + "strconv" + "strings" + "sync" + "time" + "github.com/ghodss/yaml" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" chaos_experiment2 "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment" @@ -14,13 +22,6 @@ import ( "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/gitops" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/grpc" - "io/ioutil" - "os" - "path/filepath" - "strconv" - "strings" - "sync" - "time" "github.com/sirupsen/logrus" "github.com/tidwall/gjson" diff --git a/chaoscenter/graphql/server/pkg/grpc/auth_grpc_client.go b/chaoscenter/graphql/server/pkg/grpc/auth_grpc_client.go index 5ce2afeb8f3..96c9c73ee72 100644 --- a/chaoscenter/graphql/server/pkg/grpc/auth_grpc_client.go +++ b/chaoscenter/graphql/server/pkg/grpc/auth_grpc_client.go @@ -3,6 +3,7 @@ package grpc import ( "context" "errors" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/protos" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" diff --git a/chaoscenter/graphql/server/pkg/handlers/file_handler.go b/chaoscenter/graphql/server/pkg/handlers/file_handler.go index 7a99aead2b7..98cdc119785 100644 --- a/chaoscenter/graphql/server/pkg/handlers/file_handler.go +++ b/chaoscenter/graphql/server/pkg/handlers/file_handler.go @@ -1,12 +1,13 @@ package handlers import ( + "strings" + "github.com/gin-gonic/gin" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" dbChaosInfra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" - "strings" "github.com/sirupsen/logrus" ) diff --git a/chaoscenter/graphql/server/pkg/handlers/readiness_handler.go b/chaoscenter/graphql/server/pkg/handlers/readiness_handler.go index 77f99a73857..98ce0220058 100644 --- a/chaoscenter/graphql/server/pkg/handlers/readiness_handler.go +++ b/chaoscenter/graphql/server/pkg/handlers/readiness_handler.go @@ -2,9 +2,10 @@ package handlers import ( "context" - "github.com/gin-gonic/gin" "net/http" + "github.com/gin-gonic/gin" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" ) diff --git a/chaoscenter/graphql/server/pkg/handlers/status_handler.go b/chaoscenter/graphql/server/pkg/handlers/status_handler.go index ac3c7a30571..ff9278d6e4d 100644 --- a/chaoscenter/graphql/server/pkg/handlers/status_handler.go +++ b/chaoscenter/graphql/server/pkg/handlers/status_handler.go @@ -1,8 +1,9 @@ package handlers import ( - "github.com/gin-gonic/gin" "net/http" + + "github.com/gin-gonic/gin" ) type APIStatus struct { diff --git a/chaoscenter/graphql/server/pkg/image_registry/service.go b/chaoscenter/graphql/server/pkg/image_registry/service.go index 6bdbeb82138..78ad87c29a9 100644 --- a/chaoscenter/graphql/server/pkg/image_registry/service.go +++ b/chaoscenter/graphql/server/pkg/image_registry/service.go @@ -2,14 +2,15 @@ package image_registry import ( "context" + "strconv" + "time" + "github.com/google/uuid" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/image_registry" dbOperationsImageRegistry "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/image_registry" "go.mongodb.org/mongo-driver/bson" - "strconv" - "time" ) // Service is the interface for the image registry service diff --git a/chaoscenter/graphql/server/pkg/k8s/cluster.go b/chaoscenter/graphql/server/pkg/k8s/cluster.go index b9030a172f1..ef8a7fad100 100644 --- a/chaoscenter/graphql/server/pkg/k8s/cluster.go +++ b/chaoscenter/graphql/server/pkg/k8s/cluster.go @@ -5,11 +5,12 @@ import ( "encoding/base64" "errors" "fmt" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" "log" "strconv" "strings" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" + k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/chaoscenter/graphql/server/pkg/projects/project_handler.go b/chaoscenter/graphql/server/pkg/projects/project_handler.go index d1898a1fae7..41a403244eb 100644 --- a/chaoscenter/graphql/server/pkg/projects/project_handler.go +++ b/chaoscenter/graphql/server/pkg/projects/project_handler.go @@ -2,6 +2,7 @@ package projects import ( "context" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/image_registry" diff --git a/chaoscenter/graphql/server/pkg/self-deployer/start.go b/chaoscenter/graphql/server/pkg/self-deployer/start.go index 1138f899adf..2ad0f8af868 100644 --- a/chaoscenter/graphql/server/pkg/self-deployer/start.go +++ b/chaoscenter/graphql/server/pkg/self-deployer/start.go @@ -3,15 +3,17 @@ package self_deployer import ( "context" "encoding/json" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" chaos_infra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/k8s" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" "log" "strings" + + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/k8s" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" ) // StartDeployer registers a new internal self-infra and starts the deployer diff --git a/chaoscenter/graphql/server/protos/authentication.pb.go b/chaoscenter/graphql/server/protos/authentication.pb.go index 3dedcdc16b2..10392c9e53f 100644 --- a/chaoscenter/graphql/server/protos/authentication.pb.go +++ b/chaoscenter/graphql/server/protos/authentication.pb.go @@ -7,10 +7,11 @@ package protos import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -196,7 +197,7 @@ func (x *GetProjectByIdRequest) GetProjectID() string { return "" } -//ProjectMembers is the message struct that holds the details about the project members +// ProjectMembers is the message struct that holds the details about the project members type ProjectMembers struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/chaoscenter/graphql/server/protos/authentication_grpc.pb.go b/chaoscenter/graphql/server/protos/authentication_grpc.pb.go index e0a4033eda8..136d3b3d7d1 100644 --- a/chaoscenter/graphql/server/protos/authentication_grpc.pb.go +++ b/chaoscenter/graphql/server/protos/authentication_grpc.pb.go @@ -8,6 +8,7 @@ package protos import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/chaoscenter/graphql/server/protos/project.pb.go b/chaoscenter/graphql/server/protos/project.pb.go index 8e15d94b9b4..e6ed2b0c37f 100644 --- a/chaoscenter/graphql/server/protos/project.pb.go +++ b/chaoscenter/graphql/server/protos/project.pb.go @@ -7,11 +7,12 @@ package protos import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" - reflect "reflect" - sync "sync" ) const ( diff --git a/chaoscenter/graphql/server/protos/project_grpc.pb.go b/chaoscenter/graphql/server/protos/project_grpc.pb.go index e7eb5ed416e..1bb1e585e35 100644 --- a/chaoscenter/graphql/server/protos/project_grpc.pb.go +++ b/chaoscenter/graphql/server/protos/project_grpc.pb.go @@ -8,6 +8,7 @@ package protos import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/chaoscenter/graphql/server/utils/misc.go b/chaoscenter/graphql/server/utils/misc.go index fd9fa0f0499..1813b00a5b6 100644 --- a/chaoscenter/graphql/server/utils/misc.go +++ b/chaoscenter/graphql/server/utils/misc.go @@ -4,12 +4,13 @@ import ( "bytes" "encoding/base64" "fmt" - "github.com/gin-gonic/gin" "math/rand" "reflect" "strings" "time" + "github.com/gin-gonic/gin" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" "github.com/google/uuid" diff --git a/chaoscenter/subscriber/pkg/events/chaosengine.go b/chaoscenter/subscriber/pkg/events/chaosengine.go index 313b13fec37..ede4b5e7eb8 100644 --- a/chaoscenter/subscriber/pkg/events/chaosengine.go +++ b/chaoscenter/subscriber/pkg/events/chaosengine.go @@ -154,7 +154,7 @@ func chaosEventHandler(obj interface{}, eventType string, stream chan types.Work stream <- workflow } -//StopChaosEngineState is used to patch all the chaosEngines with engineState=stop +// StopChaosEngineState is used to patch all the chaosEngines with engineState=stop func StopChaosEngineState(namespace string, workflowRunID *string) error { ctx := context.TODO() diff --git a/chaoscenter/subscriber/pkg/events/util.go b/chaoscenter/subscriber/pkg/events/util.go index 4e60532865e..3ce917d3de9 100644 --- a/chaoscenter/subscriber/pkg/events/util.go +++ b/chaoscenter/subscriber/pkg/events/util.go @@ -77,7 +77,7 @@ func getChaosData(nodeStatus v1alpha13.NodeStatus, engineName, engineNS string, return cd, nil } -//CheckChaosData util function, checks if event is a chaos-exp event, if so - extract the chaos data +// CheckChaosData util function, checks if event is a chaos-exp event, if so - extract the chaos data func CheckChaosData(nodeStatus v1alpha13.NodeStatus, workflowNS string, chaosClient *v1alpha12.LitmuschaosV1alpha1Client) (string, *types.ChaosData, error) { nodeType := string(nodeStatus.Type) var cd *types.ChaosData = nil @@ -169,7 +169,7 @@ func ListWorkflowObject(wfid string) (*v1alpha1.WorkflowList, error) { return listWf, nil } -//GenerateWorkflowPayload generate graphql mutation payload for events event +// GenerateWorkflowPayload generate graphql mutation payload for events event func GenerateWorkflowPayload(cid, accessKey, version, completed string, wfEvent types.WorkflowEvent) ([]byte, error) { infraID := `{infraID: \"` + cid + `\", version: \"` + version + `\", accessKey: \"` + accessKey + `\"}` for id, event := range wfEvent.Nodes { diff --git a/chaoscenter/subscriber/pkg/graphql/operations.go b/chaoscenter/subscriber/pkg/graphql/operations.go index 15a96429eb3..8ae980ee838 100644 --- a/chaoscenter/subscriber/pkg/graphql/operations.go +++ b/chaoscenter/subscriber/pkg/graphql/operations.go @@ -29,7 +29,7 @@ func SendRequest(server string, payload []byte) (string, error) { return string(body), nil } -//MarshalGQLData processes event data into proper format acceptable by graphql +// MarshalGQLData processes event data into proper format acceptable by graphql func MarshalGQLData(gqlData interface{}) (string, error) { data, err := json.Marshal(gqlData) if err != nil { diff --git a/chaoscenter/subscriber/pkg/k8s/client.go b/chaoscenter/subscriber/pkg/k8s/client.go index 62f834bb3a7..01b2f5536f0 100644 --- a/chaoscenter/subscriber/pkg/k8s/client.go +++ b/chaoscenter/subscriber/pkg/k8s/client.go @@ -12,7 +12,7 @@ import ( var KubeConfig *string -//getKubeConfig setup the config for access cluster resource +// getKubeConfig setup the config for access cluster resource func GetKubeConfig() (*rest.Config, error) { // Use in-cluster config if kubeconfig path is not specified if *KubeConfig == "" { @@ -30,7 +30,7 @@ func GetGenericK8sClient() (*kubernetes.Clientset, error) { return kubernetes.NewForConfig(config) } -//This function returns dynamic client and discovery client +// This function returns dynamic client and discovery client func GetDynamicAndDiscoveryClient() (discovery.DiscoveryInterface, dynamic.Interface, error) { // returns a config object which uses the service account kubernetes gives to pods config, err := GetKubeConfig() diff --git a/chaoscenter/subscriber/pkg/k8s/operations.go b/chaoscenter/subscriber/pkg/k8s/operations.go index dec65cb72f4..9c3b2c92697 100644 --- a/chaoscenter/subscriber/pkg/k8s/operations.go +++ b/chaoscenter/subscriber/pkg/k8s/operations.go @@ -5,11 +5,12 @@ import ( "encoding/base64" "errors" "fmt" - "k8s.io/apimachinery/pkg/labels" "strings" "sync" "time" + "k8s.io/apimachinery/pkg/labels" + "subscriber/pkg/graphql" "subscriber/pkg/types" diff --git a/chaoscenter/subscriber/pkg/utils/workflow.go b/chaoscenter/subscriber/pkg/utils/workflow.go index 7b314fac884..b397724e8ff 100644 --- a/chaoscenter/subscriber/pkg/utils/workflow.go +++ b/chaoscenter/subscriber/pkg/utils/workflow.go @@ -2,11 +2,12 @@ package utils import ( "context" + "subscriber/pkg/events" + "subscriber/pkg/k8s" + wfclientset "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "subscriber/pkg/events" - "subscriber/pkg/k8s" ) func WorkflowRequest(agentData map[string]string, requestType string, externalData string, uuid string) error { diff --git a/chaoscenter/web/Dockerfile b/chaoscenter/web/Dockerfile index 1d9a0aa0f33..9ade3067602 100644 --- a/chaoscenter/web/Dockerfile +++ b/chaoscenter/web/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7 +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 RUN microdnf module enable nginx:1.20 RUN microdnf install nginx diff --git a/litmus-portal/deprecated-github-workflows/build-deprecated.yml b/litmus-portal/deprecated-github-workflows/build-deprecated.yml new file mode 100644 index 00000000000..952ce6f8614 --- /dev/null +++ b/litmus-portal/deprecated-github-workflows/build-deprecated.yml @@ -0,0 +1,255 @@ +name: build-pipeline +on: + pull_request: + branches: + - master + - v* + +env: + DOCKER_BUILDKIT: 1 # Enable Docker_buildkit in all build jobs + +jobs: + changes: + runs-on: ubuntu-latest + # Set job outputs to values from filter step + outputs: + frontend: ${{ steps.filter.outputs.frontend }} + graphql-server: ${{ steps.filter.outputs.graphql-server }} + authentication: ${{ steps.filter.outputs.authentication }} + event-tracker: ${{ steps.filter.outputs.event-tracker }} + upgrade-agent-cp: ${{ steps.filter.outputs.upgrade-agent-cp }} + subscriber: ${{ steps.filter.outputs.subscriber }} + litmus-demo: ${{ steps.filter.outputs.litmus-demo }} + dex-server: ${{ steps.filter.outputs.dex-server }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + frontend: + - 'litmus-portal/frontend/**' + graphql-server: + - 'litmus-portal/graphql-server/**' + authentication: + - 'litmus-portal/authentication/**' + event-tracker: + - 'litmus-portal/cluster-agents/event-tracker/**' + upgrade-agent-cp: + - 'litmus-portal/upgrade-agents/control-plane/**' + subscriber: + - 'litmus-portal/cluster-agents/subscriber/**' + litmus-demo: + - 'demo/1.x/**' + dex-server: + - 'litmus-portal/dex-server/**' + + backend-checks: + runs-on: ubuntu-latest + needs: changes + if: needs.changes.outputs.graphql-server == 'true' || needs.changes.outputs.dex-server == 'true' || needs.changes.outputs.upgrade-agent-cp == 'true' || needs.changes.outputs.authentication == 'true' || needs.changes.outputs.event-tracker == 'true' || needs.changes.outputs.subscriber == 'true' + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "1.16" # By default, the go version is v1.15 in runner. + - name: Check Golang imports order + uses: Jerome1337/goimports-action@v1.0.3 + with: + goimports-path: ./litmus-portal + - name: Backend checks + shell: bash + run: | + cd litmus-portal + make backend-services-checks + + frontend-checks: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.frontend == 'true' }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 16.14.2 + - name: Frontend checks + shell: bash + run: | + cd litmus-portal + make frontend-services-checks + + backend-unit-tests: + runs-on: ubuntu-latest + needs: + - changes + - backend-checks + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "1.16" # By default, the go version is v1.15 in runner. + - name: Backend unit tests + shell: bash + run: | + cd litmus-portal + make unit-tests + + docker-build-graphql-server: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: ${{ needs.changes.outputs.graphql-server == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build graphql server docker image + shell: bash + run: | + cd litmus-portal/graphql-server + docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-server:${{ github.sha }} --build-arg TARGETARCH=amd64 + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'docker.io/litmuschaos/litmusportal-server:${{ github.sha }}' + format: 'table' + exit-code: '0' + ignore-unfixed: true + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' + + docker-build-authentication-server: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: ${{ needs.changes.outputs.authentication == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build auth server docker image + shell: bash + run: | + cd litmus-portal/authentication + docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-auth-server:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'docker.io/litmuschaos/litmusportal-auth-server:${{ github.sha }}' + format: 'table' + exit-code: '1' + ignore-unfixed: true + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' + + docker-build-subscriber: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: ${{ needs.changes.outputs.subscriber == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build subscriber docker image + shell: bash + run: | + cd litmus-portal/cluster-agents/subscriber + docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-subscriber:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'docker.io/litmuschaos/litmusportal-subscriber:${{ github.sha }}' + format: 'table' + exit-code: '0' + ignore-unfixed: true + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' + + docker-build-event-tracker: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: ${{ needs.changes.outputs.event-tracker == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build event tracker docker image + shell: bash + run: | + cd litmus-portal/cluster-agents/event-tracker + docker build . -f Dockerfile -t docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'docker.io/litmuschaos/litmusportal-event-tracker:${{ github.sha }}' + format: 'table' + exit-code: '1' + ignore-unfixed: true + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' + + docker-build-upgrade-agent-cp: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: ${{ needs.changes.outputs.upgrade-agent-cp == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build control plane upgrade agent docker image + shell: bash + run: | + cd litmus-portal/upgrade-agents/control-plane + docker build . -f Dockerfile -t docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }} --build-arg TARGETARCH=amd64 + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'docker.io/litmuschaos/upgrade-agent-cp:${{ github.sha }}' + format: 'table' + exit-code: '1' + ignore-unfixed: true + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' + + docker-build-frontend: + runs-on: ubuntu-latest + needs: + - frontend-checks + - changes + if: ${{ needs.changes.outputs.frontend == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build frontend docker image + shell: bash + run: | + cd litmus-portal/frontend + docker build . -f Dockerfile --build-arg TARGETARCH=amd64 + + docker-build-dex-server: + runs-on: ubuntu-latest + needs: + - backend-checks + - changes + - backend-unit-tests + if: needs.changes.outputs.dex-server == 'true' + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build dex-server docker image + shell: bash + run: | + cd litmus-portal/dex-server + docker images && docker build . -f Dockerfile --build-arg TARGETARCH=amd64 diff --git a/litmus-portal/deprecated-github-workflows/push-deprecated.yml b/litmus-portal/deprecated-github-workflows/push-deprecated.yml new file mode 100644 index 00000000000..6ee9c54509c --- /dev/null +++ b/litmus-portal/deprecated-github-workflows/push-deprecated.yml @@ -0,0 +1,350 @@ +# name: push-pipeline +# on: +# push: +# branches: +# - master +# - ^v[0-9]*.[0-9]*.x$ +# tags: +# - "*" +# defaults: +# run: +# working-directory: litmus-portal +# shell: bash + +# jobs: +# backend-checks: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 +# - uses: actions/setup-go@v2 +# with: +# go-version: "1.16" # By default, the go version is v1.15 in runner. +# - run: | +# make backend-services-checks + +# frontend-checks: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 +# - uses: actions/setup-node@v3 +# with: +# node-version: 16.14.2 +# - run: | +# make frontend-services-checks + +# get-envs: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 +# - run: | +# img_tag="" +# array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`) +# if [ ${array[1]} == "tags" ] +# then +# echo "tag build" +# img_tag=${GITHUB_REF#refs/*/} +# else +# echo "non tag build" +# img_tag="ci" +# fi +# # This is a condition where image tag looks like "pull/" during pull request build +# NEW_IMG_TAG=`echo $img_tag | sed "s/\//-/g"` +# echo $NEW_IMG_TAG +# echo export IMG_TAG=$NEW_IMG_TAG >> env-vars +# echo export GRAPHQL_SERVER_IMAGE="litmusportal-server" >> env-vars +# echo export AUTHENTICATION_SERVER_IMAGE="litmusportal-auth-server" >> env-vars +# echo export FRONTEND_IMAGE="litmusportal-frontend" >> env-vars +# echo export SUBSCRIBER_IMAGE="litmusportal-subscriber" >> env-vars +# echo export EVENT_TRACKER="litmusportal-event-tracker" >> env-vars +# echo export UPGRADE_AGENT_CP="upgrade-agent-cp" >> env-vars +# echo export DEX_SERVER="litmusportal-dex-server" >> env-vars + +# - name: Uploading envs +# uses: actions/upload-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal/env-vars + +# docker-build-and-push-graphql-server: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push graphql server docker image +# env: +# IMAGE_NAME: ${GRAPHQL_SERVER_IMAGE} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "graphql-server" +# run: | +# source env-vars +# make push-portal-component + +# docker-build-and-push-authentication-server: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push auth server docker image +# env: +# IMAGE_NAME: ${AUTHENTICATION_SERVER_IMAGE} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "authentication" +# run: | +# source env-vars +# make push-portal-component + +# docker-build-and-push-subscriber: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push subscriber docker image +# env: +# IMAGE_NAME: ${SUBSCRIBER_IMAGE} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "cluster-agents/subscriber/" +# run: | +# source env-vars +# make push-portal-component + +# docker-build-and-push-event-tracker: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push event tracker docker image +# env: +# IMAGE_NAME: ${EVENT_TRACKER} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "cluster-agents/event-tracker/" +# run: | +# source env-vars +# make push-portal-component + +# docker-build-and-push-upgrade-agent-cp: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push control plane upgrade agent docker image +# env: +# IMAGE_NAME: ${UPGRADE_AGENT_CP} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "upgrade-agents/control-plane/" +# run: | +# source env-vars +# make push-portal-component + +# ## TODO: the build time for multiarch frontend image is higher so it is used in the release +# ## builds only need to optimize the build duration and also add it with ci tag +# ## Build and push / base path +# docker-build-and-push-frontend: +# runs-on: ubuntu-latest +# strategy: +# matrix: +# frontend: +# [ +# { "image_name": "litmusportal-frontend", "path": "" }, +# { +# "image_name": "litmusportal-frontend-path-litmuschaos", +# "path": "/litmuschaos", +# }, +# ] +# needs: +# - get-envs +# - frontend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push frontend docker image ( ${{ matrix.frontend.image_name }} ) +# env: +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# timestamp: ${timestamp} +# PUBLIC_URL: ${{ matrix.frontend.path }} +# run: | +# source env-vars +# FRONTEND_IMAGE=${{ matrix.frontend.image_name }} +# timestamp=`date "+%s"` +# make push-frontend + +# docker-build-and-push-dex-server: +# runs-on: ubuntu-latest +# needs: +# - get-envs +# - backend-checks +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Downloading image artficate +# uses: actions/download-artifact@v2 +# with: +# name: env_artifact +# path: litmus-portal + +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@v1 +# with: +# version: latest + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Push dex server docker image +# env: +# IMAGE_NAME: ${DEX_SERVER} +# IMG_TAG: ${IMG_TAG} +# PLATFORMS: ${{ secrets.PLATFORMS }} +# REPONAME: ${{ secrets.REPONAME }} +# DIRECTORY: "dex-server" +# run: | +# source env-vars +# make push-portal-component