public VSTSDropProxy(string VSTSDropUri, string path, string pat, TimeSpan blobtimeout) { _dropApi = new RestfulDropApi(pat); _contentClient = new HttpClient() { Timeout = blobtimeout }; if (!Uri.TryCreate(VSTSDropUri, UriKind.Absolute, out _VSTSDropUri)) { throw new ArgumentException($"VSTS drop URI invalid {VSTSDropUri}", nameof(VSTSDropUri)); } if (path == null) { throw new ArgumentException($"VSTS drop URI must contain a ?root= querystring {_VSTSDropUri}", nameof(VSTSDropUri)); } _relativeroot = path.Replace("\\", "/"); if (!_relativeroot.StartsWith("/")) { _relativeroot = "/" + _relativeroot; } if (!_relativeroot.EndsWith("/")) { _relativeroot = _relativeroot + "/"; } //move this to a lazy so we can actually be async? try { var manifesturi = Munge(_VSTSDropUri, ManifestAPIVersion); _files = _dropApi.GetVstsManifest(manifesturi, BlobAPIVersion, _relativeroot).Result; } catch (Exception) { Console.WriteLine($"Not able to get build manifest please check your build '{VSTSDropUri}'"); throw; } if (!_files.Any()) { throw new ArgumentException("Encountered empty build drop check your build " + VSTSDropUri); } //https://1eswiki.com/wiki/CloudBuild_Duplicate_Binplace_Detection }
public VSTSDropProxy(string VSTSDropUri, string path, string pat, ILoggerFactory loggerFactory) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <VSTSDropProxy>(); //mLogger = logger; _dropApi = new RestfulDropApi(pat, _loggerFactory); if (!Uri.TryCreate(VSTSDropUri, UriKind.Absolute, out _VSTSDropUri)) { throw new ArgumentException($"VSTS drop URI invalid {VSTSDropUri}", nameof(VSTSDropUri)); } if (path == null) { throw new ArgumentException($"VSTS drop URI must contain a ?root= querystring {_VSTSDropUri}", nameof(VSTSDropUri)); } _relativeroot = path.Replace("\\", "/"); if (!_relativeroot.StartsWith("/")) { _relativeroot = "/" + _relativeroot; } if (!_relativeroot.EndsWith("/")) { _relativeroot = _relativeroot + "/"; } //move this to a lazy so we can actually be async? IEnumerable <VstsFile> files = null; try { var manifesturi = Munge(_VSTSDropUri, ManifestAPIVersion); files = _dropApi.GetVstsManifest(manifesturi, BlobAPIVersion, _relativeroot).Result; } catch (Exception dropApiException) // gotta catch 'em all! -ash ketchexception. { throw new DropException($"Not able to get build manifest please check your build '{VSTSDropUri}'", dropApiException); } // dictionary doesn't necesarily make sesne now. // clocke: so what does? VstsFilesToDictionary(VSTSDropUri, files); _logger.LogInformation($"Found {_pathToUrl.Count} files, {_blobs.Count} unique."); }
public VSTSDropProxy(string VSTSDropUri, string path, string pat) { //mLogger = logger; _dropApi = new RestfulDropApi(pat); if (!Uri.TryCreate(VSTSDropUri, UriKind.Absolute, out _VSTSDropUri)) { throw new ArgumentException($"VSTS drop URI invalid {VSTSDropUri}", nameof(VSTSDropUri)); } if (path == null) { throw new ArgumentException($"VSTS drop URI must contain a ?root= querystring {_VSTSDropUri}", nameof(VSTSDropUri)); } _relativeroot = path.Replace("\\", "/"); if (!_relativeroot.StartsWith("/")) { _relativeroot = "/" + _relativeroot; } if (!_relativeroot.EndsWith("/")) { _relativeroot = _relativeroot + "/"; } //move this to a lazy so we can actually be async? IEnumerable <VstsFile> files = null; try { var manifesturi = Munge(_VSTSDropUri, ManifestAPIVersion); files = _dropApi.GetVstsManifest(manifesturi, BlobAPIVersion, _relativeroot).Result; } catch (Exception) { Console.WriteLine($"Not able to get build manifest please check your build '{VSTSDropUri}'"); throw; } // dictionary doesn't necesarily make sesne now. // clocke: so what does? VstsFilesToDictionary(VSTSDropUri, files); }
public VSTSDropProxy(string VSTSDropUri, string path, string pat, TimeSpan blobtimeout, int retryCount, bool useSoftLinks, string cacheLocation, int concurrentDownloads, bool computeDockerHashes) { _dropApi = new RestfulDropApi(pat); _contentClient = new HttpClient() { Timeout = blobtimeout }; _retryCount = retryCount; _useSoftLinks = useSoftLinks; _cacheLocation = cacheLocation; _concurrentDownloads = concurrentDownloads; _computeDockerHashes = computeDockerHashes; if (!Uri.TryCreate(VSTSDropUri, UriKind.Absolute, out _VSTSDropUri)) { throw new ArgumentException($"VSTS drop URI invalid {VSTSDropUri}", nameof(VSTSDropUri)); } if (path == null) { throw new ArgumentException($"VSTS drop URI must contain a ?root= querystring {_VSTSDropUri}", nameof(VSTSDropUri)); } _relativeroot = path.Replace('\\', Path.DirectorySeparatorChar); if (!_relativeroot.StartsWith("/")) { _relativeroot = $"/{_relativeroot}"; } if (!_relativeroot.EndsWith("/")) { _relativeroot += "/"; } //move this to a lazy so we can actually be async? try { var manifesturi = Munge(_VSTSDropUri, ManifestAPIVersion); Policy .Handle <HttpRequestException>() .Or <SocketException>() .Or <IOException>() .Or <TaskCanceledException>() .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (e, t) => { Console.WriteLine($"{DateTime.Now.ToString("o")} Transient error downloading manifest '{e}'"); }) .Execute(() => { _files = _dropApi.GetVstsManifest(manifesturi, BlobAPIVersion, _relativeroot).Result; }); } catch (Exception) { Console.WriteLine($"Not able to get build manifest please check your build '{VSTSDropUri}'"); throw; } if (!_files.Any()) { throw new ArgumentException("Encountered empty build drop check your build " + VSTSDropUri); } //https://1eswiki.com/wiki/CloudBuild_Duplicate_Binplace_Detection }