-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jurre/hash-private-packages
- Loading branch information
Showing
30 changed files
with
5,388 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
require "yaml" | ||
|
||
module Dependabot | ||
module Cargo | ||
module Helpers | ||
def self.setup_credentials_in_environment(credentials) | ||
credentials.each do |cred| | ||
next if cred["type"] != "cargo_registry" | ||
|
||
# If there is a 'token' property, then apply it. | ||
# If there is not, it probably means we are running under dependabot-cli which stripped | ||
# all tokens. So in that case, we assume that the dependabot proxy will re-inject the | ||
# actual correct token, and we just use 'token' as a placeholder at this point. | ||
# (We must add these environment variables here, or 'cargo update' will not think it is | ||
# configured properly for the private registries.) | ||
|
||
token_env_var = "CARGO_REGISTRIES_#{cred['cargo_registry'].upcase.tr('-', '_')}_TOKEN" | ||
|
||
token = "placeholder_token" | ||
if cred["token"].nil? | ||
puts "Setting #{token_env_var} to 'placeholder_token' because dependabot-cli proxy will override it anyway" | ||
else | ||
token = cred["token"] | ||
puts "Setting #{token_env_var} to provided token value" | ||
end | ||
|
||
ENV[token_env_var] ||= token | ||
end | ||
|
||
# And set CARGO_REGISTRY_GLOBAL_CREDENTIAL_PROVIDERS here as well, so Cargo will expect tokens | ||
ENV["CARGO_REGISTRY_GLOBAL_CREDENTIAL_PROVIDERS"] ||= "cargo:token" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/file_fetchers" | ||
require "dependabot/file_fetchers/base" | ||
|
||
module Dependabot | ||
module Cargo | ||
class RegistryFetcher < Dependabot::FileFetchers::Base | ||
def self.required_files_in?(filenames) | ||
filenames.include?("config.json") | ||
end | ||
|
||
def self.required_files_message | ||
"Repo must contain a config.json" | ||
end | ||
|
||
def dl | ||
parsed_config_json["dl"].chomp("/") | ||
end | ||
|
||
def api | ||
parsed_config_json["api"].chomp("/") | ||
end | ||
|
||
private | ||
|
||
def fetch_files | ||
fetched_files = [] | ||
fetched_files << config_json | ||
end | ||
|
||
def parsed_config_json | ||
@parsed_config_json ||= JSON.parse(config_json.content) | ||
end | ||
|
||
def config_json | ||
@config_json ||= fetch_file_from_host("config.json") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.