Skip to content

Commit

Permalink
Removing Docker clients use of proxy (#149)
Browse files Browse the repository at this point in the history
* Removing Docker clients use of proxy

 as should be internal to AWS

* Reverting docker http to use direct client
  • Loading branch information
flurdy authored May 24, 2024
1 parent a297ff9 commit 1d13e34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,5 @@ __pycache__/
library.db

# AWS logs
*/aws-logger*.txt
*/aws-logger*.txt
.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public void DockerServiceShouldExtractFilesFromTgzStream()

// A list of paths we dont want to scan (stuff in the base image basically, avoids false positives
var pathsToIgnore = new List<Regex> { new("^/?usr/.*") };

var mockHttp = Substitute.For<HttpClient>();
var opts = new DockerServiceOptions();
var client = new DockerClient(new MockClientFactory(), Options.Create(opts), new EmptyDockerCredentialProvider(),
var client = new DockerClient(mockHttp, Options.Create(opts), new EmptyDockerCredentialProvider(),
NullLoggerFactory.Instance.CreateLogger<DockerClient>());

using (var fs = File.OpenRead("Resources/testlayer.tgz"))
{
var files = client.ExtractFilesFromStream(fs, "test:1.0.0", filesToExtract, pathsToIgnore);
Expand Down Expand Up @@ -131,4 +131,4 @@ public async void ScanImageShouldSaveAnArtifact()
Assert.Single(artifact!.Files);
Assert.Equal("sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c", artifact.Sha256);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ public class DockerClient : IDockerClient
private readonly ILogger _logger;

public DockerClient(
IHttpClientFactory clientFactory,
HttpClient client,
IOptions<DockerServiceOptions> options,
IDockerCredentialProvider credentialProvider,
ILogger<DockerClient> logger)
{
_client = clientFactory.CreateClient(Proxy.ProxyClient);
_client = client;
_logger = logger;
_baseUrl = options.Value.RegistryUrl;
_credentialProvider = credentialProvider;
_client.DefaultRequestHeaders.Accept.Clear();

}

public async Task<ImageTagList> FindTags(string repo)
Expand Down Expand Up @@ -173,4 +172,4 @@ public List<LayerFile> ExtractFilesFromStream(Stream stream, string sourceName,

return files;
}
}
}

0 comments on commit 1d13e34

Please sign in to comment.