Skip to content
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

feat: add client for deepcode [IDE-175] #10

Merged
merged 2 commits into from
Mar 14, 2024
Merged

Conversation

teodora-sandu
Copy link
Contributor

@teodora-sandu teodora-sandu commented Mar 13, 2024

Implements the client for the DeepCode API calls, by more or less extracting it from snyk-ls as it is today in https://github.com/snyk/snyk-ls/blob/5be0cbefa40f92837e7470e3550a60492ae1ed24/infrastructure/code/snyk_code_http_client.go. The API calls included are:

  • GET /filters
  • POST /bundle
  • PUT /bundle/:bundleHash

It rewrites the unit tests to use Golang generated mocks and it duplicates the Pact testing that's already in snyk-ls.

We might eventually be able to just use this client and replace the code in snyk-ls but that is not necessarily what I plan on doing next.

@github-actions github-actions bot added feature and removed feature labels Mar 13, 2024
@teodora-sandu teodora-sandu force-pushed the feat/snyk-code-client branch 2 times, most recently from 794039f to 0b0d1af Compare March 13, 2024 18:33
# TODO(forbidigo): revisit
#- forbidigo
# TODO(forcetypeassert): revisit this one! beware fragile asserts in this codebase
#- forcetypeassert
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I didn't have to comment these out but it's linting problems that come from snyk-ls and although I tried to fix them, there were way too many

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes... I think we'll have to take these one at a time in separate PRs to knock down the tech debt. A nice calming activity for a Friday afternoon or a cooldown perhaps.

@teodora-sandu teodora-sandu marked this pull request as ready for review March 13, 2024 18:40
@teodora-sandu teodora-sandu requested a review from a team as a code owner March 13, 2024 18:40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for the future: we could run golangci-lint in fixing mode when format is called.

pact.Setup(true)

t.Setenv("DEEPROXY_API_URL", fmt.Sprintf("http://localhost:%d", pact.Server.Port))
config.CurrentConfig().SetOrganization(orgUUID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, and I'm aware that this is not really part of the PR, whether we should switch code-client to ONLY use the go-application-framework configuration package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we'd be relying on go-application-framework configuration for this.

type localInstrumentor struct {
}

// NewTestInstrumentor is used in pact testing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the normal one? Originally, we had the TestInstrumentor because we didn't want to tests to end up in Sentry, but as we don't use Sentry for distributed tracing & instrumentation anymore, I don't see why we wouldn't be able to use the "normal" instrumentor. It basically just creates a request_id and makes it available in its context - and that's functionality that would be good to have even in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use the snyk-ls one but I wonder now if that's a good idea since we already spoke about how we're worried about the cyclic dependency of snyk-ls->code-client-go->snyk-ls

Like discussed I will merge this and then add the following improvements but let me know if you have any reason to believe we should use the snyk-ls instrumentor in the pact tests too:

  • use the configuration from GAF so we don't depend on the one in snyk-ls
  • refactor the error_reporter so that CaptureError takes in some configuration that decides whether to send diagnostics for LSP
  • use the logger from GAF

Copy link
Contributor

@bastiandoetsch bastiandoetsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some stuff we already discussed directly, one more comment here :)

@teodora-sandu teodora-sandu merged commit 8c21c1f into main Mar 14, 2024
10 checks passed
@teodora-sandu teodora-sandu deleted the feat/snyk-code-client branch March 14, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants