Beispiel #1
0
        void AddParts(Package package, PackageDefinition manifest, string directory, string baseDataStorePath)
        {
            foreach (var file in fileSystem.EnumerateFiles(directory))
            {
                var partUri = new Uri(baseDataStorePath + "/" + Path.GetFileName(file), UriKind.Relative);
                AddContent(package, manifest, partUri, file);
            }

            foreach (var subDirectory in fileSystem.EnumerateDirectories(directory).Select(x => new DirectoryInfo(x)))
            {
                AddParts(package, manifest, subDirectory.FullName, baseDataStorePath + "/" + subDirectory.Name);
            }
        }
Beispiel #2
0
        public static void LogDirectoryContents(ILog log, ICalamariFileSystem fileSystem, string workingDirectory, string currentDirectoryRelativePath, int depth = 0)
        {
            var directory = new DirectoryInfo(Path.Combine(workingDirectory, currentDirectoryRelativePath));

            var files = fileSystem.EnumerateFiles(directory.FullName).ToList();

            for (int i = 0; i < files.Count; i++)
            {
                // Only log the first 50 files in each directory
                if (i == 50)
                {
                    log.VerboseFormat("{0}And {1} more files...", Indent(depth), files.Count - i);
                    break;
                }

                var file = files[i];
                log.Verbose(Indent(depth) + Path.GetFileName(file));
            }

            foreach (var subDirectory in fileSystem.EnumerateDirectories(directory.FullName).Select(x => new DirectoryInfo(x)))
            {
                log.Verbose(Indent(depth + 1) + "\\" + subDirectory.Name);
                LogDirectoryContents(log, fileSystem, workingDirectory, Path.Combine(currentDirectoryRelativePath, subDirectory.Name), depth + 1);
            }
        }
        string GetChartLocation(RunningDeployment deployment)
        {
            var installDir = deployment.Variables.Get(PackageVariables.Output.InstallationDirectoryPath);

            var packageId = deployment.Variables.Get(PackageVariables.IndexedPackageId(string.Empty));

            // Try the root directory
            if (fileSystem.FileExists(Path.Combine(installDir, "Chart.yaml")))
            {
                return(Path.Combine(installDir, "Chart.yaml"));
            }

            // Try the directory that matches the package id
            var packageIdPath = Path.Combine(installDir, packageId);

            if (fileSystem.DirectoryExists(packageIdPath) && fileSystem.FileExists(Path.Combine(packageIdPath, "Chart.yaml")))
            {
                return(packageIdPath);
            }

            /*
             * Although conventions suggests that the directory inside the helm archive matches the package ID, this
             * can not be assumed. If the standard locations above failed to locate the Chart.yaml file, loop over
             * all subdirectories to try and find the file.
             */
            foreach (var dir in fileSystem.EnumerateDirectories(installDir))
            {
                if (fileSystem.FileExists(Path.Combine(dir, "Chart.yaml")))
                {
                    return(dir);
                }
            }

            // Nothing worked
            throw new CommandException($"Unexpected error. Chart.yaml was not found in {packageIdPath}");
        }