Пример #1
0
        public override async Task Execute(DeploymentManifestSourceTrackingContext context)
        {
            using (_log.BeginScope(new Dictionary <string, object>
            {
                { "Application", context.ApplicationName },
                { "Ref", context.DeploymentManifest.Repository.Ref },
                { "Path", context.DeploymentManifest.Path }
            }))
            {
                var repository = context.DeploymentManifest.Repository;
                await _deploymentManifestRepositoryService.Checkout(repository);

                var application = _applicationService.GetApplication(context.ApplicationName);

                var manifestsChanged = context.DeploymentManifest switch
                {
                    HelmDeploymentManifest helmDeploymentManifest => await InternalExecute(helmDeploymentManifest,
                                                                                           application),
                    RawDeploymentManifest rawDeploymentManifest => await InternalExecute(rawDeploymentManifest,
                                                                                         application),
                    _ => throw new ArgumentOutOfRangeException()
                };

                if (
                    manifestsChanged &&
                    context.AutoDeploy &&
                    !_configuration.Value.Dryrun)
                {
                    await _deploymentManifestRepositoryService.Push(repository);
                }
            }
        }
    }