protected override void Execute(StructuredConfigVariablesCommandInputs inputs)
        {
            var targetPath = variables.GetRaw(inputs.TargetPathVariable);

            if (targetPath == null)
            {
                throw new CommandException($"Could not locate target path from variable {inputs.TargetPathVariable} for {nameof(StructuredConfigVariablesCommand)}");
            }

            structuredConfigVariablesService.ReplaceVariables(targetPath);
        }
示例#2
0
        /// <summary>
        /// Uploads multiple files given the globbing patterns provided by the selection properties.
        /// </summary>
        /// <param name="clientFactory"></param>
        /// <param name="deployment"></param>
        /// <param name="selection"></param>
        private async Task <IEnumerable <S3UploadResult> > UploadMultiFileSelection(Func <AmazonS3Client> clientFactory, RunningDeployment deployment, S3MultiFileSelectionProperties selection)
        {
            Guard.NotNull(deployment, "Deployment may not be null");
            Guard.NotNull(selection, "Multi file selection properties may not be null");
            Guard.NotNull(clientFactory, "Client factory must not be null");
            var results = new List <S3UploadResult>();

            var files = new RelativeGlobber((@base, pattern) => fileSystem.EnumerateFilesWithGlob(@base, pattern), deployment.StagingDirectory).EnumerateFilesWithGlob(selection.Pattern).ToList();

            if (!files.Any())
            {
                Log.Info($"The glob pattern '{selection.Pattern}' didn't match any files. Nothing was uploaded to S3.");
                return(results);
            }

            Log.Info($"Glob pattern '{selection.Pattern}' matched {files.Count} files");
            var substitutionPatterns = SplitFilePatternString(selection.VariableSubstitutionPatterns);

            if (substitutionPatterns.Any())
            {
                substituteInFiles.Substitute(deployment.CurrentDirectory, substitutionPatterns);
            }

            var structuredSubstitutionPatterns = SplitFilePatternString(selection.StructuredVariableSubstitutionPatterns);

            if (structuredSubstitutionPatterns.Any())
            {
                structuredConfigVariablesService.ReplaceVariables(deployment.CurrentDirectory, structuredSubstitutionPatterns.ToList());
            }

            foreach (var matchedFile in files)
            {
                var request = CreateRequest(matchedFile.FilePath, $"{selection.BucketKeyPrefix}{matchedFile.MappedRelativePath}", selection);
                LogPutObjectRequest(matchedFile.FilePath, request);

                results.Add(await HandleUploadRequest(clientFactory(), request, WarnAndIgnoreException));
            }

            return(results);
        }
示例#3
0
        public Task Execute(RunningDeployment context)
        {
            structuredConfigVariablesService.ReplaceVariables(context);

            return(this.CompletedTask());
        }