Skip to content

Commit

Permalink
Fix templates for service in #60 , and tone down verbosity - will int…
Browse files Browse the repository at this point in the history
…roduce a verbosity command to allow showing all input
  • Loading branch information
prom3theu5 committed Dec 1, 2023
1 parent a4d6aa4 commit 8b1121f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public class DockerfileTemplateData(
public bool IsDockerfile { get; set; } = true;
public List<Ports> Ports { get; set; } = ports;
public bool HasPorts => Ports.Any();

public string ServiceType { get; set; } = "ClusterIP";
}
1 change: 1 addition & 0 deletions src/Aspirate.Cli/Processors/Project/ProjectTemplateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class ProjectTemplateData(
{
public string ContainerImage { get; set; } = containerImage;
public bool IsProject { get; set; } = true;
public string ServiceType { get; set; } = "ClusterIP";
}
6 changes: 3 additions & 3 deletions src/Aspirate.Cli/Services/ContainerCompositionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<bool> BuildAndPushContainerForProject(
await AddProjectPublishArguments(argumentsBuilder, fullProjectPath);
AddContainerDetailsToArguments(argumentsBuilder, containerDetails);

await shellExecutionService.ExecuteCommand(DotNetSdkLiterals.DotNetCommand, argumentsBuilder, nonInteractive, onFailed: HandleBuildErrors );
await shellExecutionService.ExecuteCommand(DotNetSdkLiterals.DotNetCommand, argumentsBuilder, nonInteractive, onFailed: HandleBuildErrors, showOutput: true);

return true;
}
Expand All @@ -36,13 +36,13 @@ public async Task<bool> BuildAndPushContainerForDockerfile(Dockerfile dockerfile
.AppendArgument(DockerLiterals.DockerFileArgument, fullDockerfilePath)
.AppendArgument(dockerfile.Context, string.Empty, quoteValue: false);

await shellExecutionService.ExecuteCommand(builder, argumentsBuilder, nonInteractive);
await shellExecutionService.ExecuteCommand(builder, argumentsBuilder, nonInteractive, showOutput: true);

argumentsBuilder.Clear()
.AppendArgument(DockerLiterals.PushCommand, string.Empty, quoteValue: false)
.AppendArgument(tag, string.Empty, quoteValue: false);

await shellExecutionService.ExecuteCommand(builder, argumentsBuilder, nonInteractive);
await shellExecutionService.ExecuteCommand(builder, argumentsBuilder, nonInteractive, showOutput: true);

return true;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Aspirate.Cli/Services/KubeCtlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public async Task<bool> ApplyManifests(string context, string outputFolder)
_ = await shellExecutionService.ExecuteCommand(
KubeCtlLiterals.KubeCtlCommand, argumentsBuilder,
preCommandMessage: $"[cyan]Executing: [green]{KubeCtlLiterals.KubeCtlCommand} {argumentsBuilder.RenderArguments()}[/] against kubernetes context [blue]{context}.[/][/]",
failureCommandMessage: $"[red]Failed to deploy manifests in [blue]'{fullOutputPath}'[/][/]");
failureCommandMessage: $"[red]Failed to deploy manifests in [blue]'{fullOutputPath}'[/][/]",
showOutput: true);

return true;
}
Expand All @@ -56,7 +57,8 @@ public async Task<bool> RemoveManifests(string context, string outputFolder)
_ = await shellExecutionService.ExecuteCommand(
KubeCtlLiterals.KubeCtlCommand, argumentsBuilder,
preCommandMessage: $"[cyan]Executing: [green]{KubeCtlLiterals.KubeCtlCommand} {argumentsBuilder.RenderArguments()}[/] against kubernetes context [blue]{context}.[/][/]",
failureCommandMessage: $"[red]Failed to remove manifests in [blue]'{fullOutputPath}'[/][/]");
failureCommandMessage: $"[red]Failed to remove manifests in [blue]'{fullOutputPath}'[/][/]",
showOutput: true);

return true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Aspirate.Cli/Services/ProjectPropertyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public sealed class ProjectPropertyService(IFileSystem filesystem, IShellExecuti
DotNetSdkLiterals.DotNetCommand,
argumentsBuilder,
workingDirectory: workingDirectory,
propertyKeySeparator: ':',
showOutput: true);
propertyKeySeparator: ':');


return result.Success ? result.Output : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Aspirate.Cli/Services/ShellExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public async Task<ShellCommandResult> ExecuteCommand(string command,
ArgumentsBuilder argumentsBuilder,
bool nonInteractive = false,
Func<string, ArgumentsBuilder, bool, string, Task>? onFailed = default,
bool? showOutput = true,
bool? showOutput = false,
string? workingDirectory = null,
char? propertyKeySeparator = null,
string? preCommandMessage = null,
Expand Down
16 changes: 8 additions & 8 deletions src/Aspirate.Cli/Templates/service.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ spec:
type: {{serviceType}}
selector:
app: {{name}}
ports:
- name: http
port: 8080
targetPort: 8080
ports:
- name: http
port: 8080
targetPort: 8080
{{/if}}
{{#if isDockerfile}}
Expand All @@ -25,11 +25,11 @@ spec:
type: {{serviceType}}
selector:
app: {{name}}
ports:
ports:
{{#each ports}}
- name: {{name}}
port: {{port}}
targetPort: {{port}}
- name: {{name}}
port: {{port}}
targetPort: {{port}}
{{/each}}
{{/if}}
{{/if}}
2 changes: 1 addition & 1 deletion src/Aspirate.Shared/Services/IShellExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public interface IShellExecutionService
{
Task<ShellCommandResult> ExecuteCommand(string command, ArgumentsBuilder argumentsBuilder, bool nonInteractive = false,
Func<string, ArgumentsBuilder, bool, string, Task>? onFailed = default,
bool? showOutput = true,
bool? showOutput = false,
string? workingDirectory = null,
char? propertyKeySeparator = null,
string? preCommandMessage = null,
Expand Down

0 comments on commit 8b1121f

Please sign in to comment.