Esempio n. 1
0
        public override async Task Execute(ContainerImageRepositoryPollingJobContext context)
        {
            var allContainerImages = (await _containerImageMetadataService
                                      .GetTagsForRepository(context.ContainerImageRepository))
                                     .ToList();


            IEnumerable <ContainerImage> filter = allContainerImages.OrderByDescending(x => x.CreationDateTime);

            if (LastContainerImageCheck.TryGetValue(context.ContainerImageRepository, out var lastCheckTime))
            {
                filter = filter.Where(x => x.CreationDateTime > lastCheckTime);
            }

            var newContainerImages = filter.ToList();

            if (newContainerImages.Any())
            {
                LastContainerImageCheck[context.ContainerImageRepository] = newContainerImages.First().CreationDateTime;

                await _deploymentWorkflowService.StartImageDeployment(
                    context.ContainerImageRepository,
                    newContainerImages,
                    true);
            }
        }
        public async Task <ActionResult> Post([FromBody] NewDeploymentDto newDeploymentDto)
        {
            var containerImage = new ContainerImage(
                newDeploymentDto.Repository,
                newDeploymentDto.Tag
                );

            var createdDeployments = (await _deploymentWorkflowService.StartImageDeployment(containerImage, false)).ToList();

            if (createdDeployments.Any())
            {
                return(StatusCode(StatusCodes.Status201Created, createdDeployments.Select(ConvertFromModel).ToList()));
            }

            return(Ok());
        }