-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Eliminate Global Variable to Enhance Testability #4685
base: master
Are you sure you want to change the base?
Conversation
Hello @namkyu1999 Please review my pull request |
can you check DCO? |
@namkyu1999 Sir, as you instructed, I've tried to complete the checks. Could you please verify them? If there are any changes needed in the code, please let me know, and I'll try to fix them |
Hi @andoriyaprashant, some checks are failing now (build-pipeline, CIFuzz). can you check them? |
i am working on those 👍🏻 |
@@ -32,8 +32,8 @@ type MongoOperations struct { | |||
} | |||
|
|||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this var block itself as well.
@@ -10,20 +10,20 @@ import ( | |||
) | |||
|
|||
// CreateConfig creates a new server config with unique key | |||
func CreateConfig(ctx context.Context, config *ServerConfig) error { | |||
err := mongodb.Operator.Create(ctx, mongodb.ServerConfigCollection, config) | |||
func CreateConfig(ctx context.Context, config *ServerConfig, mongodbOperator mongodb.MongoOperator) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to create an interface and receivers here similar to what we have in other places?
Hello @Saranya-jena @Jonsy13 @namkyu1999 |
The checks are failing can you fix those? |
@andoriyaprashant are you still working on this PR? |
Sorry @Saranya-jena I forgot to check the pull request checks. I'll fix them as soon as possible 👍🏻 |
@andoriyaprashant the checks are still failing, PTAL. |
Ma'am @Saranya-jena , can you please help me or guide me in fixing the CIFuzz workflow error? I tried, but I am not able to understand it |
5bc31c5
to
30cea9a
Compare
updated-dependencies: - dependency-name: github.com/99designs/gqlgen dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Bumps [github.com/vektah/gqlparser/v2](https://github.com/vektah/gqlparser) from 2.5.11 to 2.5.12. - [Release notes](https://github.com/vektah/gqlparser/releases) - [Commits](vektah/gqlparser@v2.5.11...v2.5.12) --- updated-dependencies: - dependency-name: github.com/vektah/gqlparser/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Saranya-jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
* upgrade go version in all the modules Signed-off-by: Saranya-jena <saranya.jena@harness.io> * upgrade go version in dockerfiles Signed-off-by: Saranya-jena <saranya.jena@harness.io> * upgrade go version in github actions Signed-off-by: Saranya-jena <saranya.jena@harness.io> * updated go sum Signed-off-by: Saranya-jena <saranya.jena@harness.io> * updated subscriber dockerfile Signed-off-by: Saranya-jena <saranya.jena@harness.io> --------- Signed-off-by: Saranya-jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
* Added env support to enable/disable gql introspection Signed-off-by: Saranya-jena <saranya.jena@harness.io> * resolved comments Signed-off-by: Saranya-jena <saranya.jena@harness.io> * fixed imports Signed-off-by: Saranya-jena <saranya.jena@harness.io> * fixed build issues Signed-off-by: Saranya-jena <saranya.jena@harness.io> --------- Signed-off-by: Saranya-jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Saranya-jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Jongwoo Han <jongwooo.han@gmail.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Jongwoo Han <jongwooo.han@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…os#4830) Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…os#4666) * fix: Invalid version details in backend. Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Checking CIVersion at start Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> --------- Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> Co-authored-by: Vedant Shrotria <vedant.shrotria@harness.io> Co-authored-by: Amit Kumar Das <amit.das@harness.io> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Bumps [github.com/99designs/gqlgen](https://github.com/99designs/gqlgen) from 0.17.47 to 0.17.49. - [Release notes](https://github.com/99designs/gqlgen/releases) - [Changelog](https://github.com/99designs/gqlgen/blob/master/CHANGELOG.md) - [Commits](99designs/gqlgen@v0.17.47...v0.17.49) --- updated-dependencies: - dependency-name: github.com/99designs/gqlgen dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…uschaos#4692) Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…haos#4762) Signed-off-by: Denish Tomar <denishtomar3436@gmail.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Co-authored-by: Sahil <sahil.kumar@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…itmuschaos#4813) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.25.0 to 0.26.0. - [Commits](golang/crypto@v0.25.0...v0.26.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.15.0 to 1.16.1. - [Release notes](https://github.com/mongodb/mongo-go-driver/releases) - [Commits](mongodb/mongo-go-driver@v1.15.0...v1.16.1) --- updated-dependencies: - dependency-name: go.mongodb.org/mongo-driver dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Baalekshan <baalekshan@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Suyeon Jung <suyeonjungdev@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.15.1 to 1.16.1. - [Release notes](https://github.com/mongodb/mongo-go-driver/releases) - [Commits](mongodb/mongo-go-driver@v1.15.1...v1.16.1) --- updated-dependencies: - dependency-name: go.mongodb.org/mongo-driver dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: hursit <hursit.topal@enuygun.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…os#4779) * Adding environment filter in Infrastructure selection modal Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * setting initialAllInfrastructureLength as 0 initially Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * making InitialAllInfrastructureLength consistent Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Scroll env list and Pagination(infra) Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * added preSelectedEnvironmentID Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Minor changes in code Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Refactored code Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Changing height of infralist section Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> * Minor improvements Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> --------- Signed-off-by: JanhaviAlekar <janhavialekar@gmail.com> Co-authored-by: Sahil <sahil.kumar@harness.io> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: 잉퓨 <dayeon620@kakao.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Co-authored-by: Vedant Shrotria <vedant.shrotria@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
litmuschaos#4866) Signed-off-by: DongYoung Kim <kwx4957@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Bumps [github.com/tidwall/gjson](https://github.com/tidwall/gjson) from 1.17.1 to 1.17.3. - [Commits](tidwall/gjson@v1.17.1...v1.17.3) --- updated-dependencies: - dependency-name: github.com/tidwall/gjson dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
* test: add fuzz test to GetChartsPath function in handler Signed-off-by: Soyeon Park <sypark9646@gmail.com> * test: add fuzz test to FuzzReadExperimentFile function in handler * Removed the ./types.go example in unit test handler_test.go/TestReadExperimentFile because it returns a file does not exist error, not the file is not a yaml error that the test is intended to return. Signed-off-by: Soyeon Park <sypark9646@gmail.com> * * test: Add the FuzzReadExperimentYAMLFile test in the handler_fuzz_test.go file Signed-off-by: Soyeon Park <sypark9646@gmail.com> * test: add fuzz test to FuzzIsFileExisting function in handler Signed-off-by: Soyeon Park <sypark9646@gmail.com> * test: add fuzz test to FuzzGetExperimentData, FuzzUnzipRemoteHub function in handler Signed-off-by: Soyeon Park <sypark9646@gmail.com> * refactor: remove unused imported library Signed-off-by: Soyeon Park <sypark9646@gmail.com> * fix: check yaml: control characters are not allowed Signed-off-by: Soyeon Park <sypark9646@gmail.com> * refactor: save goimport order Signed-off-by: Soyeon Park <sypark9646@gmail.com> --------- Signed-off-by: Soyeon Park <sypark9646@gmail.com> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
* add handler_fuzz_test file Signed-off-by: weeeeestern <liz0824@naver.com> * add service_fuzz_test file Signed-off-by: weeeeestern <liz0824@naver.com> * test: add fuzz test Signed-off-by: weeeeestern <liz0824@naver.com> * test: add fuzz_test Signed-off-by: weeeeestern <liz0824@naver.com> * test: modify fuzz-test Signed-off-by: weeeeestern <liz0824@naver.com> * test: modify fuzz-test Signed-off-by: weeeeestern <liz0824@naver.com> --------- Signed-off-by: weeeeestern <liz0824@naver.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
…only a single namespace (litmuschaos#4680) * Create a seperate function to get Namespace in subscriber Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Update graphql server to include KubeNamespace call (model not generated) Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Update graphqls to include KubeNamespace model Update objectmodel and subscriber to incldue KubeNamespace Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Fix issue in graphqls and adding KubeNamespace type. Regenerating model with gqlgen. Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Update model to includude missing field in KubeNamespaceData Rename getKubeNamespace function that didn't match graphqls operation in Subscription Add missing function for the graphql server to retrieve list of namespace Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Add remaining function in k8s pkg and requests to return list of namespace Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Update graphql/subscriber to transform KubeObject to not be a array since subscriber will only return one element. Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Update web server to seperate call for KubeObject and KubeNamespace. Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Fix import with goimports Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Reverting upgrade of webpack-dev-server so it's compatible with github workflow Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Run gofmt with correct version. Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Bumping ubi-minimal:8.8 to 8.10 to fix some HIGH CVE severity detected by trivy. Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Updating chaos_infrastructure mock to include KubeNamespace. Fix a comment Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Fix issue from Codacy Removing some unused code Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Fix codacy issue: - Add some trailing comma - Trying transform subscription function to resolve "non-arrow functions are forbidden" - Add null check Signed-off-by: Calvin Audier <calvinaudier@gmail.com> * Continue fix Codacy issue - Adding trailing comma - Re-ordering by alphabetic order some parameters Signed-off-by: Calvin Audier <calvinaudier@gmail.com> --------- Signed-off-by: Calvin Audier <calvinaudier@gmail.com> Signed-off-by: Calvinaud <calvinaudier@gmail.com> Co-authored-by: Namkyu Park <53862866+namkyu1999@users.noreply.github.com> Co-authored-by: Saranya Jena <saranya.jena@harness.io> Signed-off-by: andoriyaprashant <prashantandoriya@gmail.com>
Signed-off-by: Prashant Andoriya <121665385+andoriyaprashant@users.noreply.github.com>
Hi @andoriyaprashant , can you please rebase with main? The current commit history is incorrect which is why it's pulling a lot of extra commits too. |
Signed-off-by: Prashant Andoriya <121665385+andoriyaprashant@users.noreply.github.com>
Fixes #4217
Proposed changes
This pull request refactors the codebase by removing a global variable to improve testability.
Types of changes
What types of changes does your code introduce to Litmus? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.