Esempio n. 1
0
        public async Task ExecuteFile(
            [Option("-i", "path to the base directory to search.")] string inputPath,
            [Option("-o", "path to the output kustomization file.")] string outputPath,
            [Option("-s", "search pattern of files. (ex. *.config)")] string searchPattern,
            [Option("-n", "configmap name of ConfigMapGenerator.")] string name,
            [Option("-b", "ConfigMapGenerator behavior.")] Behavior behavior       = Behavior.unspecified,
            [Option("-skip", "skip configMapGenerator: output.")] bool skipHeader  = false,
            [Option("-a", "append just an value to existing config.")] bool append = false,
            [Option("-f", "override outputfile without prompt.")] bool forceOutput = false,
            [Option("-d", "dry run.")] bool dryRun = true
            )
        {
            var generator = new FileConfigMapGenerator(name, behavior, skipHeader);
            var contents  = generator.Generate(inputPath, searchPattern);

            if (dryRun)
            {
                Context.Logger.LogInformation("dryrun mode detected. see output contents.");
                Context.Logger.LogInformation("");
                Context.Logger.LogInformation(contents);
            }
            else
            {
                Context.Logger.LogInformation($"begin writing following contents to {outputPath}.");
                Context.Logger.LogInformation("");
                Context.Logger.LogInformation(contents);

                await generator.WriteAsync(contents, outputPath, forceOutput, append, Context.CancellationToken);
            }
        }