diff --git a/src/Microsoft.Tye.Core/ApplicationGlobals.cs b/src/Microsoft.Tye.Core/ApplicationGlobals.cs deleted file mode 100644 index 7050dfec..00000000 --- a/src/Microsoft.Tye.Core/ApplicationGlobals.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - public sealed class ApplicationGlobals - { - public DeploymentKind DeploymentKind { get; set; } = DeploymentKind.Kubernetes; - - public string? Name { get; set; } - - public ContainerRegistry? Registry { get; set; } - } -} diff --git a/src/Microsoft.Tye.Core/DirectorySearch.cs b/src/Microsoft.Tye.Core/DirectorySearch.cs deleted file mode 100644 index 4093aa17..00000000 --- a/src/Microsoft.Tye.Core/DirectorySearch.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Microsoft.Tye -{ - internal static class DirectorySearch - { - public static string? AscendingSearch(string directoryPath, string fileName) - { - if (directoryPath is null) - { - throw new ArgumentNullException(nameof(directoryPath)); - } - - if (fileName is null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - var directory = new DirectoryInfo(directoryPath); - - while (true) - { - var filePath = Path.Combine(directory.FullName, fileName); - if (File.Exists(filePath)) - { - return filePath; - } - - if (directory == directory.Root) - { - return null; - } - - if (directory.Parent == null) - { - return null; - } - - directory = directory.Parent; - } - } - - public static IEnumerable AscendingWildcardSearch(string directoryPath, string searchPattern) - { - if (directoryPath is null) - { - throw new ArgumentNullException(nameof(directoryPath)); - } - - if (searchPattern is null) - { - throw new ArgumentNullException(nameof(searchPattern)); - } - - var directory = new DirectoryInfo(directoryPath); - - while (true) - { - if (directory.EnumerateFiles(searchPattern).Any()) - { - return directory.EnumerateFiles(searchPattern); - } - - if (directory == directory.Root) - { - return Array.Empty(); - } - - if (directory.Parent == null) - { - return Array.Empty(); - } - - directory = directory.Parent; - } - } - } -} diff --git a/src/Microsoft.Tye.Core/EnvironmentAttribute.cs b/src/Microsoft.Tye.Core/EnvironmentAttribute.cs deleted file mode 100644 index f9dbeb66..00000000 --- a/src/Microsoft.Tye.Core/EnvironmentAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Tye -{ - public class EnvironmentAttribute : Attribute - { - public EnvironmentAttribute(string environmentName) - { - if (environmentName is null) - { - throw new ArgumentNullException(nameof(environmentName)); - } - - EnvironmentName = environmentName; - } - - public string EnvironmentName { get; } - } -} diff --git a/src/Microsoft.Tye.Core/Environments.cs b/src/Microsoft.Tye.Core/Environments.cs deleted file mode 100644 index 64b437c7..00000000 --- a/src/Microsoft.Tye.Core/Environments.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - public static class Environments - { - public const string Development = "Development"; - - public const string Production = "Production"; - } -} diff --git a/src/Microsoft.Tye.Core/GeneratedAssets.cs b/src/Microsoft.Tye.Core/GeneratedAssets.cs deleted file mode 100644 index cd4cc899..00000000 --- a/src/Microsoft.Tye.Core/GeneratedAssets.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - public sealed class GeneratedAssets - { - public ContainerInfo? Container { get; set; } - } -} diff --git a/src/Microsoft.Tye.Core/HelmChartBuilder.cs b/src/Microsoft.Tye.Core/HelmChartBuilder.cs deleted file mode 100644 index b39c76cf..00000000 --- a/src/Microsoft.Tye.Core/HelmChartBuilder.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.CommandLine.Invocation; -using System.IO; -using System.Threading.Tasks; - -namespace Microsoft.Tye -{ - internal static class HelmChartBuilder - { - public static async Task BuildHelmChartAsync(OutputContext output, ApplicationBuilder application, ProjectServiceBuilder project, ContainerInfo container, HelmChartStep chart) - { - if (output is null) - { - throw new ArgumentNullException(nameof(output)); - } - - if (application is null) - { - throw new ArgumentNullException(nameof(application)); - } - - if (project is null) - { - throw new ArgumentNullException(nameof(project)); - } - - if (container is null) - { - throw new ArgumentNullException(nameof(container)); - } - - if (chart is null) - { - throw new ArgumentNullException(nameof(chart)); - } - - var projectDirectory = project.ProjectFile.DirectoryName; - var outputDirectoryPath = Path.Combine(projectDirectory, "bin"); - using var tempDirectory = TempDirectory.Create(); - - HelmChartGenerator.ApplyHelmChartDefaults(application, project, container, chart); - - var chartRoot = Path.Combine(projectDirectory, "charts"); - var chartPath = Path.Combine(chartRoot, chart.ChartName); - - output.WriteDebugLine($"Looking for existing chart in '{chartPath}'."); - if (Directory.Exists(chartPath)) - { - output.WriteDebugLine($"Found existing chart in '{chartPath}'."); - } - else - { - chartRoot = tempDirectory.DirectoryPath; - chartPath = Path.Combine(chartRoot, chart.ChartName); - output.WriteDebugLine($"Generating chart in '{chartPath}'."); - await HelmChartGenerator.GenerateAsync(output, application, project, container, chart, new DirectoryInfo(tempDirectory.DirectoryPath)); - } - - output.WriteDebugLine("Running 'helm package'."); - output.WriteCommandLine("helm", $"package -d \"{outputDirectoryPath}\" --version {project.Version.Replace('+', '-')} --app-version {project.Version.Replace('+', '-')}"); - var capture = output.Capture(); - var exitCode = await Process.ExecuteAsync( - "helm", - $"package . -d \"{outputDirectoryPath}\" --version {project.Version.Replace('+', '-')} --app-version {project.Version.Replace('+', '-')}", - workingDir: chartPath, - stdOut: capture.StdOut, - stdErr: capture.StdErr); - - output.WriteDebugLine($"Running 'helm package' exit code: {exitCode}"); - if (exitCode != 0) - { - throw new CommandException("Running 'helm package' failed."); - } - - output.WriteInfoLine($"Created Helm Chart: {Path.Combine(outputDirectoryPath, chart.ChartName + "-" + project.Version.Replace('+', '-') + ".tgz")}"); - } - } -} diff --git a/src/Microsoft.Tye.Core/HelmPush.cs b/src/Microsoft.Tye.Core/HelmPush.cs deleted file mode 100644 index fcfcd55a..00000000 --- a/src/Microsoft.Tye.Core/HelmPush.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.CommandLine.Invocation; -using System.Threading.Tasks; - -namespace Microsoft.Tye -{ - internal static class HelmPush - { - public static async Task ExecuteAsync(OutputContext output, string registryHostname, string chartFilePath) - { - if (output is null) - { - throw new ArgumentNullException(nameof(output)); - } - - if (registryHostname is null) - { - throw new ArgumentNullException(nameof(registryHostname)); - } - - if (chartFilePath is null) - { - throw new ArgumentNullException(nameof(chartFilePath)); - } - - // NOTE: this is currently hardcoded to use ACR and uses the azure CLI to do - // the push operation. Helm 3 has support for pushing to OCI repositories, - // but it's not documented that it works yet for azure. - if (!registryHostname.EndsWith(".azurecr.io")) - { - throw new CommandException("Currently pushing of helm charts is limited to '*.azurecr.io'."); - } - - var registryName = registryHostname.Substring(0, registryHostname.Length - ".azurecr.io".Length); - - output.WriteDebugLine("Running 'az acr helm push'."); - output.WriteCommandLine("az", $"acr helm push --name {registryName} \"{chartFilePath}\""); - var capture = output.Capture(); - var exitCode = await Process.ExecuteAsync( - $"az", - $"acr helm push --name {registryName} \"{chartFilePath}\"", - stdOut: capture.StdOut, - stdErr: capture.StdErr); - - output.WriteDebugLine($"Done running 'az acr helm push' exit code: {exitCode}"); - if (exitCode != 0) - { - throw new CommandException("'az acr helm push' failed."); - } - } - } -} diff --git a/src/Microsoft.Tye.Core/NameSanitizer.cs b/src/Microsoft.Tye.Core/NameSanitizer.cs deleted file mode 100644 index 27131bef..00000000 --- a/src/Microsoft.Tye.Core/NameSanitizer.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Tye -{ - public static class NameSanitizer - { - // Converts an arbitrary string into something usable as a C# identifier. - // - // For instance the project file might be `test-project.csproj` but `test-project` is - // not what will appear in `launchSettings.json`. We need to convert to - // `test_project` - public static string SanitizeToIdentifier(string name) - { - if (name is null) - { - throw new ArgumentNullException(nameof(name)); - } - - // This is not perfect. For now it just handles cases we've encountered. - return name.Replace("-", "_"); - } - } -} diff --git a/src/Microsoft.Tye.Core/Names.cs b/src/Microsoft.Tye.Core/Names.cs deleted file mode 100644 index 8b5e3943..00000000 --- a/src/Microsoft.Tye.Core/Names.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Tye -{ - internal static class Names - { - public static string NormalizeToDns(string name) - { - if (name is null) - { - throw new ArgumentNullException(nameof(name)); - } - - name = name.ToLowerInvariant(); - name = name.Replace('.', '-'); - name = name.Replace('_', '-'); - return name; - } - - public static string NormalizeToFriendly(string name) - { - if (name is null) - { - throw new ArgumentNullException(nameof(name)); - } - - name = name.Replace('.', '_'); - name = name.Replace('-', '_'); - return name; - } - } -} diff --git a/src/Microsoft.Tye.Core/OamApplicationGenerator.cs b/src/Microsoft.Tye.Core/OamApplicationGenerator.cs deleted file mode 100644 index cf0fada1..00000000 --- a/src/Microsoft.Tye.Core/OamApplicationGenerator.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using YamlDotNet.RepresentationModel; - -namespace Microsoft.Tye -{ - internal static class OamApplicationGenerator - { - public static Task WriteOamApplicationAsync(TextWriter writer, OutputContext output, ApplicationBuilder application, string environment) - { - if (writer is null) - { - throw new ArgumentNullException(nameof(writer)); - } - - if (output is null) - { - throw new ArgumentNullException(nameof(output)); - } - - if (application is null) - { - throw new ArgumentNullException(nameof(application)); - } - - if (environment is null) - { - throw new ArgumentNullException(nameof(environment)); - } - - var componentManifests = new List(); - var documents = new List(); - - foreach (var service in application.Services) - { - componentManifests.AddRange(service.Outputs.OfType()); - } - - var root = new YamlMappingNode(); - - root.Add("kind", "ApplicationConfiguration"); - root.Add("apiVersion", "core.oam.dev/v1alpha1"); - - var metadata = new YamlMappingNode(); - root.Add("metadata", metadata); - metadata.Add("name", application.Name); - - var spec = new YamlMappingNode(); - root.Add("spec", spec); - - var components = new YamlSequenceNode(); - spec.Add("components", components); - - foreach (var manifest in componentManifests) - { - documents.Add(manifest.Yaml); - - var component = new YamlMappingNode(); - components.Add(component); - - component.Add("componentName", manifest.Name); - component.Add("instanceName", $"{environment.ToLowerInvariant()}-{manifest.Name}"); - } - - documents.Add(new YamlDocument(root)); - - var stream = new YamlStream(documents.ToArray()); - stream.Save(writer, assignAnchors: false); - - return Task.CompletedTask; - } - } -} diff --git a/src/Microsoft.Tye.Core/PipelineHolder.cs b/src/Microsoft.Tye.Core/PipelineHolder.cs deleted file mode 100644 index 579c705e..00000000 --- a/src/Microsoft.Tye.Core/PipelineHolder.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Tye -{ - public sealed class PipelineHolder - { - public PipelineHolder(Pipeline pipeline) - { - if (pipeline is null) - { - throw new ArgumentNullException(nameof(pipeline)); - } - - __Pipeline = pipeline; - } - - public Pipeline __Pipeline { get; } - } -} diff --git a/src/Microsoft.Tye.Core/Program.cs b/src/Microsoft.Tye.Core/Program.cs deleted file mode 100644 index bd97b092..00000000 --- a/src/Microsoft.Tye.Core/Program.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - static class Program - { - public static void Main() - { - } - } -} diff --git a/src/Microsoft.Tye.Core/ServiceBinding.cs b/src/Microsoft.Tye.Core/ServiceBinding.cs deleted file mode 100644 index d4a0be37..00000000 --- a/src/Microsoft.Tye.Core/ServiceBinding.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - public class ServiceBinding - { - public ServiceBinding(string name) - { - Name = name; - } - - public string Name { get; } - public string? Host { get; set; } - public string? Protocol { get; set; } - public int? Port { get; set; } - public string? ConnectionString { get; set; } - public Secret? Secret { get; set; } - } -} diff --git a/src/Microsoft.Tye.Core/StepView.cs b/src/Microsoft.Tye.Core/StepView.cs deleted file mode 100644 index 3f6c9107..00000000 --- a/src/Microsoft.Tye.Core/StepView.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Tye -{ - internal class StepView - { - - } -} diff --git a/src/Microsoft.Tye.Core/Templates.cs b/src/Microsoft.Tye.Core/Templates.cs deleted file mode 100644 index ce21a76c..00000000 --- a/src/Microsoft.Tye.Core/Templates.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; - -namespace Microsoft.Tye -{ - internal static class Templates - { - public static string RootDirectoryPath - { - get - { - return Path.Combine( - Path.GetDirectoryName(typeof(HelmChartGenerator).Assembly.Location)!, - "Templates"); - } - } - - public static string HelmChartsDirectoryPath - { - get - { - return Path.Combine(RootDirectoryPath, "Helm"); - } - } - } -} diff --git a/src/tye/tye.csproj b/src/tye/tye.csproj index 71460886..1bc977ed 100644 --- a/src/tye/tye.csproj +++ b/src/tye/tye.csproj @@ -13,7 +13,6 @@ -