Skip to content

[Updater] Remove an unused ApiClient method, Make Dependabot::Job an explicit receiver for more parameters#6810

Merged
brrygrdn merged 10 commits intomainfrom
brrygrdn/harden-job-objects
Mar 14, 2023
Merged

[Updater] Remove an unused ApiClient method, Make Dependabot::Job an explicit receiver for more parameters#6810
brrygrdn merged 10 commits intomainfrom
brrygrdn/harden-job-objects

Conversation

@brrygrdn
Copy link
Copy Markdown
Contributor

Follows up on #6770, #6792 and #6808

This is another clear-the-way PR for #6663 [Prototype] Generating grouped update PRs.

The primary changes in this PR are:

  • Remove ApiClient.fetch_jobs
    • This endpoint was maintained for Dependabot Preview, all current workflows, including the CLI, retrieve this information outside the Updater's container and inject it into a JSON file
  • Consolidate all the logic to filter the Job JSON file into Dependabot::Job itself
  • Move repo_contents_path into Dependabot::Job so we aren't mixing methods of referring back to Dependabot::Environment or passing it as an additional argument

The aim of this is to have as little repetition around creating a Dependabot::Job as possible as well as binding all inputs shared by the FileFetcherCommand and UpateFilesCommand to it.

This leaves the base_commit_sha and dependency_files as floating parameters which are produced by the FileFetcherCommand and consumed by the UpateFilesCommand. I don't think it makes sense to bind these to Dependabot::Job as they are a separate concern for that reason. I may bind these into a value class in a subsequent PR if this makes sense.

@brrygrdn brrygrdn requested a review from a team as a code owner March 10, 2023 13:24
Copy link
Copy Markdown
Contributor

@landongrindheim landongrindheim left a comment

Choose a reason for hiding this comment

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

I love the direction these changes are moving us toward! 👨‍🍳👌

Comment on lines 88 to 89
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since a job is supposed to live/execute in a transient environment, I'm really digging Environment as a global (hopefully unchanging) space to store facts 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is currently an Updater-isim but I think we should probably split it out into Core and have an Dependabot::UpdaterEnvironment module which extends Dependabot::Environment at some point as I like the pattern.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👏 This is a great improvement!

@brrygrdn brrygrdn force-pushed the brrygrdn/harden-job-objects branch from 2688ec4 to 0e98ad8 Compare March 10, 2023 16:22
brrygrdn and others added 10 commits March 14, 2023 10:54
This method was used in Dependabot Preview to retrieve the Job from an API call,
in modern Dependabot the Job definition is always injected into the container by
the Docker co-ordination layer ( the CLI, the Dependabot Action, etc ).

This method doesn't need to be maintained anymore and it duplicates Job instantiation
which presents a risk where we could naievely provide the wrong credentials to the
Fetch/Update steps
Co-authored-by: Landon Grindheim <landon.grindheim@gmail.com>
@brrygrdn brrygrdn force-pushed the brrygrdn/harden-job-objects branch from f793484 to 5490d47 Compare March 14, 2023 10:54
@brrygrdn brrygrdn merged commit 6c0e305 into main Mar 14, 2023
@brrygrdn brrygrdn deleted the brrygrdn/harden-job-objects branch March 14, 2023 12:46
brrygrdn added a commit that referenced this pull request Mar 28, 2023
This should have been removed in #6810

Our API returns a 4xx response and a blank job description if a job that has already been
processed is requested, but this no longer happens within the Dependabot::Updater code.

The layer that constructs the docker containers which the code runs in will not be able
to inject a file and will bail out before ever invoking any Ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants