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/RELEASE_GUIDELINES.md b/RELEASE_GUIDELINES.md index b9434db58c2..c4724f6d846 100644 --- a/RELEASE_GUIDELINES.md +++ b/RELEASE_GUIDELINES.md @@ -1,4 +1,19 @@ -## RELEASE GUIDELINES +# Versioning and Release Guidelines + +This document details the versioning, release plan and release guidelines for LitmusChaos. Stability +is a top goal for this project, and we hope that this document and the processes +it entails will help to achieve that. It covers the release timelines, tracking, process, versioning +numbering, support horizons, and API stability. + +If you rely on LitmusChaos, it would be good to spend time understanding the +areas of the API that are and are not supported and how they impact your +project in the future. + +This document will be considered a living document. Scheduled releases, supported timelines, and API stability guarantees will be updated here as they +change. + +If there is something that you require or this document leaves out, please +reach out by [filing an issue](https://github.com/litmuschaos/litmus/issues). - There is a scheduled release on the 15th of every month on the following repositories: - [Litmus](https://github.com/litmuschaos/litmus) @@ -7,8 +22,6 @@ - [Chaos-Exporter](https://github.com/litmuschaos/chaos-exporter) - [Chaos-Charts](https://github.com/litmuschaos/chaos-charts) -- Repositories use release version according to the [Semantic Versioning](https://semver.org/) - - Docker images with release tags are pushed upon creation of a github release - Following are the docker images: @@ -32,6 +45,157 @@ - Doc sanity tests - Litmus release with change log +## Releases + +Releases of LitmusChaos will be versioned using dotted triples, similar to +[Semantic Version](http://semver.org/). For the purposes of this document, we +will refer to the respective components of this triple as +`..`. The version number may have additional information, +such as alpha, beta and release candidate qualifications. Such releases will be +considered "pre-releases". + +### Major and Minor Releases + +Major and minor releases of LitmusChaos will be made from main. Releases of +LitmusChaos will be marked with GPG signed tags and announced at +https://github.com/LitmusChaos/LitmusChaos/releases. The tag will be of the +format `v..` and should be made with the command `git tag +-s v..`. + +After a minor release, a branch will be created, with the format +`release/.` from the minor tag. All further patch releases will +be done from that branch. For example, once we release `v1.0.0`, a branch +`release/1.0` will be created from that tag. All future patch releases will be +done against that branch. + +### Pre-releases + +Pre-releases, such as alphas, betas and release candidates will be conducted +from their source branch. For major and minor releases, these releases will be +done from main. For patch releases, these pre-releases should be done within +the corresponding release branch. + +While pre-releases are done to assist in the stabilization process, no +guarantees are provided. + +### Upgrade Path + +The upgrade path for LitmusChaos is such that the 0.0.x patch releases are +always backward compatible with its major and minor version. Minor (0.x.0) +version will always be compatible with the previous minor release. i.e. 1.2.0 +is backwards compatible with 1.1.0 and 1.1.0 is compatible with 1.0.0. There is +no compatibility guarantees for upgrades that span multiple, _minor_ releases. +For example, 1.0.0 to 1.2.0 is not supported. One should first upgrade to 1.1, +then 1.2. + +There are no compatibility guarantees with upgrades to _major_ versions. For +example, upgrading from 1.0.0 to 2.0.0 may require resources to migrated or +integrations to change. Each major version will be supported for at least 1 +year with bug fixes and security patches. + +### Next Release + +The activity for the next release will be tracked in the +[project board](https://github.com/litmuschaos/litmus/projects). If your +issue or PR is not present in the project board, please reach out to the maintainers or discuss the same on the #litmus-dev slack channel to create the milestone or add an issue or PR to an existing milestone. + +### Support Horizon + +Support horizons will be defined corresponding to a release branch, identified +by `.`. Release branches will be in one of several states: + +- __*Next*__: The next planned release branch. +- __*Active*__: The release is a stable branch which is currently supported and accepting patches. +- __*Extended*__: The release branch is only accepting security patches. +- __*LTS*__: The release is a long term stable branch which is currently supported and accepting patches. +- __*End of Life*__: The release branch is no longer supported and no new patches will be accepted. + +Releases will be supported at least one year after a _minor_ release. This means that +we will accept bug reports and backports to release branches until the end of +life date. If no new _minor_ release has been made, that release will be +considered supported until 6 months after the next _minor_ is released or one year, +whichever is longer. Additionally, releases may have an extended security support +period after the end of the active period to accept security backports. This +timeframe will be decided by maintainers before the end of the active status. + +Long term stable (_LTS_) releases will be supported for at least three years after +their initial _minor_ release. These branches will accept bug reports and +backports until the end of life date. They may also accept a wider range of +patches than non-_LTS_ releases to support the longer term maintainability of the +branch, including library dependency, toolchain (including Go) and other version updates +which are needed to ensure each release is built with fully supported dependencies and +remains usable by LitmusChaos clients. _LTS_ releases can also accept feature backports +to support new Kubernetes releases. The default action has to be reject it though, +for long-term stability. This is still negotiable when the feature is a hard dependency +for a new release of Kubernetes. There should be at least a 6-month overlap between +the end of life of an _LTS_ release and the initial release of a new _LTS_ release. +Up to 6 months before the announced end of life of an _LTS_ branch, the branch may +convert to a regular _Active_ release with stricter backport criteria. + +The current state is available in the following tables: + +| Release | Status | Start | End of Life | +| --------- | ------------- | ------------------ | ------------------- | +| [0.x {0.6 - 0.9}](https://github.com/litmuschaos/litmus/releases/tag/0.9.0) | End of Life | Sept 13, 2019 | Jun 15, 2020 | +| [1.x {1.0 - 1.13}](https://github.com/litmuschaos/litmus/releases/tag/1.13.8) | End of Life | Jan 8, 2020 | - | +| [2.0 beta {2.0 beta 0 to 2.0 beta 9}](https://github.com/litmuschaos/litmus/releases/tag/2.0.0-Beta9) | End of Life | Mar 05, 2021 | July 15, 2021 | +| [2.x](https://github.com/litmuschaos/litmus/releases/tag/2.14.0) | End of Life | Aug 9, 2021 | September 5, 2023 | +| [3.x beta](https://github.com/litmuschaos/litmus/releases/tag/3.0.0-beta12) | End of Life | Nov 16, 2022 | Nov 15, 2023 | +| [3.x](https://github.com/litmuschaos/litmus/releases/tag/3.6.1) | Active | Oct 04, 2023 | active(release of 4.0 + 6 months), | +| [4.0](https://github.com/litmuschaos/litmus/blob/master/ROADMAP.md) | Next | TBD | TBD | + +> **_NOTE_** LitmusChaos v3.x will end of life at the same time as v4.x reaches full stability. Due to +> [Minimal Version Selection](https://go.dev/ref/mod#minimal-version-selection) used +> by Go modules, 3.x must be supported until EOL of all 3.x releases. Once 3.x is in +> extended support, it will continue to accept security patches in addition to client +> changes relevant for package importers. + +### Kubernetes Support + +The Kubernetes version matrix represents the versions of LitmusChaos which are +recommended for a Kubernetes release. Any actively supported version of +LitmusChaos may receive patches to fix bugs encountered in any version of +Kubernetes, however, our recommendation is based on which versions have been +the most thoroughly tested. See the [Kubernetes test grid](https://testgrid.k8s.io/sig-node-LitmusChaos) +for the list of actively tested versions. Kubernetes only supports n-3 minor +release versions and LitmusChaos will ensure there is always a supported version +of LitmusChaos for every supported version of Kubernetes. + +| Kubernetes Version | LitmusChaos Version | +|--------------------|-------------------------------| +| 1.26 | 1.x, 2.x | +| 1.27 | 1.x, 2.x | +| 1.28 | 2.x, 3.x | +| 1.29 | 3.x | +| 1.30(wip) | 4.0 (wip), 3.x | + + +## Public API Stability + +The following table provides an overview of the components covered by +LitmusChaos versions: + + +| Component | Status | Stabilized Version | Links | +|------------------|----------|--------------------|---------------| +| GraphQL API | Stable | 1.0 | [graphql API]() | +| Go client API | Stable | 2.0 | [godoc]() | + + +From the version stated in the above table, that component must adhere to the +stability constraints expected in release versions. + +Unless explicitly stated here, components that are called out as unstable or +not covered may change in a future minor version. Breaking changes to +"unstable" components will be avoided in patch versions. + +Go client API stability includes the `client`, `defaults` and `version` package +as well as all packages under `pkg`, `core`, `api` and `protobuf`. +All packages under `cmd`, `contrib`, `integration`, and `internal` are not +considered part of the stable client API. + + + ### Release Checklist * [ ] Release branch creation on litmus component repos diff --git a/chaoscenter/authentication/api/handlers/rest/user_handlers.go b/chaoscenter/authentication/api/handlers/rest/user_handlers.go index 3c957ec9034..4f702a83609 100644 --- a/chaoscenter/authentication/api/handlers/rest/user_handlers.go +++ b/chaoscenter/authentication/api/handlers/rest/user_handlers.go @@ -152,6 +152,18 @@ func UpdateUser(service services.ApplicationService) gin.HandlerFunc { func GetUser(service services.ApplicationService) gin.HandlerFunc { return func(c *gin.Context) { uid := c.Param("uid") + + // Validating logged in user + // Must be either requesting info from the logged in user + // or any user if it has the admin role + role := c.MustGet("role").(string) + if c.MustGet("uid").(string) != uid && role != string(entities.RoleAdmin) { + log.Error("auth error: unauthorized") + c.JSON(utils.ErrorStatusCodes[utils.ErrUnauthorized], + presenter.CreateErrorResponse(utils.ErrUnauthorized)) + return + } + user, err := service.GetUser(uid) if err != nil { log.Error(err) @@ -255,13 +267,13 @@ func LoginUser(service services.ApplicationService) gin.HandlerFunc { user, err := service.FindUserByUsername(userRequest.Username) if err != nil { log.Error(err) - c.JSON(utils.ErrorStatusCodes[utils.ErrUserNotFound], presenter.CreateErrorResponse(utils.ErrUserNotFound)) + c.JSON(utils.ErrorStatusCodes[utils.ErrUserNotFound], presenter.CreateErrorResponse(utils.ErrInvalidCredentials)) return } // Checking if user is deactivated if user.DeactivatedAt != nil { - c.JSON(utils.ErrorStatusCodes[utils.ErrUserDeactivated], presenter.CreateErrorResponse(utils.ErrUserDeactivated)) + c.JSON(utils.ErrorStatusCodes[utils.ErrUserDeactivated], presenter.CreateErrorResponse(utils.ErrInvalidCredentials)) return } @@ -559,6 +571,15 @@ func CreateApiToken(service services.ApplicationService) gin.HandlerFunc { return } + // Validating logged in user + // Requesting info must be from the logged in user + if c.MustGet("uid").(string) != apiTokenRequest.UserID { + log.Error("auth error: unauthorized") + c.JSON(utils.ErrorStatusCodes[utils.ErrUnauthorized], + presenter.CreateErrorResponse(utils.ErrUnauthorized)) + return + } + // Checking if user exists user, err := service.GetUser(apiTokenRequest.UserID) if err != nil { @@ -594,6 +615,16 @@ func CreateApiToken(service services.ApplicationService) gin.HandlerFunc { func GetApiTokens(service services.ApplicationService) gin.HandlerFunc { return func(c *gin.Context) { uid := c.Param("uid") + + // Validating logged in user + // Requesting info must be from the logged in user + if c.MustGet("uid").(string) != uid { + log.Error("auth error: unauthorized") + c.JSON(utils.ErrorStatusCodes[utils.ErrUnauthorized], + presenter.CreateErrorResponse(utils.ErrUnauthorized)) + return + } + apiTokens, err := service.GetApiTokensByUserID(uid) if err != nil { log.Error(err) diff --git a/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go b/chaoscenter/authentication/api/handlers/rest/user_handlers_test.go index e06e4b29645..a6d9b092d94 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()) } @@ -142,12 +142,14 @@ func TestGetUser(t *testing.T) { tests := []struct { name string uid string + role string given func() expectedCode int }{ { name: "Successfully retrieve user", uid: "testUID", + role: "user", given: func() { user := &entities.User{ ID: "testUID", @@ -167,7 +169,8 @@ func TestGetUser(t *testing.T) { c.Params = gin.Params{ {"uid", tt.uid}, } - + c.Set("uid", tt.uid) + c.Set("role", tt.role) tt.given() rest.GetUser(service)(c) @@ -516,7 +519,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([]byte(bodyBytes))) c.Set("role", tt.mockRole) c.Set("uid", tt.mockUID) c.Set("username", tt.mockUsername) @@ -592,7 +595,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) @@ -637,7 +640,7 @@ func TestCreateApiToken(t *testing.T) { bodyBytes, _ := json.Marshal(tt.inputBody) c.Request = httptest.NewRequest(http.MethodPost, "/api/token", bytes.NewReader(bodyBytes)) c.Request.Header.Set("Content-Type", "application/json") - + c.Set("uid", tt.inputBody.UserID) tt.given() rest.CreateApiToken(service)(c) @@ -682,7 +685,7 @@ func TestGetApiTokens(t *testing.T) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) c.Params = []gin.Param{{Key: "uid", Value: tt.uid}} - + c.Set("uid", tt.uid) tt.given() rest.GetApiTokens(service)(c) diff --git a/chaoscenter/authentication/api/middleware/jwt_middlware_test.go b/chaoscenter/authentication/api/middleware/jwt_middlware_test.go new file mode 100644 index 00000000000..021acc8ff9e --- /dev/null +++ b/chaoscenter/authentication/api/middleware/jwt_middlware_test.go @@ -0,0 +1,125 @@ +package middleware_test + +import ( + "errors" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/golang-jwt/jwt" + "github.com/litmuschaos/litmus/chaoscenter/authentication/api/middleware" + "github.com/litmuschaos/litmus/chaoscenter/authentication/api/mocks" + "github.com/litmuschaos/litmus/chaoscenter/authentication/pkg/utils" + "github.com/stretchr/testify/assert" +) + +func TestJwtMiddleware(t *testing.T) { + router := gin.Default() + mockService := new(mocks.MockedApplicationService) + router.Use(middleware.JwtMiddleware(mockService)) + + router.GET("/status", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "Access Granted"}) + }) + + createRequest := func(token string) *httptest.ResponseRecorder { + req := httptest.NewRequest("GET", "/status", nil) + req.Header.Set("Authorization", "Bearer "+token) + w := httptest.NewRecorder() + return w + } + + t.Run("Valid Token", func(t *testing.T) { + wValid := createRequest("jwtstring") + assert.Equal(t, http.StatusOK, wValid.Code) + }) + + t.Run("Missing Authorization Header", func(t *testing.T) { + wMissingHeader := httptest.NewRecorder() + reqMissingHeader := httptest.NewRequest("GET", "/status", nil) + router.ServeHTTP(wMissingHeader, reqMissingHeader) + assert.Equal(t, http.StatusUnauthorized, wMissingHeader.Code) + }) +} + +func TestJwtMiddleware_SetClaimsAndCallNextHandler(t *testing.T) { + router := gin.Default() + + mockService := new(mocks.MockedApplicationService) + router.Use(middleware.JwtMiddleware(mockService)) + + router.GET("/status", func(c *gin.Context) { + username, _ := c.Get("username") + uid, _ := c.Get("uid") + role, _ := c.Get("role") + assert.Equal(t, "testuser", username) + assert.Equal(t, "12345", uid) + assert.Equal(t, "admin", role) + c.JSON(http.StatusOK, gin.H{"message": "Access Granted"}) + }) + + mockService.On("ValidateToken", "jwtstring").Return(&jwt.Token{ + Valid: true, + Claims: jwt.MapClaims{ + "username": "testuser", + "uid": "12345", + "role": "admin", + }, + }, nil) + + w := httptest.NewRecorder() + req, _ := http.NewRequest("GET", "/status", nil) + req.Header.Set("Authorization", "Bearer jwtstring") + router.ServeHTTP(w, req) + assert.Equal(t, http.StatusOK, w.Code) +} + +func TestJwtMiddleware_TokenValidationFailure(t *testing.T) { + router := gin.Default() + + mockService := new(mocks.MockedApplicationService) + router.Use(middleware.JwtMiddleware(mockService)) + + router.GET("/status", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "Access Granted"}) + }) + + mockService.On("ValidateToken", "invalidtoken").Return(&jwt.Token{ + Valid: false, + }, nil) + + w := httptest.NewRecorder() + req, _ := http.NewRequest("GET", "/status", nil) + req.Header.Set("Authorization", "Bearer invalidtoken") + router.ServeHTTP(w, req) + + assert.Equal(t, http.StatusUnauthorized, w.Code) +} + +func TestJwtMiddleware_Error(t *testing.T) { + router := gin.Default() + + mockService := new(mocks.MockedApplicationService) + router.Use(middleware.JwtMiddleware(mockService)) + + dummyToken := &jwt.Token{ + Raw: "DummyToken", + Method: jwt.SigningMethodHS256, + Header: map[string]interface{}{"alg": "HS256"}, + Claims: jwt.MapClaims{"foo": "bar"}, + Signature: "", + Valid: false, + } + + mockService.On("ValidateToken", "dummy").Return(dummyToken, errors.New("mock error")) + + req, _ := http.NewRequest("GET", "/", nil) + req.Header.Set("Authorization", "Bearer dummy") + resp := httptest.NewRecorder() + router.ServeHTTP(resp, req) + + if status := resp.Code; status != utils.ErrorStatusCodes[utils.ErrUnauthorized] { + t.Errorf("Handler returned wrong status code: got %v want %v", status, utils.ErrorStatusCodes[utils.ErrUnauthorized]) + } +} diff --git a/chaoscenter/authentication/go.mod b/chaoscenter/authentication/go.mod index e7c083b4ce3..72e6ac93448 100644 --- a/chaoscenter/authentication/go.mod +++ b/chaoscenter/authentication/go.mod @@ -15,9 +15,9 @@ require ( github.com/swaggo/swag v1.16.3 go.mongodb.org/mongo-driver v1.14.0 golang.org/x/crypto v0.22.0 - golang.org/x/oauth2 v0.16.0 + golang.org/x/oauth2 v0.20.0 google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.1 ) require ( @@ -62,7 +62,6 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.19.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/chaoscenter/authentication/go.sum b/chaoscenter/authentication/go.sum index f43415cfecd..434a8b7bbc7 100644 --- a/chaoscenter/authentication/go.sum +++ b/chaoscenter/authentication/go.sum @@ -45,14 +45,11 @@ github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keL github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -152,8 +149,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -187,16 +184,12 @@ golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/chaoscenter/authentication/pkg/project/repository.go b/chaoscenter/authentication/pkg/project/repository.go index 8037eb24374..461f1ecf299 100644 --- a/chaoscenter/authentication/pkg/project/repository.go +++ b/chaoscenter/authentication/pkg/project/repository.go @@ -70,7 +70,7 @@ func (r repository) GetProjectsByUserID(userID string, isOwner bool) ([]*entitie var projects []*entities.Project query := bson.D{} - if isOwner == true { + if isOwner { query = bson.D{ {"members", bson.D{ {"$elemMatch", bson.D{ diff --git a/chaoscenter/authentication/pkg/session/revoked_token_repository.go b/chaoscenter/authentication/pkg/session/revoked_token_repository.go index c69a07225d5..999882561d2 100644 --- a/chaoscenter/authentication/pkg/session/revoked_token_repository.go +++ b/chaoscenter/authentication/pkg/session/revoked_token_repository.go @@ -31,10 +31,8 @@ func (r repository) IsTokenRevoked(encodedToken string) bool { err := r.Collection.FindOne(context.TODO(), bson.M{ "token": encodedToken, }).Decode(&result) - if err != nil { - return false - } - return true + + return err == nil } // NewRevokedTokenRepo creates a new instance of this repository diff --git a/chaoscenter/graphql/server/go.mod b/chaoscenter/graphql/server/go.mod index 7997e68f7fb..c831a7417a1 100644 --- a/chaoscenter/graphql/server/go.mod +++ b/chaoscenter/graphql/server/go.mod @@ -3,31 +3,31 @@ module github.com/litmuschaos/litmus/chaoscenter/graphql/server go 1.20 require ( - github.com/99designs/gqlgen v0.17.42 + github.com/99designs/gqlgen v0.17.46 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 github.com/argoproj/argo-workflows/v3 v3.3.5 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/gin-contrib/cors v1.3.1 github.com/gin-gonic/gin v1.9.1 - github.com/go-git/go-git/v5 v5.11.0 + github.com/go-git/go-git/v5 v5.12.0 github.com/golang-jwt/jwt v3.2.2+incompatible - github.com/google/uuid v1.3.0 - github.com/gorilla/websocket v1.5.0 + github.com/google/uuid v1.6.0 + github.com/gorilla/websocket v1.5.1 github.com/jinzhu/copier v0.3.5 github.com/kelseyhightower/envconfig v1.4.0 github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4 github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71 - github.com/mrz1836/go-sanitize v1.3.1 + github.com/mrz1836/go-sanitize v1.3.2 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tidwall/gjson v1.14.0 github.com/tidwall/sjson v1.2.4 - github.com/vektah/gqlparser/v2 v2.5.10 + github.com/vektah/gqlparser/v2 v2.5.11 go.mongodb.org/mongo-driver v1.11.4 golang.org/x/crypto v0.22.0 google.golang.org/grpc v1.56.3 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.26.0 k8s.io/apimachinery v0.26.0 @@ -39,7 +39,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect @@ -70,7 +70,7 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/googleapis/gnostic v0.5.5 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -80,7 +80,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -88,11 +88,11 @@ require ( github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect - github.com/sosodev/duration v1.1.0 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/skeema/knownhosts v1.2.2 // indirect + github.com/sosodev/duration v1.3.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect @@ -103,15 +103,15 @@ require ( github.com/xdg-go/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sync v0.3.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/tools v0.20.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/chaoscenter/graphql/server/go.sum b/chaoscenter/graphql/server/go.sum index cf59335bd2e..aa0da062758 100644 --- a/chaoscenter/graphql/server/go.sum +++ b/chaoscenter/graphql/server/go.sum @@ -43,8 +43,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/99designs/gqlgen v0.17.42 h1:BVWDOb2VVHQC5k3m6oa0XhDnxltLLrU4so7x/u39Zu4= -github.com/99designs/gqlgen v0.17.42/go.mod h1:GQ6SyMhwFbgHR0a8r2Wn8fYgEwPxxmndLFPhU63+cJE= +github.com/99designs/gqlgen v0.17.46 h1:Dk/pSCMVp57z/vd6gwZ/wmqbPOL3i5iz4YQHTDfxyuw= +github.com/99designs/gqlgen v0.17.46/go.mod h1:qRtiAeVPgkBBSPzZtoZXRRl5WkNrUTpp1OeVt61TmGU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/azure-sdk-for-go v32.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= @@ -99,9 +99,9 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OpenPeeDeeP/depguard v1.0.0/go.mod h1:7/4sitnI9YlQgTLLk734QlzXT8DuHVnAyztLplQjk+o= github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= @@ -124,7 +124,7 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= +github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/ant31/crd-validation v0.0.0-20180702145049-30f8a35d0ac2/go.mod h1:X0noFIik9YqfhGYBLEHg8LJKEwy7QIitLQuFMpKLcPk= @@ -350,7 +350,7 @@ github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmC github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-acme/lego v2.5.0+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M= @@ -362,8 +362,8 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmS github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -604,8 +604,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= @@ -628,8 +628,8 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= github.com/gostaticanalysis/analysisutil v0.0.3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= github.com/gosuri/uitable v0.0.1/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= @@ -665,8 +665,8 @@ github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE= -github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -817,8 +817,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -875,8 +875,8 @@ github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5 github.com/mozilla/tls-observatory v0.0.0-20180409132520-8791a200eb40/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= github.com/mrunalp/fileutils v0.0.0-20160930181131-4ee1cc9a8058/go.mod h1:x8F1gnqOkIEiO4rqoeEEEqQbo7HjGMTvyoq3gej4iT0= github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618/go.mod h1:x8F1gnqOkIEiO4rqoeEEEqQbo7HjGMTvyoq3gej4iT0= -github.com/mrz1836/go-sanitize v1.3.1 h1:bTxpzDXzGh9cp3XLTeVKgL2iLqEwCaLqqe+3BmpnCbo= -github.com/mrz1836/go-sanitize v1.3.1/go.mod h1:Js6Gq1uiarNReoOeOKxPXxNpKy1FRlbgDDZnJG4THdM= +github.com/mrz1836/go-sanitize v1.3.2 h1:sGhusPxP4L+7NAUVAUl/WrrBazNSNECsvYh3yumuJXQ= +github.com/mrz1836/go-sanitize v1.3.2/go.mod h1:wvRS2ALFDxOCK3ORQPwKUxl7HTIBUV8S3U34Hwn96r4= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -1035,8 +1035,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= @@ -1052,14 +1052,14 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= -github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/sosodev/duration v1.3.0 h1:g3E6mto+hFdA2uZXeNDYff8LYeg7v5D4YKP/Ng/NUkE= +github.com/sosodev/duration v1.3.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34cd2MNlA9u1mE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -1090,8 +1090,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1104,8 +1105,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20160928074757-e7cb7fa329f4/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1143,8 +1144,8 @@ github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= -github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= -github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= +github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= @@ -1293,8 +1294,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180112015858-5ccada7d0a7b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1397,8 +1398,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180117170059-2c42eef0765b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1521,8 +1522,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1616,8 +1617,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1747,8 +1748,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= +google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/chaoscenter/graphql/server/manifests/cluster/1b_argo_rbac.yaml b/chaoscenter/graphql/server/manifests/cluster/1b_argo_rbac.yaml index 41cfdc5912b..3846bf8fd99 100644 --- a/chaoscenter/graphql/server/manifests/cluster/1b_argo_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/cluster/1b_argo_rbac.yaml @@ -6,48 +6,27 @@ metadata: namespace: #{INFRA_NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole +kind: ClusterRoleBinding metadata: - name: chaos-cluster-role -rules: - # for managing the pods created by workflow controller to implement individual steps in the workflow - - apiGroups: [''] - resources: ['pods', 'services'] - verbs: ['create', 'get', 'watch', 'patch', 'delete', 'list'] - - apiGroups: [''] - resources: ['namespaces'] - verbs: ['get', 'watch', 'patch', 'list'] - - # for tracking & getting logs of the pods created by workflow controller to implement individual steps in the workflow - - apiGroups: [''] - resources: ['pods/log', 'pods/exec'] - verbs: ['get', 'watch', 'create', 'delete', 'patch'] - - apiGroups: [''] - resources: ['secrets', 'configmaps'] - verbs: ['get', 'watch', 'create', 'patch'] - - # for creation & deletion of application in predefined workflows - - apiGroups: ['apps'] - resources: ['deployments'] - verbs: ['delete'] - - apiGroups: ['apps'] - resources: ['deployments', 'statefulsets'] - verbs: ['get', 'watch', 'patch' , 'create'] - - # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow - - apiGroups: ["litmuschaos.io"] - resources: - ["chaosengines", "chaosexperiments", "chaosresults", "chaosschedules"] - verbs: ["create", "list", "get", "patch", "delete", "watch"] + name: argo-chaos-infra-cluster-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: infra-cluster-role +subjects: + - kind: ServiceAccount + name: argo-chaos + namespace: #{INFRA_NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding +kind: RoleBinding metadata: - name: chaos-cluster-role-binding + name: argo-chaos-ops-role-binding + namespace: #{INFRA_NAMESPACE} roleRef: apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: chaos-cluster-role + kind: Role + name: infra-ops-role subjects: - kind: ServiceAccount name: argo-chaos diff --git a/chaoscenter/graphql/server/manifests/cluster/1c_argo_deployment.yaml b/chaoscenter/graphql/server/manifests/cluster/1c_argo_deployment.yaml index 263aec09885..41a43441c30 100644 --- a/chaoscenter/graphql/server/manifests/cluster/1c_argo_deployment.yaml +++ b/chaoscenter/graphql/server/manifests/cluster/1c_argo_deployment.yaml @@ -46,6 +46,7 @@ spec: - workflow-controller-configmap - --executor-image - #{ARGO_WORKFLOW_EXECUTOR} + - --namespaced - --container-runtime-executor - #{ARGO_CONTAINER_RUNTIME_EXECUTOR} command: diff --git a/chaoscenter/graphql/server/manifests/cluster/2b_litmus_admin_rbac.yaml b/chaoscenter/graphql/server/manifests/cluster/2b_litmus_admin_rbac.yaml index fc60ab50d66..854b3ecfa3e 100644 --- a/chaoscenter/graphql/server/manifests/cluster/2b_litmus_admin_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/cluster/2b_litmus_admin_rbac.yaml @@ -11,9 +11,9 @@ metadata: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: litmus-admin + name: litmus-admin-cluster-role labels: - name: litmus-admin + name: litmus-admin-cluster-role rules: # *************************************************************************************** # Permissions needed for preparing and monitor the chaos resources by chaos-runner @@ -30,11 +30,6 @@ rules: resources: ["events"] verbs: ["create","get","list","patch","update"] - # for fetching configmaps and secrets to inject into chaos-runner pod (if specified) - - apiGroups: [""] - resources: ["secrets", "configmaps"] - verbs: ["get", "list"] - # for tracking & getting logs of the pods created by chaos-runner to implement individual steps in the runner - apiGroups: [""] resources: ["pods/log"] @@ -110,13 +105,29 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: litmus-admin + name: litmus-admin-cluster-role-binding labels: - name: litmus-admin + name: litmus-admin-cluster-role-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: litmus-admin + name: litmus-admin-cluster-role +subjects: + - kind: ServiceAccount + name: litmus-admin + namespace: #{INFRA_NAMESPACE} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: litmus-admin-ops-role-binding + namespace: #{INFRA_NAMESPACE} + labels: + name: litmus-admin-ops-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: infra-ops-role subjects: - kind: ServiceAccount name: litmus-admin diff --git a/chaoscenter/graphql/server/manifests/cluster/3a_agents_rbac.yaml b/chaoscenter/graphql/server/manifests/cluster/3a_agents_rbac.yaml index 3c10b2840da..05cb1961b6d 100644 --- a/chaoscenter/graphql/server/manifests/cluster/3a_agents_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/cluster/3a_agents_rbac.yaml @@ -8,11 +8,6 @@ rules: # Permissions needed for orchestration and monitoring chaos by chaos-operator and chaos-exporter # *********************************************************************************************** - # for mounting the secrets to the chaos-runner pod - - apiGroups: [ "" ] - resources: [ "secrets" ] - verbs: [ "get", "list" ] - # for deriving the owner references of the operator pod - apiGroups: [ "apps" ] resources: [ "deployments", "replicasets"] @@ -28,9 +23,9 @@ rules: resources: [ "pods" ] verbs: ["get", "create", "update", "patch", "delete", "list", "watch", "deletecollection" ] - # for creating of events, monitoring and leader election + # for creating of events and monitoring - apiGroups: [ "" ] - resources: [ "configmaps", "events", "services" ] + resources: [ "events", "services" ] verbs: ["get", "create", "update", "patch", "list", "watch" ] # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow @@ -57,10 +52,6 @@ rules: # Permissions needed to manage and communicate between control plane and execution plane by subscriber # ******************************************************************************************************* - - apiGroups: [ "" ] - resources: [ "configmaps", "secrets" ] - verbs: [ "get", "create", "delete", "update", "patch" ] - - apiGroups: [ "batch" ] resources: [ "jobs" ] verbs: [ "get", "create", "patch", "update" ] @@ -74,7 +65,7 @@ rules: verbs: [ "get", "list", "watch" ] - apiGroups: [ "litmuschaos.io" ] - resources: [ "chaosengines", "chaosschedules", "chaosresults" ] + resources: [ "chaosengines", "chaosschedules", "chaosresults", "chaosschedules" ] verbs: [ "get", "list", "create", "delete", "update", "watch", "patch" ] - apiGroups: [ "apps.openshift.io" ] @@ -111,9 +102,6 @@ rules: - apiGroups: [ "" ] resources: [ "pods", "pods/exec" ] verbs: [ "create", "get", "list", "watch", "update", "patch", "delete" ] - - apiGroups: [ "" ] - resources: [ "configmaps" ] - verbs: [ "get", "watch", "list" ] - apiGroups: [ "" ] resources: [ "persistentvolumeclaims" ] verbs: [ "create", "delete" ] @@ -163,3 +151,31 @@ subjects: - kind: ServiceAccount name: #{INFRA_SERVICE_ACCOUNT} namespace: #{INFRA_NAMESPACE} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: infra-ops-role + namespace: #{INFRA_NAMESPACE} +rules: + - apiGroups: [ "" ] + resources: [ "secrets" ] + verbs: [ "get", "create", "update", "patch" ] + + - apiGroups: [ "" ] + resources: [ "configmaps"] + verbs: ["get", "create", "update", "patch", "list", "watch" ] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: infra-ops-role-binding + namespace: #{INFRA_NAMESPACE} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: infra-ops-role +subjects: + - kind: ServiceAccount + name: #{INFRA_SERVICE_ACCOUNT} + namespace: #{INFRA_NAMESPACE} diff --git a/chaoscenter/graphql/server/manifests/namespace/1a_argo_rbac.yaml b/chaoscenter/graphql/server/manifests/namespace/1a_argo_rbac.yaml index f91f931b577..e577568ffa2 100644 --- a/chaoscenter/graphql/server/manifests/namespace/1a_argo_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/namespace/1a_argo_rbac.yaml @@ -6,46 +6,28 @@ metadata: namespace: #{INFRA_NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: Role +kind: RoleBinding metadata: - name: chaos-role + name: argo-chaos-infra-role-binding namespace: #{INFRA_NAMESPACE} -rules: - # for managing the pods created by workflow controller to implement individual steps in the workflow - - apiGroups: [""] - resources: ["pods", "services"] - verbs: ["create", "get", "watch", "patch", "delete", "list"] - - # for tracking & getting logs of the pods created by workflow controller to implement individual steps in the workflow - - apiGroups: [''] - resources: ['pods/log', 'pods/exec'] - verbs: ['get', 'watch', 'create', 'delete', 'patch'] - - apiGroups: [''] - resources: ['secrets', 'configmaps'] - verbs: ['get', 'watch', 'create', 'patch'] - - # for creation & deletion of application in predefined workflows - - apiGroups: ['apps'] - resources: ['deployments'] - verbs: ['delete'] - - apiGroups: ['apps'] - resources: ['deployments', 'statefulsets'] - verbs: ['get', 'watch', 'patch' , 'create'] - - # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow - - apiGroups: ["litmuschaos.io"] - resources: ["chaosengines", "chaosexperiments", "chaosresults", "chaosschedules"] - verbs: ["create", "list", "get", "patch", "delete", "watch"] +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: infra-role +subjects: + - kind: ServiceAccount + name: argo-chaos + namespace: #{INFRA_NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: chaos-role-binding + name: argo-chaos-ops-role-binding namespace: #{INFRA_NAMESPACE} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: chaos-role + name: infra-ops-role subjects: - kind: ServiceAccount name: argo-chaos diff --git a/chaoscenter/graphql/server/manifests/namespace/2a_litmus_admin_rbac.yaml b/chaoscenter/graphql/server/manifests/namespace/2a_litmus_admin_rbac.yaml index 2d12ead082c..0bba6feda8c 100644 --- a/chaoscenter/graphql/server/manifests/namespace/2a_litmus_admin_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/namespace/2a_litmus_admin_rbac.yaml @@ -10,10 +10,10 @@ metadata: apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: litmus-admin + name: litmus-admin-role namespace: #{INFRA_NAMESPACE} labels: - name: litmus-admin + name: litmus-admin-role rules: # *************************************************************************************** # Permissions needed for preparing and monitor the chaos resources by chaos-runner @@ -30,11 +30,6 @@ rules: resources: ["events"] verbs: ["create", "get", "list", "patch", "update"] - # for fetching configmaps and secrets to inject into chaos-runner pod (if specified) - - apiGroups: [""] - resources: ["secrets", "configmaps"] - verbs: ["get", "list"] - # for tracking & getting logs of the pods created by chaos-runner to implement individual steps in the runner - apiGroups: [""] resources: ["pods/log"] @@ -105,14 +100,30 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: litmus-admin + name: litmus-admin-role-binding namespace: #{INFRA_NAMESPACE} labels: + name: litmus-admin-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: litmus-admin-role +subjects: + - kind: ServiceAccount name: litmus-admin + namespace: #{INFRA_NAMESPACE} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: litmus-admin-ops-role-binding + namespace: #{INFRA_NAMESPACE} + labels: + name: litmus-admin-ops-role-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: litmus-admin + name: infra-ops-role subjects: - kind: ServiceAccount name: litmus-admin diff --git a/chaoscenter/graphql/server/manifests/namespace/3a_agents_rbac.yaml b/chaoscenter/graphql/server/manifests/namespace/3a_agents_rbac.yaml index 49260a9c79e..c24da4d0fb4 100644 --- a/chaoscenter/graphql/server/manifests/namespace/3a_agents_rbac.yaml +++ b/chaoscenter/graphql/server/manifests/namespace/3a_agents_rbac.yaml @@ -11,11 +11,6 @@ rules: # Permissions needed for orchestration and monitoring chaos by chaos-operator and chaos-exporter # *********************************************************************************************** - # for mounting the secrets to the chaos-runner pod - - apiGroups: [ "" ] - resources: ["secrets" ] - verbs: [ "get", "list" ] - # for deriving the owner references of the operator pod - apiGroups: [ "apps" ] resources: [ "deployments", "replicasets"] @@ -31,9 +26,9 @@ rules: resources: [ "pods"] verbs: ["get", "create", "update", "patch", "delete", "list", "watch", "deletecollection" ] - # for creating of events, monitoring and leader election + # for creating of events and monitoring - apiGroups: [ "" ] - resources: [ "configmaps", "events", "services" ] + resources: [ "events", "services" ] verbs: ["get", "create", "update", "patch", "list", "watch" ] # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow @@ -55,10 +50,6 @@ rules: # Permissions needed to manage and communicate between control plane and execution plane by subscriber # ******************************************************************************************************* - - apiGroups: [ "" ] - resources: [ "configmaps", "secrets" ] - verbs: [ "get", "create", "delete", "update", "patch" ] - - apiGroups: [ "" ] resources: [ "pods/log" ] verbs: [ "get", "list", "watch" ] @@ -68,7 +59,7 @@ rules: verbs: [ "get", "list", "watch" ] - apiGroups: [ "litmuschaos.io" ] - resources: [ "chaosengines", "chaosschedules", "chaosresults" ] + resources: [ "chaosengines", "chaosschedules", "chaosresults", "chaosschedules" ] verbs: [ "get", "list", "create", "delete", "update", "watch", "patch" ] - apiGroups: [ "apps.openshift.io" ] @@ -101,9 +92,6 @@ rules: - apiGroups: [ "" ] resources: [ "pods", "pods/exec" ] verbs: [ "create", "get", "list", "watch", "update", "patch", "delete" ] - - apiGroups: [ "" ] - resources: [ "configmaps" ] - verbs: [ "get", "watch", "list" ] - apiGroups: [ "" ] resources: [ "persistentvolumeclaims" ] verbs: [ "create", "delete" ] @@ -119,9 +107,6 @@ rules: - apiGroups: [ "" ] resources: [ "serviceaccounts" ] verbs: [ "get", "list" ] - - apiGroups: [ "" ] - resources: [ "secrets" ] - verbs: [ "get" ] - apiGroups: [ "argoproj.io" ] resources: [ "cronworkflows", "cronworkflows/finalizers" ] verbs: [ "get", "list", "watch", "update", "patch", "delete" ] @@ -157,3 +142,31 @@ roleRef: kind: Role name: infra-role apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: infra-ops-role + namespace: #{INFRA_NAMESPACE} +rules: + - apiGroups: [ "" ] + resources: [ "secrets" ] + verbs: [ "get", "create", "update", "patch" ] + + - apiGroups: [ "" ] + resources: [ "configmaps"] + verbs: ["get", "create", "update", "patch", "list", "watch" ] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: infra-ops-role-binding + namespace: #{INFRA_NAMESPACE} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: infra-ops-role +subjects: + - kind: ServiceAccount + name: #{INFRA_SERVICE_ACCOUNT} + namespace: #{INFRA_NAMESPACE} diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go index 59d5aa59bce..dfd8d962bd2 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 @@ -115,11 +113,11 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs ) // Checking if the agent namespace does not exist and its scope of installation is not namespaced - if *infra.InfraNsExists == false && infra.InfraScope != "namespace" { + if !*infra.InfraNsExists && infra.InfraScope != "namespace" { generatedYAML = append(generatedYAML, fmt.Sprintf(namespaceConfig)) } - if *infra.InfraSaExists == false { + if !*infra.InfraSaExists { generatedYAML = append(generatedYAML, fmt.Sprintf(serviceAccountStr)) } @@ -129,14 +127,19 @@ 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(file *os.File) { + err := file.Close() + if err != nil { + log.Errorf("failed to close the file %v", err) + } + }(file) list, err := file.Readdirnames(0) // 0 to read all files and folders if err != nil { return nil, fmt.Errorf("failed to read the file %v", err) } - var nodeselector string + var nodeSelector string if infra.NodeSelector != nil { selector := strings.Split(*infra.NodeSelector, ",") selectorList := make(map[string]string) @@ -145,18 +148,17 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs selectorList[kv[0]] = kv[1] } - nodeSelector := struct { - NodeSelector map[string]string `yaml:"nodeSelector" json:"nodeSelector"` - }{ - NodeSelector: selectorList, - } - - byt, err := yaml.Marshal(nodeSelector) + byt, err := yaml.Marshal( + struct { + NodeSelector map[string]string `yaml:"nodeSelector" json:"nodeSelector"` + }{ + NodeSelector: selectorList, + }) if err != nil { return nil, fmt.Errorf("failed to marshal the node selector %v", err) } - nodeselector = string(utils.AddRootIndent(byt, 6)) + nodeSelector = string(utils.AddRootIndent(byt, 6)) } var tolerations string @@ -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) } @@ -202,14 +204,14 @@ func ManifestParser(infra dbChaosInfra.ChaosInfra, rootPath string, config *Subs newContent = strings.Replace(newContent, "#{CUSTOM_TLS_CERT}", config.TLSCert, -1) newContent = strings.Replace(newContent, "#{START_TIME}", "\""+infra.StartTime+"\"", -1) - if infra.IsInfraConfirmed == true { + if infra.IsInfraConfirmed { newContent = strings.Replace(newContent, "#{IS_INFRA_CONFIRMED}", "\""+"true"+"\"", -1) } else { newContent = strings.Replace(newContent, "#{IS_INFRA_CONFIRMED}", "\""+"false"+"\"", -1) } if infra.NodeSelector != nil { - newContent = strings.Replace(newContent, "#{NODE_SELECTOR}", nodeselector, -1) + newContent = strings.Replace(newContent, "#{NODE_SELECTOR}", nodeSelector, -1) } generatedYAML = append(generatedYAML, newContent) } @@ -250,7 +252,8 @@ func SendExperimentToSubscriber(projectID string, workflow *model.ChaosExperimen var workflowObj unstructured.Unstructured err := yaml.Unmarshal([]byte(workflow.ExperimentManifest), &workflowObj) if err != nil { - fmt.Errorf("error while parsing experiment manifest %v", err) + log.Errorf("error while parsing experiment manifest %v", err) + return } SendRequestToSubscriber(SubscriberRequests{ diff --git a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go index f69fb9cda01..a62fcffd18b 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/handler/handler.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "path/filepath" @@ -19,9 +18,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" ) @@ -39,9 +36,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(chartsPath) if err != nil { log.Error("file reading error", err) return nil, err @@ -50,7 +47,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) } @@ -79,14 +76,16 @@ func GetExperimentData(experimentFilePath string) (*model.Chart, error) { return nil, err } var chartData *model.Chart - json.Unmarshal(e, &chartData) + if err = json.Unmarshal(e, &chartData); err != nil { + return nil, err + } return chartData, nil } // ReadExperimentFile is used for reading experiment file from given path func ReadExperimentFile(path string) (ChaosChart, error) { var experiment ChaosChart - experimentFile, err := ioutil.ReadFile(path) + experimentFile, err := os.ReadFile(path) if err != nil { return experiment, fmt.Errorf("file path of the, err: %+v", err) } @@ -99,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) } @@ -112,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 } @@ -162,8 +161,8 @@ 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(hubPath) if err != nil { log.Error(err) return err @@ -191,14 +190,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(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(hubPath) return fmt.Errorf("err: Invalid file type %s", contentType) } @@ -210,13 +209,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(hubPath) if err != nil { return err } @@ -224,16 +223,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(zipReader *zip.ReadCloser) { + err := zipReader.Close() + if err != nil { + log.Error(err) + } + }(zipReader) for _, file := range zipReader.File { - CopyZipItems(file, extractPath, file.Name) + err := CopyZipItems(file, extractPath, file.Name) + if err != nil { + return err + } } return nil } @@ -365,7 +372,12 @@ func DefaultChaosHubIconHandler() gin.HandlerFunc { } } - defer img.Close() + defer func(img *os.File) { + err := img.Close() + if err != nil { + log.WithError(err).Error("error while closing the file") + } + }(img) c.Writer.Header().Set("Content-Type", "image/png") c.Writer.WriteHeader(responseStatusCode) 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..531c5510ea7 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/ops/gitops_test.go @@ -2,18 +2,17 @@ package chaoshubops_test import ( "fmt" - "io/ioutil" + "io" "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" "github.com/google/uuid" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model" + chaosHubOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub/ops" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) @@ -25,7 +24,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 d2dcc2b994e..c6920d20de1 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/service.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/service.go @@ -4,11 +4,12 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "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 +17,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 ( @@ -68,7 +65,7 @@ func (c *chaosHubService) AddChaosHub(ctx context.Context, chaosHub model.Create if IsExist, err := c.IsChaosHubAvailable(ctx, chaosHub.Name, projectID); err != nil { return nil, err } else if IsExist == true { - return nil, errors.New("Name Already exists") + return nil, errors.New("name already exists") } currentTime := time.Now() cloneHub := NewCloningInputFrom(chaosHub) @@ -123,7 +120,7 @@ func (c *chaosHubService) AddChaosHub(ctx context.Context, chaosHub model.Create return nil, err } - // Cloning the repository at a path from chaoshub link structure. + // Cloning the repository at a path from ChaosHub link structure. if err := chaosHubOps.GitClone(cloneHub, projectID); err != nil { log.Error(err) } @@ -137,7 +134,7 @@ func (c *chaosHubService) AddRemoteChaosHub(ctx context.Context, chaosHub model. return nil, err } if IsExist == true { - return nil, errors.New("Name Already exists") + return nil, errors.New("name already exists") } description := "" if chaosHub.Description != nil { @@ -206,7 +203,7 @@ func (c *chaosHubService) SaveChaosHub(ctx context.Context, chaosHub model.Creat return nil, err } if IsExist == true { - return nil, errors.New("Name Already exists") + return nil, errors.New("name already exists") } // Initialize a UID for new Hub. @@ -345,7 +342,7 @@ func (c *chaosHubService) UpdateChaosHub(ctx context.Context, chaosHub model.Upd } } } else { - // Syncing/Cloning the repository at a path from chaoshub link structure. + // Syncing/Cloning the repository at a path from ChaosHub link structure. if prevChaosHub.Name != chaosHub.Name || prevChaosHub.RepoURL != chaosHub.RepoURL || prevChaosHub.RepoBranch != chaosHub.RepoBranch || prevChaosHub.IsPrivate != chaosHub.IsPrivate || prevChaosHub.AuthType != chaosHub.AuthType.String() { err = os.RemoveAll(clonePath) if err != nil { @@ -481,21 +478,21 @@ 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) + csvYaml, err := os.ReadFile(csvPath) if err != nil { csvYaml = []byte("") } //Get engine.yaml data enginePath := basePath + "/" + "engine.yaml" - engineYaml, err := ioutil.ReadFile(enginePath) + engineYaml, err := os.ReadFile(enginePath) if err != nil { engineYaml = []byte("") } //Get fault.yaml data faultPath := basePath + "/" + "fault.yaml" - faultYaml, err := ioutil.ReadFile(faultPath) + faultYaml, err := os.ReadFile(faultPath) if err != nil { faultYaml = []byte("") } @@ -507,7 +504,7 @@ func (c *chaosHubService) GetChaosFault(ctx context.Context, request model.Exper }, nil } -// ListChaosHubs returns the array of hubdetails with their current status. +// ListChaosHubs returns the array of hub details with their current status. func (c *chaosHubService) ListChaosHubs(ctx context.Context, projectID string, request *model.ListChaosHubRequest) ([]*model.ChaosHubStatus, error) { defaultHub := c.listDefaultHubs() updatedDefaultHub := dbSchemaChaosHub.ChaosHub{ @@ -730,7 +727,7 @@ func (c *chaosHubService) ListPredefinedExperiments(ctx context.Context, hubID s hubPath = DefaultPath + projectID + "/" + hub.Name + "/experiments/" } var predefinedWorkflows []*model.PredefinedExperimentList - files, err := ioutil.ReadDir(hubPath) + files, err := os.ReadDir(hubPath) if err != nil { return nil, err } @@ -813,14 +810,14 @@ func (c *chaosHubService) getPredefinedExperimentDetails(experimentsPath string, } if isExist { - yamlData, err := ioutil.ReadFile(experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml") + yamlData, err := os.ReadFile(experimentsPath + experiment + "/" + experiment + ".chartserviceversion.yaml") if err != nil { csvManifest = "" } csvManifest = string(yamlData) - yamlData, err = ioutil.ReadFile(experimentsPath + experiment + "/" + "experiment.yaml") + yamlData, err = os.ReadFile(experimentsPath + experiment + "/" + "experiment.yaml") if err != nil { workflowManifest = "" } @@ -837,64 +834,6 @@ func (c *chaosHubService) getPredefinedExperimentDetails(experimentsPath string, return preDefinedWorkflow } -// GetExperimentManifestDetails is used to send the ChaosEngine and ChaosExperiment YAMLs -//func (c *chaosHubService) GetExperimentManifestDetails(ctx context.Context, request model.ExperimentRequest, projectID string) (*model.ExperimentDetails, error) { -// -// engineType := model.FileTypeEngine -// experimentType := model.FileTypeExperiment -// -// engineData, err := c.GetYAMLData(model.ExperimentRequest{ -// ChartName: request.ChartName, -// ExperimentName: request.ExperimentName, -// Name: request.Name, -// FileType: (*string)(&engineType), -// }, projectID) -// if err != nil { -// engineData = "" -// } -// experimentData, err := c.GetYAMLData(model.ExperimentRequest{ -// ChartName: request.ChartName, -// ExperimentName: request.ExperimentName, -// Name: request.Name, -// FileType: (*string)(&experimentType), -// }, projectID) -// if err != nil { -// experimentData = "" -// } -// experimentDetails := &model.ExperimentDetails{ -// EngineDetails: engineData, -// ExperimentDetails: experimentData, -// } -// return experimentDetails, nil -//} - -//func (c *chaosHubService) ListPredefinedWorkflows(name string, projectID string) ([]*model.PredefinedWorkflowList, error) { -// workflowsList, err := handler.ListPredefinedWorkflowDetails(name, projectID) -// if err != nil { -// return nil, err -// } -// return workflowsList, nil -//} - -// GetPredefinedExperimentYAMLData is responsible for sending the workflow.yaml for a given pre-defined workflow. -//func (c *chaosHubService) GetPredefinedExperimentYAMLData(request model.ExperimentRequest, projectID string) (string, error) { -// var YAMLPath string -// if request.FileType == nil { -// return "", errors.New("provide a valid filetype") -// } -// if strings.ToLower(*request.FileType) != "workflow" { -// return "", errors.New("invalid file type") -// } -// if strings.ToLower(request.ChartName) == "predefined" && strings.ToLower(*request.FileType) == "workflow" { -// YAMLPath = handler.GetPredefinedExperimentManifest(request, projectID) -// } -// YAMLData, err := handler.ReadExperimentYAMLFile(YAMLPath) -// if err != nil { -// return "", err -// } -// return YAMLData, nil -//} - // IsChaosHubAvailable is used for checking if hub already exist or not func (c *chaosHubService) IsChaosHubAvailable(ctx context.Context, name string, projectID string) (bool, error) { chaosHubs, err := c.chaosHubOperator.GetChaosHubByProjectID(ctx, projectID) diff --git a/chaoscenter/graphql/server/pkg/gitops/gitops.go b/chaoscenter/graphql/server/pkg/gitops/gitops.go index 925cb0577c8..b629e600d79 100644 --- a/chaoscenter/graphql/server/pkg/gitops/gitops.go +++ b/chaoscenter/graphql/server/pkg/gitops/gitops.go @@ -6,16 +6,11 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "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 +18,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" ) @@ -87,7 +85,7 @@ func GetGitOpsConfig(repoData gitops.GitConfigDB) GitConfig { LatestCommit: repoData.LatestCommit, UserName: repoData.UserName, Password: repoData.Password, - AuthType: model.AuthType(repoData.AuthType), + AuthType: repoData.AuthType, Token: repoData.Token, SSHPrivateKey: repoData.SSHPrivateKey, } @@ -95,7 +93,7 @@ func GetGitOpsConfig(repoData gitops.GitConfigDB) GitConfig { return gitConfig } -// setupGitRepo helps clones and sets up the repo for gitops +// setupGitRepo helps clones and sets up the repo for GitOps func (c GitConfig) setupGitRepo(user GitUser) error { projectPath := c.LocalPath + "/" + ProjectDataPath + "/" + c.ProjectID @@ -113,7 +111,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(projectPath + "/.info") if err != nil { return errors.New("can't read existing git info file " + err.Error()) } @@ -137,7 +135,7 @@ func (c GitConfig) setupGitRepo(user GitUser) error { if err != nil { return err } - err = ioutil.WriteFile(projectPath+"/.info", data, 0644) + err = os.WriteFile(projectPath+"/.info", data, 0644) if err != nil { return err } @@ -204,7 +202,7 @@ func (c GitConfig) getAuthMethod() (transport.AuthMethod, error) { } } -// UnsafeGitPull executes git pull after a hard reset when uncommited changes are present in repo. Not safe. +// UnsafeGitPull executes git pull after a hard reset when uncommitted changes are present in repo. Not safe. func (c GitConfig) UnsafeGitPull() error { cleanStatus, err := c.GitGetStatus() if err != nil { @@ -282,7 +280,7 @@ func (c GitConfig) GitPull() error { ReferenceName: plumbing.NewBranchReferenceName(c.Branch), SingleBranch: true, }) - if err != nil && err != git.NoErrAlreadyUpToDate { + if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) { return err } return nil @@ -325,7 +323,7 @@ func (c GitConfig) GitPush() error { Auth: auth, Progress: nil, }) - if err == git.NoErrAlreadyUpToDate { + if errors.Is(err, git.NoErrAlreadyUpToDate) { return nil } return err @@ -445,7 +443,7 @@ func (c GitConfig) GetLatestCommitHash() (string, error) { return commit.Hash.String(), nil } -// SetupGitOps clones and sets up the repo for gitops and returns the LatestCommit +// SetupGitOps clones and sets up the repo for git ops and returns the LatestCommit func SetupGitOps(user GitUser, gitConfig GitConfig) (string, error) { err := gitConfig.setupGitRepo(user) if err != nil { diff --git a/chaoscenter/graphql/server/pkg/gitops/service.go b/chaoscenter/graphql/server/pkg/gitops/service.go index 9fbb662fecd..2c19987af22 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,17 @@ 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 +65,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,12 +74,12 @@ 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) if err != nil { - logrus.Error("Could not get experiment :", err) + log.Error("Could not get experiment :", err) return "could not get experiment", err } if len(experiments) == 0 { @@ -94,12 +91,12 @@ func (g *gitOpsService) GitOpsNotificationHandler(ctx context.Context, infra cha } experiments[0].Revision[len(experiments[0].Revision)-1].ExperimentManifest, err = sjson.Set(experiments[0].Revision[len(experiments[0].Revision)-1].ExperimentManifest, "metadata.name", experiments[0].Name+"-"+strconv.FormatInt(time.Now().UnixMilli(), 10)) if err != nil { - logrus.Error("Failed to updated experiment name :", err) + log.Error("Failed to updated experiment name :", err) return "", errors.New("Failed to updated experiment name " + err.Error()) } 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 +104,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 +114,19 @@ func (g *gitOpsService) EnableGitOpsHandler(ctx context.Context, projectID strin var conn *grpc2.ClientConn client, conn := grpc.GetAuthGRPCSvcClient(conn) - defer conn.Close() + defer func(conn *grpc2.ClientConn) { + err := conn.Close() + if err != nil { + log.Error("Failed to close connection : ", err) + } + }(conn) _, err := grpc.GetProjectById(client, projectID) if err != nil { return false, errors.New("Failed to setup GitOps : " + err.Error()) } - logrus.Info("Enabling Gitops") + log.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") + log.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") + log.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()) } @@ -296,7 +298,7 @@ func (g *gitOpsService) UpsertExperimentToGit(ctx context.Context, projectID str // DeleteExperimentFromGit deletes experiment from git func (g *gitOpsService) DeleteExperimentFromGit(ctx context.Context, projectID string, experiment *model.ChaosExperimentRequest) error { - logrus.Info("Deleting Experiment...") + log.Info("Deleting Experiment...") gitLock.Lock(projectID, nil) defer gitLock.Unlock(projectID, nil) @@ -323,7 +325,7 @@ func (g *gitOpsService) DeleteExperimentFromGit(ctx context.Context, projectID s return errors.New("Cannot delete experiment from git : " + err.Error()) } if !exists { - logrus.Error("File not found in git : ", gitConfig.LocalPath+"/"+experimentPath) + log.Error("File not found in git : ", gitConfig.LocalPath+"/"+experimentPath) return nil } err = os.RemoveAll(gitConfig.LocalPath + "/" + experimentPath) @@ -333,13 +335,13 @@ func (g *gitOpsService) DeleteExperimentFromGit(ctx context.Context, projectID s commit, err := gitConfig.GitCommit(GitUserFromContext(ctx), "Deleted Experiment : "+experiment.ExperimentName, &experimentPath) if err != nil { - logrus.Error("Error", err) + log.Error("Error", err) return errors.New("Cannot commit experiment[delete] to git : " + err.Error()) } err = gitConfig.GitPush() if err != nil { - logrus.Error("Error", err) + log.Error("Error", err) return errors.New("Cannot push experiment[delete] to git : " + err.Error()) } @@ -370,7 +372,7 @@ func (g *gitOpsService) gitSyncHelper(config gitops.GitConfigDB, wg *sync.WaitGr // get most recent data from db after acquiring lock conf, err := g.gitOpsOperator.GetGitConfig(ctx, config.ProjectID) if err != nil { - logrus.Error("Repo Sync ERROR: ", config.ProjectID, err.Error()) + log.Error("Repo Sync ERROR: ", config.ProjectID, err.Error()) } if conf == nil { return @@ -380,7 +382,7 @@ func (g *gitOpsService) gitSyncHelper(config gitops.GitConfigDB, wg *sync.WaitGr err = g.SyncDBToGit(nil, gitConfig) if err != nil { - logrus.Error("Repo Sync ERROR: ", conf.ProjectID, err.Error()) + log.Error("Repo Sync ERROR: ", conf.ProjectID, err.Error()) } } @@ -391,17 +393,17 @@ func (g *gitOpsService) GitOpsSyncHandler(singleRun bool) { for { ctx, cancel := context.WithTimeout(backgroundContext, timeout) - logrus.Info("Running GitOps DB Sync...") + log.Info("Running GitOps DB Sync...") configs, err := g.gitOpsOperator.GetAllGitConfig(ctx) cancel() if err != nil { - logrus.Error("Failed to get git configs from db : ", err) //condition + log.Error("Failed to get git configs from db : ", err) //condition } count := len(configs) if count > 0 { - logrus.Info("Updating : ", configs) // condition + log.Info("Updating : ", configs) // condition count = count - 1 for count >= 0 { @@ -418,7 +420,7 @@ func (g *gitOpsService) GitOpsSyncHandler(singleRun bool) { wg.Wait() } - logrus.Info("GitOps DB Sync Complete") //condition + log.Info("GitOps DB Sync Complete") //condition } if singleRun { break @@ -448,7 +450,7 @@ func (g *gitOpsService) SyncDBToGit(ctx context.Context, config GitConfig) error if latestCommit == config.LatestCommit { return nil } - logrus.Info(latestCommit, " ", config.LatestCommit, "File Changes: ", files) + log.Info(latestCommit, " ", config.LatestCommit, "File Changes: ", files) newExperiments := false for file := range files { if !strings.HasSuffix(file, ".yaml") { @@ -462,20 +464,20 @@ func (g *gitOpsService) SyncDBToGit(ctx context.Context, config GitConfig) error if !exists { err = g.deleteExperiment(file, config) if err != nil { - logrus.Error("Error while deleting experiment db entry : " + file + " | " + err.Error()) + log.Error("Error while deleting experiment db entry : " + file + " | " + err.Error()) continue } 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()) + log.Error("Error reading data from git file : " + file + " | " + err.Error()) continue } data, err = yaml.YAMLToJSON(data) if err != nil { - logrus.Error("Error unmarshalling data from git file : " + file + " | " + err.Error()) + log.Error("Error unmarshalling data from git file : " + file + " | " + err.Error()) continue } wfID := gjson.Get(string(data), "metadata.labels.experiment_id").String() @@ -484,12 +486,12 @@ func (g *gitOpsService) SyncDBToGit(ctx context.Context, config GitConfig) error continue } - logrus.Info("WFID in changed File :", wfID) + log.Info("WFID in changed File :", wfID) if wfID == "" { - logrus.Info("New Experiment pushed to git : " + file) + log.Info("New Experiment pushed to git : " + file) flag, err := g.createExperiment(ctx, string(data), file, config) if err != nil { - logrus.Error("Error while creating new experiment db entry : " + file + " | " + err.Error()) + log.Error("Error while creating new experiment db entry : " + file + " | " + err.Error()) continue } if flag { @@ -498,7 +500,7 @@ func (g *gitOpsService) SyncDBToGit(ctx context.Context, config GitConfig) error } else { err = g.updateExperiment(ctx, string(data), wfID, file, config) if err != nil { - logrus.Error("Error while updating experiment db entry : " + file + " | " + err.Error()) + log.Error("Error while updating experiment db entry : " + file + " | " + err.Error()) continue } } @@ -539,7 +541,7 @@ func (g *gitOpsService) createExperiment(ctx context.Context, data, file string, fileName = strings.Replace(fileName, ".yaml", "", -1) wfName := gjson.Get(data, "metadata.name").String() infraID := gjson.Get(data, "metadata.labels.infra_id").String() - logrus.Info("Experiment Details | wf_name: ", wfName, " infra_id: ", infraID) + log.Info("Experiment Details | wf_name: ", wfName, " infra_id: ", infraID) if wfName == "" || infraID == "" { return false, nil } @@ -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()) } @@ -587,9 +589,9 @@ func (g *gitOpsService) updateExperiment(ctx context.Context, data, wfID, file s fileName = strings.Replace(fileName, ".yaml", "", -1) wfName := gjson.Get(data, "metadata.name").String() infraID := gjson.Get(data, "metadata.labels.infra_id").String() - logrus.Info("Experiment Details | wf_name: ", wfName, " infra_id: ", infraID) + log.Info("Experiment Details | wf_name: ", wfName, " infra_id: ", infraID) if wfName == "" || infraID == "" { - logrus.Error("Cannot Update experiment missing experiment name or infra id") + log.Error("Cannot Update experiment missing experiment name or infra id") return nil } @@ -603,7 +605,7 @@ func (g *gitOpsService) updateExperiment(ctx context.Context, data, wfID, file s } if infraID != experiment[0].InfraID { - logrus.Error("Cannot change infra id for existing experiment") + log.Error("Cannot change infra id for existing experiment") return nil } @@ -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 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.mod b/chaoscenter/subscriber/go.mod index f3700cf6dcd..57b1999e155 100644 --- a/chaoscenter/subscriber/go.mod +++ b/chaoscenter/subscriber/go.mod @@ -11,7 +11,7 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4 github.com/sirupsen/logrus v1.9.3 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.26.0 k8s.io/apimachinery v0.26.0 diff --git a/chaoscenter/subscriber/go.sum b/chaoscenter/subscriber/go.sum index 955163e9a81..23ce4d8491d 100644 --- a/chaoscenter/subscriber/go.sum +++ b/chaoscenter/subscriber/go.sum @@ -232,17 +232,13 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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 } diff --git a/chaoscenter/web/src/views/ExperimentCreationFaultConfiguration/Tabs/Probes/Probes.module.scss b/chaoscenter/web/src/views/ExperimentCreationFaultConfiguration/Tabs/Probes/Probes.module.scss index 8331945aaf3..b42124db6fe 100644 --- a/chaoscenter/web/src/views/ExperimentCreationFaultConfiguration/Tabs/Probes/Probes.module.scss +++ b/chaoscenter/web/src/views/ExperimentCreationFaultConfiguration/Tabs/Probes/Probes.module.scss @@ -71,7 +71,7 @@ div[class*='TableV2--cells'], div[class*='TableV2--header'] { display: grid !important; - grid-template-columns: 1fr 1fr 5px; + grid-template-columns: 3fr 1fr 5px; } :global { diff --git a/chaoscenter/web/yarn.lock b/chaoscenter/web/yarn.lock index cde730f1bbf..4cd34cd8bae 100644 --- a/chaoscenter/web/yarn.lock +++ b/chaoscenter/web/yarn.lock @@ -8524,9 +8524,9 @@ webpack-cli@^4.9.0: webpack-merge "^5.7.3" webpack-dev-middleware@^5.3.1: - version "5.3.3" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz#efae67c2793908e7311f1d9b06f2a08dcc97e51f" - integrity sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA== + version "5.3.4" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517" + integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q== dependencies: colorette "^2.0.10" memfs "^3.4.3"