Skip to content

Commit

Permalink
Removed command line option --language & styling/cleanup (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dor authored Jun 27, 2019
1 parent a9c2616 commit 527ad3b
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 110 deletions.
16 changes: 8 additions & 8 deletions build/testIntegration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source $REPO_DIR/build/__variables.sh

# When this script is run in CI agent these environment variables are already set
if [ -z "$SQLSERVER_DATABASE_HOST" ]; then
function getValueFromKeyVault() {
function getSecretFromKeyVault() {
local secretName="$1"
result=`az.cmd keyvault secret show \
--name "$secretName" \
Expand All @@ -23,11 +23,11 @@ if [ -z "$SQLSERVER_DATABASE_HOST" ]; then
}

echo
echo Retreiving values from keyvault...
export SQLSERVER_DATABASE_HOST=$(getValueFromKeyVault "SQLSERVER-DATABASE-HOST")
export SQLSERVER_DATABASE_NAME=$(getValueFromKeyVault "SQLSERVER-DATABASE-NAME")
export SQLSERVER_DATABASE_USERNAME=$(getValueFromKeyVault "SQLSERVER-DATABASE-USERNAME")
export SQLSERVER_DATABASE_PASSWORD=$(getValueFromKeyVault "SQLSERVER-DATABASE-PASSWORD")
echo Retrieving secrets from Azure Key Vault...
export SQLSERVER_DATABASE_HOST=$(getSecretFromKeyVault "SQLSERVER-DATABASE-HOST")
export SQLSERVER_DATABASE_NAME=$(getSecretFromKeyVault "SQLSERVER-DATABASE-NAME")
export SQLSERVER_DATABASE_USERNAME=$(getSecretFromKeyVault "SQLSERVER-DATABASE-USERNAME")
export SQLSERVER_DATABASE_PASSWORD=$(getSecretFromKeyVault "SQLSERVER-DATABASE-PASSWORD")
fi

echo
Expand All @@ -48,8 +48,8 @@ testProjectName="Oryx.Integration"
cd "$TESTS_SRC_DIR/$testProjectName.Tests"

# These two images are used in Buildpacks-related integration tests
docker pull heroku/buildpacks:18
docker pull heroku/pack:18
docker pull "heroku/buildpacks:18"
docker pull "heroku/pack:18"

dotnet test \
$testCaseFilter \
Expand Down
2 changes: 1 addition & 1 deletion images/pack-builder/oryx-buildpack/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ firstPlatform=${firstPlatform%]} # Remove ]
echo "# Running 'oryx buildpack-build .' in '`pwd`'..."
oryx buildpack-build .

echo "# Running 'oryx run-script' in '`pwd`'..."
echo "# Running 'oryx run-script --platform $firstPlatform --output $runFile' in '`pwd`'..."
oryx run-script --platform $firstPlatform --output $runFile
chmod +x $runFile

Expand Down
2 changes: 1 addition & 1 deletion src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Import Project="$(MSBuildThisFileDirectory)\..\CommonFiles\AssemblyVersion.proj" />

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
Expand Down
4 changes: 2 additions & 2 deletions src/BuildScriptGeneratorCli/Commands/OptionTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
internal static class OptionTemplates
{
public const string Platform = "--platform <name>|-l|--language <name>";
public const string PlatformVersion = "--platform-version <version>|--language-version <version>";
public const string Platform = "-l|--platform <name>";
public const string PlatformVersion = "--language-version <version>";
public const string Property = "-p|--property <key-value>";
}
}
21 changes: 7 additions & 14 deletions src/BuildScriptGeneratorCli/Commands/RunScriptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@

namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
[Command(Name, Description = "Generate startup script.",
[Command(Name, Description = "Generate startup script for an app.",
ThrowOnUnexpectedArgument = false, AllowArgumentSeparator = true)]
internal class RunScriptCommand : CommandBase
{
public const string Name = "run-script";

[Argument(0, Description = "The application directory.")]
[DirectoryExists]
public string AppDir { get; set; } = ".";

[Option(
OptionTemplates.Platform,
CommandOptionType.SingleValue,
Description = "The name of the programming platform, e.g. 'nodejs'.",
ValueName = "Platform name")]
Description = "The name of the programming platform, e.g. 'nodejs'.")]
public string PlatformName { get; set; }

[Option(
OptionTemplates.PlatformVersion,
CommandOptionType.SingleValue,
Description = "The version of the platform to run the application on, e.g. '10' for nodejs.",
ValueName = "PlatformVersion")]
Description = "The version of the platform to run the application on, e.g. '10' for nodejs.")]
public string PlatformVersion { get; set; }

[Option(
Expand All @@ -46,12 +45,6 @@ internal class RunScriptCommand : CommandBase

internal override int Execute(IServiceProvider serviceProvider, IConsole console)
{
if (string.IsNullOrWhiteSpace(PlatformName))
{
console.WriteErrorLine("Platform name is required.");
return ProcessConstants.ExitFailure;
}

string appPath = Path.GetFullPath(AppDir);
ILoggerFactory loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var sourceRepo = new LocalSourceRepo(appPath, loggerFactory);
Expand All @@ -60,7 +53,7 @@ internal override int Execute(IServiceProvider serviceProvider, IConsole console
{
SourceRepo = sourceRepo,
PlatformVersion = PlatformVersion,
PassThruArguments = RemainingArgs
PassThruArguments = RemainingArgs,
};

var runScriptGenerator = serviceProvider.GetRequiredService<IRunScriptGenerator>();
Expand Down Expand Up @@ -89,9 +82,9 @@ internal override int Execute(IServiceProvider serviceProvider, IConsole console

internal override bool IsValidInput(IServiceProvider serviceProvider, IConsole console)
{
if (!Directory.Exists(AppDir))
if (string.IsNullOrWhiteSpace(PlatformName))
{
console.WriteErrorLine($"Could not find the directory '{AppDir}'.");
console.WriteErrorLine("Platform name is required.");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/BuildScriptGeneratorCli.Tests/TestConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public string StdError

public bool IsInputRedirected => throw new NotImplementedException();

public bool IsOutputRedirected => throw new NotImplementedException();
public bool IsOutputRedirected => true;

public bool IsErrorRedirected => throw new NotImplementedException();
public bool IsErrorRedirected => true;

public ConsoleColor ForegroundColor
{
Expand Down
14 changes: 7 additions & 7 deletions tests/Oryx.BuildImage.Tests/DotNetCoreSampleAppsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public void Build_ExecutesPreAndPostBuildScripts_WithinBenvContext()

var appDir = volume.ContainerDir;
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -l dotnet --language-version 2.1")
.AddBuildCommand($"{appDir} --platform dotnet --language-version 2.1")
.ToString();

// Act
Expand Down Expand Up @@ -445,7 +445,7 @@ public void Build_CopiesContentCreatedByPreAndPostBuildScript_ToExplicitOutputDi
var appDir = volume.ContainerDir;
var tempOutputDir = "/tmp/output";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {tempOutputDir} -l dotnet --language-version 2.1")
.AddBuildCommand($"{appDir} -o {tempOutputDir} --platform dotnet --language-version 2.1")
.AddFileExistsCheck($"{tempOutputDir}/pre-{fileName}")
.AddFileExistsCheck($"{tempOutputDir}/post-{fileName}")
.ToString();
Expand Down Expand Up @@ -507,7 +507,7 @@ public void Build_CopiesContentCreatedByPreAndPostBuildScript_ToImplicitOutputDi
var appDir = volume.ContainerDir;
var outputDir = $"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -l dotnet --language-version 2.1")
.AddBuildCommand($"{appDir} --platform dotnet --language-version 2.1")
.AddFileExistsCheck($"{outputDir}/pre-{fileName}")
.AddFileExistsCheck($"{outputDir}/post-{fileName}")
.ToString();
Expand Down Expand Up @@ -547,7 +547,7 @@ public void Build_Executes_InlinePreAndPostBuildCommands()
var appDir = volume.ContainerDir;
var tempOutputDir = "/tmp/output";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {tempOutputDir} -l dotnet --language-version 2.1")
.AddBuildCommand($"{appDir} -o {tempOutputDir} --platform dotnet --language-version 2.1")
.ToString();

// Act
Expand Down Expand Up @@ -603,7 +603,7 @@ public void Build_CopiesContentCreatedByPostBuildScript_ToExplicitOutputDirector
var tempOutputDir = "/tmp/output";
var script = new ShellScriptBuilder()
.AddBuildCommand(
$"{appDir} -o {tempOutputDir} -l dotnet --language-version 2.1 " +
$"{appDir} -o {tempOutputDir} --platform dotnet --language-version 2.1 " +
$"-p {ScriptGenerator.Constants.ZipAllOutputBuildPropertyKey}=true")
.AddFileDoesNotExistCheck($"{tempOutputDir}/post-{fileName}")
.AddCommand($"cd {tempOutputDir} && tar -xvf {FilePaths.CompressedOutputFileName}")
Expand Down Expand Up @@ -661,7 +661,7 @@ public void Build_CopiesContentCreatedByPostBuildScript_ToImplicitOutputDirector
var outputDir = $"{appDir}/{DotNetCoreConstants.OryxOutputPublishDirectory}";
var script = new ShellScriptBuilder()
.AddBuildCommand(
$"{appDir} -l dotnet --language-version 2.1 " +
$"{appDir} --platform dotnet --language-version 2.1 " +
$"-p {ScriptGenerator.Constants.ZipAllOutputBuildPropertyKey}=true")
.AddFileDoesNotExistCheck($"{outputDir}/post-{fileName}")
.AddCommand($"cd {outputDir} && tar -xvf {FilePaths.CompressedOutputFileName}")
Expand Down Expand Up @@ -698,7 +698,7 @@ public void MultiPlatformBuild_IsDisabled()
var appOutputDir = $"{appDir}/myoutputdir";
var buildScript = new ShellScriptBuilder()
.AddCommand("export ENABLE_MULTIPLATFORM_BUILD=true")
.AddBuildCommand($"{appDir} -o {appOutputDir} -l dotnet --language-version 2.2")
.AddBuildCommand($"{appDir} -o {appOutputDir} --platform dotnet --language-version 2.2")
.ToString();

// Act
Expand Down
12 changes: 6 additions & 6 deletions tests/Oryx.BuildImage.Tests/NodeJSSampleAppsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public void GeneratesScript_AndBuilds_WhenExplicitLanguageAndVersion_AreProvided
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/webfrontend-output";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir} -l nodejs --language-version 8.2.1")
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir} --platform nodejs --language-version 8.2.1")
.AddDirectoryExistsCheck($"{appOutputDir}/node_modules")
.ToString();

Expand Down Expand Up @@ -412,7 +412,7 @@ public void CanBuild_UsingScriptGeneratedBy_ScriptOnlyOption_AndWhenExplicitLang
var generatedScript = "/tmp/build.sh";
var tempDir = "/tmp/" + Guid.NewGuid();
var script = new ShellScriptBuilder()
.AddScriptCommand($"{appDir} -l nodejs --language-version 8.2.1 > {generatedScript}")
.AddScriptCommand($"{appDir} --platform nodejs --language-version 8.2.1 > {generatedScript}")
.SetExecutePermissionOnFile(generatedScript)
.CreateDirectory(tempDir)
.AddCommand($"{generatedScript} {appDir} {appOutputDir} {tempDir}")
Expand Down Expand Up @@ -564,7 +564,7 @@ public void Build_ExecutesPreAndPostBuildScripts_WithinBenvContext()

var appDir = volume.ContainerDir;
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -l nodejs --language-version 6")
.AddBuildCommand($"{appDir} --platform nodejs --language-version 6")
.ToString();

// Act
Expand Down Expand Up @@ -708,7 +708,7 @@ public void BuildNodeApp_ConfigureAppInsights_WithCorrectNodeVersion_AIEnvironme
// Arrange
var volume = CreateWebFrontEndVolume();
var appDir = volume.ContainerDir;
var spcifyNodeVersionCommand = "-l nodejs --language-version=" + version;
var spcifyNodeVersionCommand = "--platform nodejs --language-version=" + version;
var nestedOutputDir = "/tmp/output";
var script = new ShellScriptBuilder()
.AddCommand(
Expand Down Expand Up @@ -760,7 +760,7 @@ public void BuildNodeApp_DoesNotConfigureAppInsights_WithWrongNodeVersion_AIEnvi
var volume = CreateWebFrontEndVolume();
var appDir = volume.ContainerDir;
var nestedOutputDir = "/tmp/output";
var spcifyNodeVersionCommand = "-l nodejs --language-version=" + version;
var spcifyNodeVersionCommand = "--platform nodejs --language-version=" + version;
var script = new ShellScriptBuilder()
.AddCommand(
$"oryx build {appDir} -o {nestedOutputDir} {spcifyNodeVersionCommand} --log-file {appDir}/1.log")
Expand Down Expand Up @@ -810,7 +810,7 @@ public void BuildNodeApp_DoesNotConfigureAppInsights_WithCorrectNodeVersion_AIEn
var volume = CreateWebFrontEndVolume();
var appDir = volume.ContainerDir;
var nestedOutputDir = "/tmp/output";
var spcifyNodeVersionCommand = "-l nodejs --language-version=" + version;
var spcifyNodeVersionCommand = "--platform nodejs --language-version=" + version;
var script = new ShellScriptBuilder()
.AddCommand(
$"oryx build {appDir} -o {nestedOutputDir} {spcifyNodeVersionCommand} --log-file {appDir}/1.log")
Expand Down
2 changes: 1 addition & 1 deletion tests/Oryx.BuildImage.Tests/PhpSampleAppsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void GeneratesScript_AndBuilds_WithoutComposerFile()
var appDir = volume.ContainerDir;
var script = new ShellScriptBuilder()
.AddCommand($"rm {appDir}/composer.json")
.AddBuildCommand($"{appDir} --language php --language-version {PhpVersions.Php73Version}")
.AddBuildCommand($"{appDir} --platform php --language-version {PhpVersions.Php73Version}")
.ToString();

// Act
Expand Down
Loading

0 comments on commit 527ad3b

Please sign in to comment.