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

make a Credential class #8967

Merged
merged 9 commits into from
Feb 5, 2024
Merged

make a Credential class #8967

merged 9 commits into from
Feb 5, 2024

Conversation

jakecoffman
Copy link
Member

@jakecoffman jakecoffman commented Feb 2, 2024

credentials was incorrectly typed as a T::Array[T::Hash[String,String]] but because of replaces-base it's actually a T::Array[T::Hash[String,T.any(T::Boolean,String)]].

I thought since I have to touch all these places to change the type I could introduce a class instead to make it nicer.

@github-actions github-actions bot added L: ruby:bundler RubyGems via bundler L: docker Docker containers L: java:maven Maven packages via Maven L: javascript L: python labels Feb 2, 2024
@jakecoffman
Copy link
Member Author

Ok maybe now that I have to change all the specs I might regret it.

@jakecoffman jakecoffman marked this pull request as ready for review February 2, 2024 22:17
@jakecoffman jakecoffman requested a review from a team as a code owner February 2, 2024 22:17
@@ -0,0 +1,30 @@
# typed: strict
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be strong?

Copy link
Member Author

Choose a reason for hiding this comment

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

strong gets mad that def_delegators brings in untyped methods. I decided to punt on figuring that out or reimplementing them like with [] for now. I think the PR got large enough 😬

@jakecoffman jakecoffman merged commit 89737ae into main Feb 5, 2024
121 checks passed
@jakecoffman jakecoffman deleted the jakecoffman/make-credential branch February 5, 2024 15:41
@lorengordon
Copy link
Contributor

@jakecoffman Just a heads up that this also breaks anyone using the setup defined in dependabot-script. Any suggestions on how to set things up now, using the class?

@lorengordon
Copy link
Contributor

I hope it's this easy...

diff --git a/dependabot-codecommit/dependabot.rb b/dependabot-codecommit/dependabot.rb
index 79c3430..b32cc46 100644
--- a/dependabot-codecommit/dependabot.rb
+++ b/dependabot-codecommit/dependabot.rb
@@ -6,6 +6,7 @@ require_relative "updater"
 require_relative "client"
 require_relative "utils"

+require "dependabot/credential"
 require "dependabot/file_fetchers"
 require "logger"

@@ -18,12 +19,12 @@ logger.level = Logger::INFO

 error_set = Set[]
 credentials = [
-  {
+  Dependabot::Credential.new({
     "type" => "git_source",
     "host" => "github.com",
     "username" => "x-access-token",
     "password" => ENV["GITHUB_ACCESS_TOKEN"] # A GitHub access token with read access to public repos
-  }
+  })
 ]

@lorengordon
Copy link
Contributor

Yes, looks like that did it!

lorengordon added a commit to lorengordon/dependabot-script that referenced this pull request Jun 4, 2024
Since dependabot/dependabot-core#8967 in dependabot-core v0.243.0, the credential object is no longer just a hash. It now must be a Credential class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: docker Docker containers L: java:maven Maven packages via Maven L: javascript L: python L: ruby:bundler RubyGems via bundler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants