Skip to content

Commit

Permalink
use $.job.credentials-metadata if $.credentials isn't given
Browse files Browse the repository at this point in the history
  • Loading branch information
brettfo authored and randhircs committed Feb 28, 2025
1 parent a4ee018 commit b9ea83b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.add_credentials_to_nuget_config(credentials)

File.rename(user_nuget_config_path, temporary_nuget_config_path)

package_sources = []
package_sources = [" <add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" />"]
package_source_credentials = []
nuget_credentials.each_with_index do |c, i|
source_name = "nuget_source_#{i + 1}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget_source_1" value="https://private.nuget.example.com/index.json" />
<add key="nuget_source_2" value="https://public.nuget.example.com/index.json" />
</packageSources>
Expand Down
8 changes: 7 additions & 1 deletion updater/lib/dependabot/file_fetcher_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ def create_file_fetcher(directory: nil)
# Use the provided directory or fallback to job.source.directory if directory is nil.
directory_to_use = directory || job.source.directory

job_definition = Environment.job_definition
job_credentials_metadata = job_definition.fetch("job", {}).fetch("credentials-metadata", [])

# prefer credentials directly from the root of the file (will contain secrets) but if not specified, fall back to
# the job's credentials-metadata that has no secrets
credentials = job_definition.fetch("credentials", job_credentials_metadata)
args = {
source: job.source.clone.tap { |s| s.directory = directory_to_use },
credentials: Environment.job_definition.fetch("credentials", []),
credentials: credentials,
options: job.experiments
}
args[:repo_contents_path] = Environment.repo_contents_path if job.clone? || already_cloned?
Expand Down

0 comments on commit b9ea83b

Please sign in to comment.