This commit is contained in:
Chris Cheetham 2020-02-17 08:55:09 -05:00
Родитель 246f7b672e
Коммит 9ae1542a3d
41 изменённых файлов: 69 добавлений и 155 удалений

Просмотреть файл

@ -15,7 +15,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -50,7 +50,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -16,7 +16,8 @@ using System;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
using Steeltoe.Tooling.Models;
namespace Steeltoe.Cli
{
@ -57,7 +58,7 @@ namespace Steeltoe.Cli
_console.Out,
new CommandShell()
);
GetExecutor().Execute(context);
GetController().Execute(context);
return 0;
}
catch (ArgumentException e)
@ -86,6 +87,6 @@ namespace Steeltoe.Cli
}
}
protected abstract Executor GetExecutor();
protected abstract Controller GetController();
}
}

Просмотреть файл

@ -15,7 +15,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -64,7 +64,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -13,7 +13,7 @@
// limitations under the License.
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -26,13 +26,13 @@ namespace Steeltoe.Cli
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
return new DoctorExecutor();
return new DoctorController();
}
}
internal class DoctorExecutor : Executor
internal class DoctorController : Controller
{
protected override void Execute()
{

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -30,7 +30,7 @@ Overview:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -30,7 +30,7 @@ Overview:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -30,7 +30,7 @@ Overview:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -80,7 +80,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -88,7 +88,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -15,7 +15,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -44,7 +44,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -45,7 +45,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -41,7 +41,7 @@ Examples:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -41,7 +41,7 @@ Examples:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -38,7 +38,7 @@ Examples:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,7 +14,7 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -37,7 +37,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -15,7 +15,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using McMaster.Extensions.CommandLineUtils;
using Steeltoe.Tooling.Executors;
using Steeltoe.Tooling.Controllers;
namespace Steeltoe.Cli
{
@ -48,7 +48,7 @@ See Also:
{
}
protected override Executor GetExecutor()
protected override Controller GetController()
{
throw new NotImplementedException();
}

Просмотреть файл

@ -14,6 +14,7 @@
using System.IO;
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling.Models;
using YamlDotNet.Serialization;
namespace Steeltoe.Tooling

Просмотреть файл

@ -13,6 +13,7 @@
// limitations under the License.
using System.IO;
using Steeltoe.Tooling.Models;
namespace Steeltoe.Tooling
{

Просмотреть файл

@ -12,17 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
using Microsoft.Extensions.Logging;
namespace Steeltoe.Tooling.Executors
namespace Steeltoe.Tooling.Controllers
{
/// <summary>
/// Represents a Steeltoe Tooling workflow.
/// </summary>
public abstract class Executor
public abstract class Controller
{
private static readonly ILogger Logger = Logging.LoggerFactory.CreateLogger<Executor>();
/// <summary>
/// The context in which the workflow executes.
/// </summary>
@ -35,8 +31,6 @@ namespace Steeltoe.Tooling.Executors
/// <exception cref="ToolingException">If an error occurs running the workflow.</exception>
public void Execute(Context context)
{
var type = GetType();
Logger.LogDebug($"executor is {type}");
Context = context;
Execute();
}

Просмотреть файл

@ -1,23 +0,0 @@
// Copyright 2018 the original author or authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Steeltoe.Tooling.Drivers.CloudFoundry
{
internal class CloudFoundryCli : Cli
{
internal CloudFoundryCli(Shell shell) : base("cf", shell)
{
}
}
}

Просмотреть файл

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling.Templaters;
namespace Steeltoe.Tooling.Drivers.CloudFoundry
{

Просмотреть файл

@ -1,70 +0,0 @@
// Copyright 2018 the original author or authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Collections.Generic;
using System.IO;
using System.Threading;
using YamlDotNet.Serialization;
namespace Steeltoe.Tooling.Drivers.Dummy
{
internal class DummyServiceDatabase
{
public List<string> Apps { get; set; } = new List<string>();
public SortedDictionary<string, Lifecycle.Status> Services { get; set; } =
new SortedDictionary<string, Lifecycle.Status>();
internal static void Store(string path, DummyServiceDatabase database)
{
var serializer = new SerializerBuilder().Build();
var yaml = serializer.Serialize(database);
using (var fOut = GetFileStream(path, FileMode.Create, FileAccess.Write))
{
using (var writer = new StreamWriter(fOut))
{
writer.Write(yaml);
}
}
}
internal static DummyServiceDatabase Load(string path)
{
var deserializer = new DeserializerBuilder().Build();
using (var fIn = GetFileStream(path, FileMode.OpenOrCreate, FileAccess.Read))
{
using (var reader = new StreamReader(fIn))
{
return deserializer.Deserialize<DummyServiceDatabase>(reader) ??
new DummyServiceDatabase();
}
}
}
private static FileStream GetFileStream(string path, FileMode mode, FileAccess access)
{
while (true)
{
try
{
return new FileStream(path, mode, access, FileShare.None);
}
catch (IOException)
{
Thread.Sleep(100);
}
}
}
}
}

Просмотреть файл

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling.Templaters;
namespace Steeltoe.Tooling.Drivers.Kubernetes
{

Просмотреть файл

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling.Templaters;
namespace Steeltoe.Tooling.Drivers.Kubernetes
{

Просмотреть файл

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Steeltoe.Tooling.Templaters;
namespace Steeltoe.Tooling.Drivers.Kubernetes
{

Просмотреть файл

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// An application that can be deployed.
@ -25,7 +25,7 @@ namespace Steeltoe.Tooling
public string App { get; }
/// <summary>
/// Creates a new AppInfo for the specified applicaition.
/// Creates a new AppInfo for the specified application.
/// </summary>
/// <param name="app">Application name.</param>
public AppInfo(string app)

Просмотреть файл

@ -17,7 +17,7 @@ using System.Linq;
using Microsoft.Extensions.Logging;
using YamlDotNet.Serialization;
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// Represents a configuration for a Steeltoe Tooling project.

Просмотреть файл

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// Defines the interface to receive alerts that the Steeltoe Tooling project configuration has changed.

Просмотреть файл

@ -21,7 +21,7 @@ using YamlDotNet.Serialization;
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// Represents a Steeltoe Tooling projects available application service types and deployment targets.

Просмотреть файл

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// An application service, such as a database, that can be deployed.

Просмотреть файл

@ -14,7 +14,7 @@
using YamlDotNet.Serialization;
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// Specifies a service.

Просмотреть файл

@ -15,10 +15,10 @@
using System.Collections.Generic;
using YamlDotNet.Serialization;
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Models
{
/// <summary>
/// Rerpresents the configuration of a deployment target.
/// Represents the configuration of a deployment target.
/// </summary>
public class TargetConfiguration
{

Просмотреть файл

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Steeltoe.Tooling.Models;
namespace Steeltoe.Tooling.Scanners
{

Просмотреть файл

@ -26,6 +26,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Drivers" />
<Folder Include="Templates" />
<Folder Include="Drivers\Dummy" />
</ItemGroup>
</Project>

Просмотреть файл

@ -3,7 +3,7 @@ using System.IO;
using System.Reflection;
using Antlr4.StringTemplate;
namespace Steeltoe.Tooling
namespace Steeltoe.Tooling.Templaters
{
/// <summary>
/// Acts as a facade for template implementations.

Просмотреть файл

@ -23,12 +23,12 @@ namespace Steeltoe.Cli.Test
public void ListTemplatesHelp()
{
Runner.RunScenario(
given => a_dotnet_project("list_dependencies_help"),
when => the_developer_runs_cli_command("list-deps --help"),
given => a_dotnet_project("list_templates_help"),
when => the_developer_runs_cli_command("list-templates --help"),
then => the_cli_should_output(new[]
{
"Displays a list of available dependencies",
$"Usage: {Program.Name} list-deps [options]",
"Displays a list of available templates",
$"Usage: {Program.Name} list-templates [options]",
"Options:",
"-?|-h|--help Show help information",
"Overview:",
@ -41,8 +41,8 @@ namespace Steeltoe.Cli.Test
public void ListTemplatesTooManyArgs()
{
Runner.RunScenario(
given => a_dotnet_project("list_dependencies_too_many_args"),
when => the_developer_runs_cli_command("list-deps arg1"),
given => a_dotnet_project("list_templates_too_many_args"),
when => the_developer_runs_cli_command("list-templates arg1"),
then => the_cli_should_fail_parse("Unrecognized command or argument 'arg1'")
);
}

Просмотреть файл

@ -13,6 +13,7 @@
// limitations under the License.
using Shouldly;
using Steeltoe.Tooling.Models;
using Xunit;
namespace Steeltoe.Tooling.Test

Просмотреть файл

@ -13,9 +13,10 @@
// limitations under the License.
using Shouldly;
using Steeltoe.Tooling.Models;
using Xunit;
namespace Steeltoe.Tooling.Test
namespace Steeltoe.Tooling.Test.Models
{
public class ConfigurationTest : ToolingTest
{

Просмотреть файл

@ -13,6 +13,7 @@
// limitations under the License.
using Shouldly;
using Steeltoe.Tooling.Models;
using Xunit;
namespace Steeltoe.Tooling.Test

Просмотреть файл

@ -14,9 +14,10 @@
using System.Collections.Generic;
using Shouldly;
using Steeltoe.Tooling.Models;
using Xunit;
namespace Steeltoe.Tooling.Test
namespace Steeltoe.Tooling.Test.Models
{
public class RegistryTest : ToolingTest
{

Просмотреть файл

@ -15,6 +15,7 @@
using System;
using System.IO;
using System.Linq;
using Steeltoe.Tooling.Models;
namespace Steeltoe.Tooling.Test
{