예제 #1
0
        /// <summary>
        /// Конструктор. Создает новый агрегат.
        /// </summary>
        /// <param name="buildDate">Дата сборки.</param>
        /// <param name="number">Номер.</param>
        /// <param name="releaseNumber">Номер релиза.</param>
        /// <param name="distributionId">Идентификатор дистрибутива.</param>
        /// <param name="location">Местоположение.</param>
        /// <param name="sourceType">Тип хранилища.</param>
        /// <param name="lifeCycleState"><see cref="LifeCycleState"/>.</param>
        /// <param name="suffixes">Суффиксы.</param>
        public Build(
            DateTime buildDate,
            VersionNumber number,
            VersionNumber releaseNumber,
            Guid distributionId,
            string location,
            BuildSourceType sourceType,
            LifeCycleState lifeCycleState,
            IList <string> suffixes = null)
        {
            location.ThrowIsNullOrWhiteSpace(new CreateBuildException("Invalid location value"));
            ValidateReleaseNumber(releaseNumber, number, location);

            Id = Guid.NewGuid();

            Apply(new BuildCreated(
                      Id,
                      buildDate,
                      distributionId,
                      location,
                      number,
                      releaseNumber,
                      lifeCycleState,
                      sourceType,
                      suffixes ?? new List <string>(),
                      CreateMetadata()));
            UpdateArtifactState(ArtifactState.Created);
        }
        /// <summary>
        /// Отправляет команду на изменение суффиксов у сборки.
        /// </summary>
        /// <param name="buildLocation">Путь к сборке.</param>
        /// <param name="sourceType">Тип источника.</param>
        /// <param name="suffixes">Суффиксы для записи.</param>
        /// <param name="currentSuffixes">Нынешние суффиксы сборки.</param>
        /// <returns><see cref="Task"/>.</returns>
        public async Task <IResponseMessage> ChangeSuffix(string buildLocation, BuildSourceType sourceType, List <string> suffixes, List <string> currentSuffixes)
        {
            var request = new ChangeSuffixesRequest {
                BuildPath = buildLocation, SourceType = sourceType, Suffixes = suffixes, CurrentSuffixes = currentSuffixes
            };

            return(await busClient.SendRequest <ChangeSuffixesRequest, IResponseMessage>(request, sendRequestOptions));
        }
        /// <summary>
        /// Получить адрес StaticStorage.
        /// </summary>
        /// <param name="buildSourceType">Тип хранилища сборки.</param>
        /// <returns>Адрес StaticStorage.</returns>
        public string GetServiceUrl(BuildSourceType buildSourceType)
        {
            string result = settings.Services.TryGetValue(buildSourceType, out string baseUrl)
                ? baseUrl
                : throw new NotSupportedException($"Не удалось найти путь StaticStorage сервиса для {buildSourceType:G}");

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="path">Путь к сборкам.</param>
        /// <param name="pattern">Паттерн.</param>
        /// <param name="sourceType">Тип источника.</param>
        public BuildsBinding(string path, BuildMatchPattern pattern, BuildSourceType sourceType)
        {
            path.ThrowIsNullOrWhiteSpace(new CreateValueObjectException(nameof(BuildsBinding), "Invalid path"));
            pattern.ThrowIfNull(new CreateValueObjectException(nameof(BuildsBinding), "Invalid pattern"));

            Path       = path;
            Pattern    = pattern;
            SourceType = sourceType;
        }
예제 #5
0
        /// <summary>
        /// Получить клиент.
        /// </summary>
        /// <param name="buildSourceType">Тип сборки.</param>
        /// <returns>Клиент StaticService.</returns>
        public StaticStorageClient Get(BuildSourceType buildSourceType)
        {
            var url = staticStorageUrlProvider.GetServiceUrl(buildSourceType);

            var client = serviceProvider.GetService <StaticStorageClient>();

            client.ServiceUrl = url;

            return(client);
        }
예제 #6
0
        /// <inheritdoc />
        public Task <string> GetOpenUrl(BuildSourceType buildSourceType, string buildLocation)
        {
            string path = PathEncoder.GetEncoded(buildLocation);

            string result = settings.BaseUrlsToOpenBuilds.TryGetValue(buildSourceType, out string baseUrl)
                ? Path.Combine(baseUrl, path)
                : throw new NotSupportedException($"Не удалось найти базовый путь для {buildSourceType:G}");

            return(Task.FromResult(result));
        }
        /// <summary>
        /// Поиск сборок.
        /// </summary>
        /// <param name="path">Путь к каталогу для поиска.</param>
        /// <param name="sourceType">Тип источника сборок.</param>
        /// <param name="patternsToCheck">Список патернов для распознавания сборок.</param>
        /// <returns>Результат поиска.</returns>
        public async Task <IResponseMessage> SearchBuilds(string path, BuildSourceType sourceType, IEnumerable <string> patternsToCheck)
        {
            var request = new ScanForBuildsRequest
            {
                Path            = path,
                PatternsToCheck = patternsToCheck.ToList(),
                SourceType      = sourceType
            };

            return(await busClient.SendRequest <ScanForBuildsRequest, IResponseMessage>(request, sendRequestOptions));
        }
        /// <summary>
        /// Поиск сборок.
        /// </summary>
        /// <param name="path">Путь к каталогу для поиска.</param>
        /// <param name="sourceType">Тип источника сборок.</param>
        /// <param name="pattern">Список патернов для распознавания сборок.</param>
        /// <returns>Результат поиска.</returns>
        public async Task <ParseBuildsResponse> ParseBuilds(string path, BuildSourceType sourceType, string pattern)
        {
            var request = new ParseBuildsRequest
            {
                Path       = path,
                Pattern    = pattern,
                SourceType = sourceType
            };

            return(await busClient.SendRequest <ParseBuildsRequest, ParseBuildsResponse>(request, sendRequestOptions));
        }
예제 #9
0
 private static BuildBindingReadModel GetBuildBindings(string pattern, BuildSourceType buildSource)
 {
     return(new BuildBindingReadModel()
     {
         Pattern = new BuildMatchPatternReadModel()
         {
             Regexp = pattern
         },
         Path = buildSource == BuildSourceType.Pdc ? pdcBuildBindingFakePath : artifactoryBuildBindingFakePath,
         SourceType = buildSource
     });
 }
        private char GetSeparator(BuildSourceType buildSourceType)
        {
            switch (buildSourceType)
            {
            case BuildSourceType.Pdc: return(Path.DirectorySeparatorChar);

            case BuildSourceType.Artifactory: return(Path.AltDirectorySeparatorChar);

            default:
                throw new NotSupportedException();
            }
        }
예제 #11
0
        /// <inheritdoc />
        public Task <IResponseMessage> SearchBuilds(string path, BuildSourceType sourceType, IEnumerable <string> patternsToCheck)
        {
            var response = new ScanForBuildsListResponse()
            {
                Items = new List <ScanForBuildsResult>
                {
                    new ScanForBuildsResult
                    {
                        PatternMatch = Guid.NewGuid().ToString(),
                        BuildsCount  = 25
                    }
                }
            };

            return(Task.FromResult <IResponseMessage>(response));
        }
        public void GenerateAllPossibleRelativePath_EqualsToExpectedResult(string version, BuildSourceType sourceType, string[] exceptedResult)
        {
            var versionNumber = new VersionNumber(version);

            string[] relativePaths = BuildPathGenerator.GenerateAllPossibleRelativePath(versionNumber, GetSeparator(sourceType)).ToArray();

            Assert.Equal(exceptedResult, relativePaths);
        }
예제 #13
0
        public async Task <IActionResult> Get([Required(AllowEmptyStrings = false)] string location, BuildSourceType sourceType)
        {
            BuildReadModel build =
                await buildReadOnlyRepository
                .WithCaseSensitive()
                .Query(x => x.Location == location && x.SourceType == sourceType);

            return(Ok(new GetBuildResponse {
                Build = mapper.Map <BuildDto>(build)
            }));
        }
예제 #14
0
 /// <inheritdoc />
 public Task <ParseBuildsResponse> ParseBuilds(string path, BuildSourceType sourceType, string pattern)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Возвращает адрес для загрузки файлов по тикету.
        /// </summary>
        /// <param name="buildSourceType">Тип хранилища</param>
        /// <param name="path">Путь для расположения файлов.</param>
        /// <param name="uploadOptions">Настройки загрузки..</param>
        /// <param name="uploadFileInfos">Информация о файлах.</param>
        /// <param name="comment">Комментарий.</param>
        /// <returns>Адрес для загрузки файлов.</returns>
        public async Task <string> GetUrlToUploadFiles(BuildSourceType buildSourceType, string path, UploadOptions uploadOptions, UploadFileInfoDto[] uploadFileInfos, string comment = null)
        {
            var client = staticStorageClientFactory.Get(buildSourceType);

            return(await client.GetUrlToUploadFilesByTicket(path, uploadOptions, uploadFileInfos, comment));
        }
        /// <summary>
        /// Возвращает адрес для скачивания файлов по тикету.
        /// </summary>
        /// <param name="buildSourceType">Тип хранилища</param>
        /// <param name="path">Путь для расположения файлов.</param>
        /// <param name="comment">Комментарий.</param>
        /// <returns>Адрес для скачивания файлов.</returns>
        public async Task <string> GetUrlToDownloadFiles(BuildSourceType buildSourceType, string path, string comment = null)
        {
            var client = staticStorageClientFactory.Get(buildSourceType);

            return(await client.GetUrlToDownloadFilesByTicket(path));
        }
예제 #17
0
 /// <inheritdoc />
 public Task <IResponseMessage> ChangeSuffix(string buildLocation, BuildSourceType sourceType, List <string> suffixes, List <string> currentSuffixes)
 {
     throw new System.NotImplementedException();
 }