From 5449439d8ca5bf7d2977dc47ebbf86965665f1de Mon Sep 17 00:00:00 2001 From: Kanhaiya yadav <93936630+kanhaiya04@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:00:26 +0530 Subject: [PATCH 01/10] pagination is now working for environment (#4470) Signed-off-by: kanhaiya04 --- chaoscenter/web/src/controllers/Environments/Environment.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chaoscenter/web/src/controllers/Environments/Environment.tsx b/chaoscenter/web/src/controllers/Environments/Environment.tsx index 1bf5d2517ca..2abb02dfd08 100644 --- a/chaoscenter/web/src/controllers/Environments/Environment.tsx +++ b/chaoscenter/web/src/controllers/Environments/Environment.tsx @@ -15,7 +15,7 @@ const EnvironmentController: React.FC = () => { // State for pagination const page = parseInt(searchParams.get('page') ?? '0'); - const limit = parseInt(searchParams.get('limit') ?? '15'); + const limit = parseInt(searchParams.get('limit') ?? '5'); const setPage = (newPage: number): void => updateSearchParams({ page: newPage.toString() }); const setLimit = (newLimit: number): void => updateSearchParams({ limit: newLimit.toString() }); @@ -27,7 +27,7 @@ const EnvironmentController: React.FC = () => { } = listEnvironment({ projectID: scope.projectID, environmentIDs: [], - pagination: { page, limit: 5 }, + pagination: { page, limit }, options: { onError: err => showError(err.message), fetchPolicy: 'cache-first' @@ -57,7 +57,6 @@ const EnvironmentController: React.FC = () => { const environments = envData?.listEnvironments.environments; const totalEnvironments = envData?.listEnvironments.totalNoOfEnvironments; - const environmentTableData: EnvironmentDetailsTableProps | undefined = environments && { content: generateEnvironmentTableContent(environments), pagination: { From da8ae756998bfb388972d9536d223d57a6e5ce47 Mon Sep 17 00:00:00 2001 From: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:05:21 +0900 Subject: [PATCH 02/10] Replace deprecated package (#4475) * fix: replace deprecated library in chaoscenter/graphql Signed-off-by: namkyu1999 * fix: replace deprecated library in authentication server Signed-off-by: namkyu1999 * fix: replace deprecated library in subscriber Signed-off-by: namkyu1999 * fix: resolve security issue Signed-off-by: namkyu1999 * fix: update codeql version Signed-off-by: namkyu1999 --------- Signed-off-by: namkyu1999 --- .github/workflows/codeql-analysis.yml | 6 +- .../api/handlers/rest/user_handlers_test.go | 8 +- .../pkg/chaos_infrastructure/infra_utils.go | 18 +++-- .../server/pkg/chaoshub/handler/handler.go | 74 +++++++++++++------ .../pkg/chaoshub/handler/handler_test.go | 14 ++-- .../server/pkg/chaoshub/ops/gitops_test.go | 4 +- .../graphql/server/pkg/chaoshub/service.go | 33 ++++----- .../graphql/server/pkg/gitops/gitops.go | 13 ++-- .../graphql/server/pkg/gitops/service.go | 48 ++++++------ chaoscenter/subscriber/go.sum | 1 + .../subscriber/pkg/graphql/operations.go | 13 +++- 11 files changed, 133 insertions(+), 99 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fa8946a4009..b36af186eda 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -54,7 +54,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -68,4 +68,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go b/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go index e06e4b29645..157b101c3a3 100644 --- a/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go +++ b/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "errors" - "io/ioutil" + "io" "log" "net/http" "net/http/httptest" @@ -26,7 +26,7 @@ import ( // TestMain is the entry point for testing func TestMain(m *testing.M) { gin.SetMode(gin.TestMode) - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) os.Exit(m.Run()) } @@ -516,7 +516,7 @@ func TestResetPassword(t *testing.T) { c := GetTestGinContext(w) c.Request.Method = http.MethodPost bodyBytes, _ := json.Marshal(tt.inputBody) - c.Request.Body = ioutil.NopCloser(bytes.NewReader([]byte(bodyBytes))) + c.Request.Body = io.NopCloser(bytes.NewReader(bodyBytes)) c.Set("role", tt.mockRole) c.Set("uid", tt.mockUID) c.Set("username", tt.mockUsername) @@ -592,7 +592,7 @@ func TestUpdateUserState(t *testing.T) { c := GetTestGinContext(w) c.Request.Method = http.MethodPost bodyBytes, _ := json.Marshal(tc.inputBody) - c.Request.Body = ioutil.NopCloser(bytes.NewReader([]byte(bodyBytes))) + c.Request.Body = io.NopCloser(bytes.NewReader([]byte(bodyBytes))) c.Set("role", tc.mockRole) c.Set("uid", tc.mockUID) c.Set("username", tc.mockUsername) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go index d28acc65ac9..0a780186311 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go @@ -2,6 +2,8 @@ package chaos_infrastructure import ( "fmt" + "os" + "strings" "github.com/ghodss/yaml" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" @@ -9,12 +11,8 @@ import ( dbChaosInfra "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" - "github.com/sirupsen/logrus" + log "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - - "io/ioutil" - "os" - "strings" ) type SubscriberConfigurations struct { @@ -65,7 +63,7 @@ func GetK8sInfraYaml(infra dbChaosInfra.ChaosInfra) ([]byte, error) { } else if infra.InfraScope == NamespaceScope { respData, err = ManifestParser(infra, "manifests/namespace", &config) } else { - logrus.Error("INFRA_SCOPE env is empty!") + log.Error("INFRA_SCOPE env is empty!") } if err != nil { return nil, err @@ -129,7 +127,11 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs return nil, fmt.Errorf("failed to open the file %v", err) } - defer file.Close() + defer func() { + if err := file.Close(); err != nil { + log.Warnf("failed to close file: %v", err) + } + }() list, err := file.Readdirnames(0) // 0 to read all files and folders if err != nil { @@ -174,7 +176,7 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs } for _, fileName := range list { - fileContent, err := ioutil.ReadFile(rootPath + "/" + fileName) + fileContent, err := os.ReadFile(rootPath + "/" + fileName) if err != nil { return nil, fmt.Errorf("failed to read the file %v", err) } diff --git a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go index a9af8cf6f97..63e027ce58d 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" + "path" "path/filepath" "strconv" "strings" @@ -17,9 +17,7 @@ import ( chaoshubops "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" - log "github.com/sirupsen/logrus" - "gopkg.in/yaml.v2" ) @@ -37,9 +35,9 @@ func GetChartsPath(chartsInput model.CloningInput, projectID string, isDefault b } // GetChartsData is used to get details of charts like experiments. -func GetChartsData(ChartsPath string) ([]*model.Chart, error) { +func GetChartsData(chartsPath string) ([]*model.Chart, error) { var allChartsDetails []ChaosChart - Charts, err := ioutil.ReadDir(ChartsPath) + Charts, err := os.ReadDir(path.Clean(chartsPath)) if err != nil { log.Error("file reading error", err) return nil, err @@ -48,7 +46,7 @@ func GetChartsData(ChartsPath string) ([]*model.Chart, error) { if chart.Name() == "icons" { continue } - chartDetails, _ := ReadExperimentFile(ChartsPath + chart.Name() + "/" + chart.Name() + ".chartserviceversion.yaml") + chartDetails, _ := ReadExperimentFile(chartsPath + chart.Name() + "/" + chart.Name() + ".chartserviceversion.yaml") allChartsDetails = append(allChartsDetails, chartDetails) } @@ -77,14 +75,17 @@ func GetExperimentData(experimentFilePath string) (*model.Chart, error) { return nil, err } var chartData *model.Chart - json.Unmarshal(e, &chartData) + err = json.Unmarshal(e, &chartData) + if err != nil { + return nil, err + } return chartData, nil } // ReadExperimentFile is used for reading experiment file from given path -func ReadExperimentFile(path string) (ChaosChart, error) { +func ReadExperimentFile(givenPath string) (ChaosChart, error) { var experiment ChaosChart - experimentFile, err := ioutil.ReadFile(path) + experimentFile, err := os.ReadFile(path.Clean(givenPath)) if err != nil { return experiment, fmt.Errorf("file path of the, err: %+v", err) } @@ -97,7 +98,7 @@ func ReadExperimentFile(path string) (ChaosChart, error) { // ReadExperimentYAMLFile is used for reading experiment/engine file from given path func ReadExperimentYAMLFile(path string) (string, error) { var s string - YAMLData, err := ioutil.ReadFile(path) + YAMLData, err := os.ReadFile(path) if err != nil { return s, fmt.Errorf("file path of the, err: %+v", err) } @@ -110,7 +111,7 @@ func ReadExperimentYAMLFile(path string) (string, error) { func ListPredefinedWorkflowDetails(name string, projectID string) ([]*model.PredefinedExperimentList, error) { experimentsPath := DefaultPath + projectID + "/" + name + "/workflows" var predefinedWorkflows []*model.PredefinedExperimentList - files, err := ioutil.ReadDir(experimentsPath) + files, err := os.ReadDir(experimentsPath) if err != nil { return nil, err } @@ -160,13 +161,17 @@ func DownloadRemoteHub(hubDetails model.CreateRemoteChaosHub, projectID string) return err } //create the destination directory where the hub will be downloaded - hubpath := dirPath + "/" + hubDetails.Name + ".zip" - destDir, err := os.Create(hubpath) + hubPath := dirPath + "/" + hubDetails.Name + ".zip" + destDir, err := os.Create(path.Clean(hubPath)) if err != nil { log.Error(err) return err } - defer destDir.Close() + defer func() { + if err := destDir.Close(); err != nil { + log.Warnf("failed to close dir: %v", err) + } + }() //download the zip file from the provided url download, err := http.Get(hubDetails.RepoURL) @@ -175,7 +180,11 @@ func DownloadRemoteHub(hubDetails model.CreateRemoteChaosHub, projectID string) return err } - defer download.Body.Close() + defer func() { + if err := download.Body.Close(); err != nil { + log.Warnf("failed to close body: %v", err) + } + }() if download.StatusCode != http.StatusOK { return fmt.Errorf("err: " + download.Status) @@ -189,14 +198,14 @@ func DownloadRemoteHub(hubDetails model.CreateRemoteChaosHub, projectID string) contentLength := download.Header.Get("content-length") length, err := strconv.Atoi(contentLength) if length > maxSize { - _ = os.Remove(hubpath) + _ = os.Remove(path.Clean(hubPath)) return fmt.Errorf("err: File size exceeded the threshold %d", length) } //validate the content-type contentType := download.Header.Get("content-type") if contentType != "application/zip" { - _ = os.Remove(hubpath) + _ = os.Remove(path.Clean(hubPath)) return fmt.Errorf("err: Invalid file type %s", contentType) } @@ -208,13 +217,13 @@ func DownloadRemoteHub(hubDetails model.CreateRemoteChaosHub, projectID string) } //unzip the ChaosHub to the default hub directory - err = UnzipRemoteHub(hubpath, hubDetails, projectID) + err = UnzipRemoteHub(hubPath, projectID) if err != nil { return err } //remove the redundant zip file - err = os.Remove(hubpath) + err = os.Remove(path.Clean(hubPath)) if err != nil { return err } @@ -222,16 +231,24 @@ func DownloadRemoteHub(hubDetails model.CreateRemoteChaosHub, projectID string) } // UnzipRemoteHub is used to unzip the zip file -func UnzipRemoteHub(zipPath string, hubDetails model.CreateRemoteChaosHub, projectID string) error { +func UnzipRemoteHub(zipPath string, projectID string) error { extractPath := DefaultPath + projectID zipReader, err := zip.OpenReader(zipPath) if err != nil { log.Error(err) return err } - defer zipReader.Close() + defer func() { + if err := zipReader.Close(); err != nil { + log.Warnf("failed to close reader: %v", err) + } + }() + for _, file := range zipReader.File { - CopyZipItems(file, extractPath, file.Name) + err := CopyZipItems(file, extractPath, file.Name) + if err != nil { + return err + } } return nil } @@ -260,9 +277,18 @@ func CopyZipItems(file *zip.File, extractPath string, chartsPath string) error { if err != nil { log.Error(err) } - fileCopy.Close() + defer func() { + if err := fileCopy.Close(); err != nil { + log.Warnf("failed to close file: %v", err) + } + }() + } - fileReader.Close() + defer func() { + if err := fileReader.Close(); err != nil { + log.Warnf("failed to close file: %v", err) + } + }() return nil } diff --git a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_test.go b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_test.go index 54ad7b63a0a..ffcd2106ac3 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler_test.go @@ -1,18 +1,16 @@ package handler_test import ( - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/handler" - chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" - "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" - - "io/ioutil" + "io" "os" "testing" "github.com/gin-gonic/gin" "github.com/google/uuid" - + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/handler" + chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) @@ -20,7 +18,7 @@ import ( // TestMain is the entry point for testing func TestMain(m *testing.M) { gin.SetMode(gin.TestMode) - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) os.Exit(m.Run()) } diff --git a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go index b4e34a85f75..3494fb17970 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go @@ -2,7 +2,7 @@ package chaoshubops_test import ( "fmt" - "io/ioutil" + "io" "os" "testing" "time" @@ -25,7 +25,7 @@ var ( // TestMain is the entry point for testing func TestMain(m *testing.M) { gin.SetMode(gin.TestMode) - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) os.Exit(m.Run()) } diff --git a/chaoscenter/graphql/server/pkg/chaoshub/service.go b/chaoscenter/graphql/server/pkg/chaoshub/service.go index 278b14dec41..5d0a78255e9 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/service.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/service.go @@ -4,11 +4,13 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" + "path" "strconv" "time" + "github.com/google/uuid" + "github.com/jinzhu/copier" "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" @@ -16,13 +18,9 @@ import ( "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" 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" - - "github.com/google/uuid" - "github.com/jinzhu/copier" - log "github.com/sirupsen/logrus" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" ) const ( @@ -480,22 +478,22 @@ func (c *chaosHubService) GetChaosFault(ctx context.Context, request model.Exper } //Get fault chartserviceversion.yaml data - csvPath := basePath + "/" + request.ExperimentName + ".chartserviceversion.yaml" - csvYaml, err := ioutil.ReadFile(csvPath) + csvPath := path.Clean(basePath + "/" + request.ExperimentName + ".chartserviceversion.yaml") + csvYaml, err := os.ReadFile(csvPath) if err != nil { csvYaml = []byte("") } //Get engine.yaml data - enginePath := basePath + "/" + "engine.yaml" - engineYaml, err := ioutil.ReadFile(enginePath) + enginePath := path.Clean(basePath + "/" + "engine.yaml") + engineYaml, err := os.ReadFile(enginePath) if err != nil { engineYaml = []byte("") } //Get fault.yaml data - faultPath := basePath + "/" + "fault.yaml" - faultYaml, err := ioutil.ReadFile(faultPath) + faultPath := path.Clean(basePath + "/" + "fault.yaml") + faultYaml, err := os.ReadFile(faultPath) if err != nil { faultYaml = []byte("") } @@ -729,8 +727,9 @@ func (c *chaosHubService) ListPredefinedExperiments(ctx context.Context, hubID s } else { hubPath = DefaultPath + projectID + "/" + hub.Name + "/experiments/" } + hubPath = path.Clean(hubPath) var predefinedWorkflows []*model.PredefinedExperimentList - files, err := ioutil.ReadDir(hubPath) + files, err := os.ReadDir(hubPath) if err != nil { return nil, err } @@ -803,24 +802,24 @@ func (c *chaosHubService) getPredefinedExperimentDetails(experimentsPath string, var ( csvManifest = "" workflowManifest = "" - path = experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml" + predefinedPath = experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml" isExist = true preDefinedWorkflow = &model.PredefinedExperimentList{} ) - _, err := os.Stat(path) + _, err := os.Stat(predefinedPath) if err != nil { isExist = false } if isExist { - yamlData, err := ioutil.ReadFile(experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml") + yamlData, err := os.ReadFile(path.Clean(experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml")) if err != nil { csvManifest = "" } csvManifest = string(yamlData) - yamlData, err = ioutil.ReadFile(experimentsPath + experiment + "/" + "experiment.yaml") + yamlData, err = os.ReadFile(path.Clean(experimentsPath + experiment + "/" + "experiment.yaml")) if err != nil { workflowManifest = "" } diff --git a/chaoscenter/graphql/server/pkg/gitops/gitops.go b/chaoscenter/graphql/server/pkg/gitops/gitops.go index 864297c4780..a37ac869dd3 100644 --- a/chaoscenter/graphql/server/pkg/gitops/gitops.go +++ b/chaoscenter/graphql/server/pkg/gitops/gitops.go @@ -6,16 +6,12 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" + "path" "strconv" "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" @@ -23,6 +19,9 @@ import ( "github.com/go-git/go-git/v5/plumbing/transport/http" "github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/golang-jwt/jwt" + "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" log "github.com/sirupsen/logrus" ssh2 "golang.org/x/crypto/ssh" ) @@ -113,7 +112,7 @@ func (c GitConfig) setupGitRepo(user GitUser) error { gitInfo := map[string]string{"projectID": c.ProjectID, "revision": "1"} if exists { - data, err := ioutil.ReadFile(projectPath + "/.info") + data, err := os.ReadFile(path.Clean(projectPath + "/.info")) if err != nil { return errors.New("can't read existing git info file " + err.Error()) } @@ -137,7 +136,7 @@ func (c GitConfig) setupGitRepo(user GitUser) error { if err != nil { return err } - err = ioutil.WriteFile(projectPath+"/.info", data, 0644) + err = os.WriteFile(path.Clean(projectPath+"/.info"), data, 0644) if err != nil { return err } diff --git a/chaoscenter/graphql/server/pkg/gitops/service.go b/chaoscenter/graphql/server/pkg/gitops/service.go index 9fbb662fecd..0f8cd1e108c 100644 --- a/chaoscenter/graphql/server/pkg/gitops/service.go +++ b/chaoscenter/graphql/server/pkg/gitops/service.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -12,19 +11,18 @@ import ( "sync" "time" - chaosExperimentOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops" - "github.com/ghodss/yaml" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" - chaos_infra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" - data_store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" + chaosExperimentOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops" + chaosInfra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" + dataStore "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store" "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment" "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" - "github.com/sirupsen/logrus" + log "github.com/sirupsen/logrus" "github.com/tidwall/gjson" "github.com/tidwall/sjson" "go.mongodb.org/mongo-driver/bson" @@ -68,7 +66,7 @@ func NewGitOpsService(gitOpsOperator *gitops.Operator, chaosExperimentService ch } } -// GitOpsNotificationHandler sends experiment run request(single run experiment only) to agent on gitops notification +// GitOpsNotificationHandler sends experiment run request(single run experiment only) to agent on GitOps notification func (g *gitOpsService) GitOpsNotificationHandler(ctx context.Context, infra chaos_infrastructure.ChaosInfra, experimentID string) (string, error) { gitLock.Lock(infra.ProjectID, nil) defer gitLock.Unlock(infra.ProjectID, nil) @@ -77,7 +75,7 @@ func (g *gitOpsService) GitOpsNotificationHandler(ctx context.Context, infra cha return "", errors.New("Cannot get Git Config from DB : " + err.Error()) } if config == nil { - return "Gitops Disabled", nil + return "GitOps Disabled", nil } query := bson.D{{"infra_id", infra.InfraID}, {"experiment_id", experimentID}, {"is_removed", false}} experiments, err := g.chaosExperimentOps.GetExperiments(query) @@ -99,7 +97,7 @@ func (g *gitOpsService) GitOpsNotificationHandler(ctx context.Context, infra cha } username := "git-ops" - chaos_infra.SendExperimentToSubscriber(experiments[0].ProjectID, &model.ChaosExperimentRequest{ + chaosInfra.SendExperimentToSubscriber(experiments[0].ProjectID, &model.ChaosExperimentRequest{ ExperimentManifest: experiments[0].Revision[len(experiments[0].Revision)-1].ExperimentManifest, InfraID: experiments[0].InfraID, }, &username, nil, "create", store.Store) @@ -107,7 +105,7 @@ func (g *gitOpsService) GitOpsNotificationHandler(ctx context.Context, infra cha return "Request Acknowledged for experimentID: " + experimentID, nil } -// EnableGitOpsHandler enables gitops for a particular project +// EnableGitOpsHandler enables GitOps for a particular project func (g *gitOpsService) EnableGitOpsHandler(ctx context.Context, projectID string, config model.GitConfig) (bool, error) { gitLock.Lock(projectID, nil) defer gitLock.Unlock(projectID, nil) @@ -117,14 +115,18 @@ func (g *gitOpsService) EnableGitOpsHandler(ctx context.Context, projectID strin var conn *grpc2.ClientConn client, conn := grpc.GetAuthGRPCSvcClient(conn) - defer conn.Close() + defer func() { + if err := conn.Close(); err != nil { + log.Warnf("failed to close connection: %v", err) + } + }() _, err := grpc.GetProjectById(client, projectID) if err != nil { return false, errors.New("Failed to setup GitOps : " + err.Error()) } - logrus.Info("Enabling Gitops") + logrus.Info("Enabling GitOps") gitDB := gitops.GetGitConfigDB(projectID, config) commit, err := SetupGitOps(GitUserFromContext(ctx), GetGitOpsConfig(gitDB)) @@ -141,12 +143,12 @@ func (g *gitOpsService) EnableGitOpsHandler(ctx context.Context, projectID strin return true, nil } -// DisableGitOpsHandler disables gitops for a specific project +// DisableGitOpsHandler disables GitOps for a specific project func (g *gitOpsService) DisableGitOpsHandler(ctx context.Context, projectID string) (bool, error) { gitLock.Lock(projectID, nil) defer gitLock.Unlock(projectID, nil) - logrus.Info("Disabling Gitops") + logrus.Info("Disabling GitOps") err := g.gitOpsOperator.DeleteGitConfig(ctx, projectID) if err != nil { return false, errors.New("Failed to delete git config from DB : " + err.Error()) @@ -160,7 +162,7 @@ func (g *gitOpsService) DisableGitOpsHandler(ctx context.Context, projectID stri return true, nil } -// UpdateGitOpsDetailsHandler updates an exiting gitops config for a project +// UpdateGitOpsDetailsHandler updates an exiting GitOps config for a project func (g *gitOpsService) UpdateGitOpsDetailsHandler(ctx context.Context, projectID string, config model.GitConfig) (bool, error) { gitLock.Lock(projectID, nil) defer gitLock.Unlock(projectID, nil) @@ -176,7 +178,7 @@ func (g *gitOpsService) UpdateGitOpsDetailsHandler(ctx context.Context, projectI return false, errors.New("GitOps Disabled ") } - logrus.Info("Enabling Gitops") + logrus.Info("Enabling GitOps") gitDB := gitops.GetGitConfigDB(projectID, config) gitConfig := GetGitOpsConfig(gitDB) @@ -205,7 +207,7 @@ func (g *gitOpsService) UpdateGitOpsDetailsHandler(ctx context.Context, projectI return true, nil } -// GetGitOpsDetails returns the current gitops config for the requested project +// GetGitOpsDetails returns the current GitOps config for the requested project func (g *gitOpsService) GetGitOpsDetails(ctx context.Context, projectID string) (*model.GitConfigResponse, error) { gitLock.Lock(projectID, nil) defer gitLock.Unlock(projectID, nil) @@ -269,7 +271,7 @@ func (g *gitOpsService) UpsertExperimentToGit(ctx context.Context, projectID str return errors.New("Cannot convert manifest to yaml : " + err.Error()) } - err = ioutil.WriteFile(experimentPath, data, 0644) + err = os.WriteFile(experimentPath, data, 0644) if err != nil { return errors.New("Cannot write experiment to git : " + err.Error()) } @@ -468,7 +470,7 @@ func (g *gitOpsService) SyncDBToGit(ctx context.Context, config GitConfig) error continue } // read changes [new additions/updates] - data, err := ioutil.ReadFile(config.LocalPath + "/" + file) + data, err := os.ReadFile(config.LocalPath + "/" + file) if err != nil { logrus.Error("Error reading data from git file : " + file + " | " + err.Error()) continue @@ -573,7 +575,7 @@ func (g *gitOpsService) createExperiment(ctx context.Context, data, file string, return false, errors.New("Cannot convert manifest to yaml : " + err.Error()) } - err = ioutil.WriteFile(experimentPath, yamlData, 0644) + err = os.WriteFile(experimentPath, yamlData, 0644) if err != nil { return false, errors.New("Cannot write experiment to git : " + err.Error()) } @@ -624,10 +626,10 @@ func (g *gitOpsService) updateExperiment(ctx context.Context, data, wfID, file s if err != nil { return err } - return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, updateRevision, config.ProjectID, data_store.Store) + return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, updateRevision, config.ProjectID, dataStore.Store) } -// deleteExperiment helps in deleting a experiment from DB during the SyncDBToGit operation +// deleteExperiment helps in deleting an experiment from DB during the SyncDBToGit operation func (g *gitOpsService) deleteExperiment(file string, config GitConfig) error { _, fileName := filepath.Split(file) fileName = strings.Replace(fileName, ".yaml", "", -1) @@ -638,5 +640,5 @@ func (g *gitOpsService) deleteExperiment(file string, config GitConfig) error { return err } - return g.chaosExperimentService.ProcessExperimentDelete(query, experiment, "git-ops", data_store.Store) + return g.chaosExperimentService.ProcessExperimentDelete(query, experiment, "git-ops", dataStore.Store) } diff --git a/chaoscenter/subscriber/go.sum b/chaoscenter/subscriber/go.sum index f2df63f6892..82c972e25a5 100644 --- a/chaoscenter/subscriber/go.sum +++ b/chaoscenter/subscriber/go.sum @@ -234,6 +234,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= diff --git a/chaoscenter/subscriber/pkg/graphql/operations.go b/chaoscenter/subscriber/pkg/graphql/operations.go index 510bdf546af..b2ea6372454 100644 --- a/chaoscenter/subscriber/pkg/graphql/operations.go +++ b/chaoscenter/subscriber/pkg/graphql/operations.go @@ -3,10 +3,12 @@ package graphql import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "strconv" "strings" + + log "github.com/sirupsen/logrus" ) func (gql *subscriberGql) SendRequest(server string, payload []byte) (string, error) { @@ -20,8 +22,13 @@ func (gql *subscriberGql) SendRequest(server string, payload []byte) (string, er return "", err } - body, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() + body, err := io.ReadAll(resp.Body) + defer func() { + if err := resp.Body.Close(); err != nil { + log.Warnf("failed to close body: %v", err) + } + }() + if err != nil { return "", err } From b85a60d2acaf7f1d29d715c34e5f333efdd019d7 Mon Sep 17 00:00:00 2001 From: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:50:13 +0530 Subject: [PATCH 03/10] Husky hook fix. (#4469) * Modified pre-commit script to Posix-compilant. Signed-off-by: aryan * Modified pre-push script to Posix-compilant. Signed-off-by: aryan --------- Signed-off-by: aryan Co-authored-by: Sarthak Jain Co-authored-by: Saranya Jena --- chaoscenter/web/.husky/pre-commit | 16 ++++++++-------- chaoscenter/web/.husky/pre-push | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/chaoscenter/web/.husky/pre-commit b/chaoscenter/web/.husky/pre-commit index c6e028de8f9..8952a103b01 100755 --- a/chaoscenter/web/.husky/pre-commit +++ b/chaoscenter/web/.husky/pre-commit @@ -1,25 +1,25 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" +"$(dirname "$0")/_/husky.sh" -declare MATCH_PATH='chaoscenter/web/' +MATCH_PATH='chaoscenter/web/' -declare BRANCH=$(git rev-parse --abbrev-ref HEAD) +BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ "$BRANCH" == "main" ]]; then +if [ "$BRANCH" = "main" ]; then echo "\033[0;31;1mYou can't commit directly to main branch\033[0m" exit 1 fi -if [[ "$BRANCH" =~ ^release\/.* ]]; then +if expr "$BRANCH" : 'release\/.*' >/dev/null; then echo "\033[0;31;1mYou cannot commit directly to release branch\033[0m" - exit 1 + exit 1 fi -declare LITMUS_UI_FILE_CHANGES=$(git diff --name-only --cached | grep $MATCH_PATH -c) +LITMUS_UI_FILE_CHANGES=$(git diff --name-only --cached | grep "$MATCH_PATH" -c) echo "\033[0;93mLITMUS_UI_FILE_CHANGES\033[0m ⟶ $LITMUS_UI_FILE_CHANGES" -if [[ $LITMUS_UI_FILE_CHANGES -gt 0 ]] +if [ "$LITMUS_UI_FILE_CHANGES" -gt 0 ]; then cd ./chaoscenter/web && yarn lint-staged else diff --git a/chaoscenter/web/.husky/pre-push b/chaoscenter/web/.husky/pre-push index 8b46a9ddc2b..01428446380 100755 --- a/chaoscenter/web/.husky/pre-push +++ b/chaoscenter/web/.husky/pre-push @@ -1,36 +1,36 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" +"$(dirname "$0")/_/husky.sh" -declare MATCH_PATH='chaoscenter/web/' +MATCH_PATH='chaoscenter/web/' -declare BRANCH=$(git rev-parse --abbrev-ref HEAD) +BRANCH=$(git rev-parse --abbrev-ref HEAD) echo "ON_BRANCH ⟶ $BRANCH" -declare REMOTE_EXISTS=$(git ls-remote --heads origin $BRANCH | wc -l) +REMOTE_EXISTS=$(git ls-remote --heads origin "$BRANCH" | wc -l) -declare CHECK_AGAINST_COMMIT +CHECK_AGAINST_COMMIT="" -if [[ $REMOTE_EXISTS -gt 0 ]] +if [ "$REMOTE_EXISTS" -gt 0 ]; then # remote exists, compare changes from last pushed commit - declare LAST_PUSHED_COMMIT_ID=$(git rev-parse --short @{push}) + LAST_PUSHED_COMMIT_ID=$(git rev-parse --short @{push}) echo "LAST_PUSHED_COMMIT ⟶ $LAST_PUSHED_COMMIT_ID" - CHECK_AGAINST_COMMIT=$LAST_PUSHED_COMMIT_ID + CHECK_AGAINST_COMMIT="$LAST_PUSHED_COMMIT_ID" else # remote doesn't exists, compare changes from branched off commit - declare BRANCHED_COMMIT_ID=$(git rev-parse --short $(git merge-base main $BRANCH)) + BRANCHED_COMMIT_ID=$(git rev-parse --short "$(git merge-base main "$BRANCH")") echo "BRANCHED_COMMIT_ID ⟶ $BRANCHED_COMMIT_ID" - CHECK_AGAINST_COMMIT=$BRANCHED_COMMIT_ID + CHECK_AGAINST_COMMIT="$BRANCHED_COMMIT_ID" fi -declare CHAOS_UI_FILE_CHANGES=$(git diff --name-only -r --stat --oneline $CHECK_AGAINST_COMMIT HEAD | grep $MATCH_PATH -c) +CHAOS_UI_FILE_CHANGES=$(git diff --name-only -r --stat --oneline "$CHECK_AGAINST_COMMIT" HEAD | grep "$MATCH_PATH" -c) echo "CHAOS_UI_FILE_CHANGES ⟶ $CHAOS_UI_FILE_CHANGES" -if [[ $CHAOS_UI_FILE_CHANGES -gt 0 ]] +if [ "$CHAOS_UI_FILE_CHANGES" -gt 0 ]; then - cd ./chaoscenter/web && yarn test:silent --changedSince=$CHECK_AGAINST_COMMIT + cd ./chaoscenter/web && yarn test:silent --changedSince="$CHECK_AGAINST_COMMIT" else echo "Skipping husky pre-push hook in $MATCH_PATH folder" fi \ No newline at end of file From 5df86aba05646e28eb6c7b42abb88f4bdea141fb Mon Sep 17 00:00:00 2001 From: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:06:02 +0300 Subject: [PATCH 04/10] Update CODE_OF_CONDUCT.md (#4485) updated code of conduct according to latest guidelines Signed-off-by: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> Co-authored-by: Saranya Jena --- CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 107 insertions(+), 21 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6cd995def26..237834f0f53 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,45 +2,131 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment include: +Examples of behavior that contributes to a positive environment for our +community include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -## Our Responsibilities +## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. ## Enforcement -Instances of abusive, harassing or otherwise unacceptable behavior may be reported by contacting the project team at support@mayadata.io. The project team will review and investigate all complaints, and will respond in a way that it seems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +prithvi.raj@harness.io. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations From f9d524790197a4ab7e470c7e52b5900b5469eb45 Mon Sep 17 00:00:00 2001 From: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> Date: Tue, 5 Mar 2024 13:42:43 +0300 Subject: [PATCH 05/10] update adopters (#4487) * Update CODE_OF_CONDUCT.md updated code of conduct according to latest guidelines Signed-off-by: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> * Update ADOPTERS.md updating latest adopters Signed-off-by: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> --------- Signed-off-by: Prithvi Raj <52114109+prithvi1307@users.noreply.github.com> Co-authored-by: Saranya Jena --- ADOPTERS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ADOPTERS.md b/ADOPTERS.md index 65270635003..6fd3b761774 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -25,6 +25,9 @@ The companies listed here conform to [CNCF's definition of end-users](https://gi |[Adidas](https://adidas.com/)|Implementing Chaos Engineering as a practice at Adidas|[Our Story](adopters/organizations/adidas.md)| |[Cyren](https://www.cyren.com/)|Implementing Chaos Engineering as a practice at Cyren|[Our Story](https://www.infoq.com/articles/chaos-engineering-cloud-native/)| |[AB-Inbev](https://www.ab-inbev.com/)|Implementing Chaos Engineering as a practice at AB-Inbev|[Our Story](adopters/organizations/abinbev.md)| +|[Group Baobab](https://baobab.com/en/home/)| Orchestrating Chaos using LitmusChaos at Baobab|[Our Story](https://github.com/litmuschaos/litmus/issues/2191#issuecomment-1647648343)| +|[Flipkart](https://www.flipkart.com/)|Chaos Engineering at Flipkart|[Our Story](https://github.com/litmuschaos/litmus/issues/2191#issuecomment-1966904935)| + ### Cloud-Native Vendors @@ -43,6 +46,7 @@ devops/reliability pipelines (such as for customer portals/websites etc.,) withi |[Zebrium](https://www.zebrium.com?utm_source=github&utm_campaign=litmuschaos_repo)|[Zebrium K8s Chaos Project](https://github.com/zebrium/zebrium-kubernetes-demo)|[Our Story](adopters/organizations/zebrium.md)| |[Container Solutions](https://www.container-solutions.com/)|Building Chaos Engineering for E-Commerce Customers|[Our Story](adopters/organizations/containersolutions.md)| |[Infracloud Technologies](https://www.infracloud.io/)|Developing Resiliency Framework at Infracloud|[Our Story](adopters/organizations/infracloud.md)| +|[IFS](https://www.ifs.com/)|Checking Resiliency with LitmusChaos at IFS|[Our Story](https://github.com/litmuschaos/litmus/issues/2191#issuecomment-1966428068)| ### Cloud-Native Solutions & Service Providers From 52ab1d592be43c7c397dcc8a61d1ec53d9409ed3 Mon Sep 17 00:00:00 2001 From: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:38:20 +0530 Subject: [PATCH 06/10] Added loader in UserManagement modal. (#4452) * Added loader in UserManagement modal. Signed-off-by: Aryan * Removed OverlaySpinner and extra state variable. Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> * fixed web tests failing. Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> * fixed minwidth for all buttons. Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> --------- Signed-off-by: Aryan Signed-off-by: Aryan Bhokare <92683836+aryan-bhokare@users.noreply.github.com> Co-authored-by: Saranya Jena --- .../DeleteApiToken/DeleteApiToken.tsx | 4 +- .../EnableDisableUser/EnableDisableUser.tsx | 4 +- .../ResetPassword/ResetPassword.tsx | 4 +- .../AccountDetailsChange.tsx | 5 ++- .../AccountPasswordChange.tsx | 5 ++- .../views/CreateNewToken/CreateNewToken.tsx | 4 +- .../src/views/CreateNewUser/CreateNewUser.tsx | 9 +++-- .../views/DeleteApiToken/DeleteApiToken.tsx | 7 +++- .../EnableDisableUser/EnableDisableUser.tsx | 37 +++++++++++-------- .../src/views/ResetPassword/ResetPassword.tsx | 8 ++-- .../__tests__/ResetPassword.test.tsx | 4 ++ 11 files changed, 56 insertions(+), 35 deletions(-) diff --git a/chaoscenter/web/src/controllers/DeleteApiToken/DeleteApiToken.tsx b/chaoscenter/web/src/controllers/DeleteApiToken/DeleteApiToken.tsx index 71d188b373a..14e45cb0e3e 100644 --- a/chaoscenter/web/src/controllers/DeleteApiToken/DeleteApiToken.tsx +++ b/chaoscenter/web/src/controllers/DeleteApiToken/DeleteApiToken.tsx @@ -13,7 +13,7 @@ interface DeleteApiTokenControllerProps { export default function DeleteApiTokenController(props: DeleteApiTokenControllerProps): React.ReactElement { const { token, apiTokensRefetch, handleClose } = props; - const { mutate: deleteApiTokenMutation } = useRemoveApiTokenMutation( + const { mutate: deleteApiTokenMutation, isLoading: deleteApiTokenMutationLoading } = useRemoveApiTokenMutation( {}, { onSuccess: () => { @@ -23,5 +23,5 @@ export default function DeleteApiTokenController(props: DeleteApiTokenController } ); - return ; + return ; } diff --git a/chaoscenter/web/src/controllers/EnableDisableUser/EnableDisableUser.tsx b/chaoscenter/web/src/controllers/EnableDisableUser/EnableDisableUser.tsx index 4a4e884619b..be0e1c33ebd 100644 --- a/chaoscenter/web/src/controllers/EnableDisableUser/EnableDisableUser.tsx +++ b/chaoscenter/web/src/controllers/EnableDisableUser/EnableDisableUser.tsx @@ -17,7 +17,7 @@ export default function EnableDisableUserController(props: EnableDisableUserCont const { getUsersRefetch } = props; const { showSuccess } = useToaster(); - const { mutate: updateStateMutation } = useUpdateStateMutation( + const { mutate: updateStateMutation, isLoading: updateStateMutationLoading} = useUpdateStateMutation( {}, { onSuccess: data => { @@ -27,5 +27,5 @@ export default function EnableDisableUserController(props: EnableDisableUserCont } ); - return ; + return ; } diff --git a/chaoscenter/web/src/controllers/ResetPassword/ResetPassword.tsx b/chaoscenter/web/src/controllers/ResetPassword/ResetPassword.tsx index a5bd6b1c3b8..360d3bd9393 100644 --- a/chaoscenter/web/src/controllers/ResetPassword/ResetPassword.tsx +++ b/chaoscenter/web/src/controllers/ResetPassword/ResetPassword.tsx @@ -13,12 +13,12 @@ export default function ResetPasswordController(props: ResetPasswordControllerPr const { username, handleClose } = props; const { getString } = useStrings(); const { showSuccess } = useToaster(); - const { mutate: resetPasswordMutation } = useResetPasswordMutation( + const { mutate: resetPasswordMutation, isLoading: resetPasswordMutationLoading } = useResetPasswordMutation( {}, { onSuccess: () => showSuccess(getString('passwordResetSuccess')) } ); return ( - + ); } diff --git a/chaoscenter/web/src/views/AccountDetailsChange/AccountDetailsChange.tsx b/chaoscenter/web/src/views/AccountDetailsChange/AccountDetailsChange.tsx index e06be22860d..ace1fcd6ac5 100644 --- a/chaoscenter/web/src/views/AccountDetailsChange/AccountDetailsChange.tsx +++ b/chaoscenter/web/src/views/AccountDetailsChange/AccountDetailsChange.tsx @@ -94,9 +94,10 @@ export default function AccountDetailsChangeView(props: AccountDetailsChangeView