From f9059dc41bc2cad67c540ea31369e2678826f2a6 Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Wed, 16 Aug 2017 16:25:45 +1000 Subject: [PATCH] Few fixes, removed API key --- AWS/DeployCloudFormation.ps1 | 6 ++++++ AWS/UserData.sh | 2 +- IntegrationTests/DeployProjects.csx | 4 ++-- IntegrationTests/RunTests.csx | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/AWS/DeployCloudFormation.ps1 b/AWS/DeployCloudFormation.ps1 index 3c7a0e3..2c96a4d 100644 --- a/AWS/DeployCloudFormation.ps1 +++ b/AWS/DeployCloudFormation.ps1 @@ -16,6 +16,11 @@ if (-not $env:AWS_ACCESS_KEY_ID) { if (-not $env:AWS_SECRET_ACCESS_KEY) { $env:AWS_SECRET_ACCESS_KEY = $OctopusParameters["AWS_SECRET_ACCESS_KEY"] } +if ($env:OctopusApiKey) { + $apiKey = $env:OctopusApiKey +} else { + $apiKey = $OctopusParameters["ApiKey"] +} $registerRequest = Get-Content ".\Register.json" | ConvertFrom-Json $formation = Get-Content ".\CloudFormation.json" | ConvertFrom-Json @@ -36,6 +41,7 @@ function GetUserData($roles) { $registerRequestJson = $registerRequestJson.Replace('"', '\"') $userData = [String]::Join("`n", (Get-Content ".\UserData.sh")) $userData = $userData.Replace("%%registerRequest%%", $registerRequestJson) + $userData = $userData.Replace("%%apiKey%%", $apiKey) return [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($userData)) } $formation.Resources.AppServerInstance.Properties.UserData = GetUserData(@("App")) diff --git a/AWS/UserData.sh b/AWS/UserData.sh index d84a891..b724a5f 100644 --- a/AWS/UserData.sh +++ b/AWS/UserData.sh @@ -3,4 +3,4 @@ hostname=`curl http://169.254.169.254/latest/meta-data/public-hostname` instanceid=`curl http://169.254.169.254/latest/meta-data/instance-id` thumbprint=`ssh-keygen -E md5 -lf /etc/ssh/ssh_host_rsa_key.pub | grep -P -o "(?<=MD5:)[0-9a-f]+:[^ ]*"` -curl https://droyad.gq/api/machines --header "X-Octopus-ApiKey:API-WNKDGUJOY857GW3A0ID7WQHC0" --data "%%registerRequest%%" \ No newline at end of file +curl https://droyad.gq/api/machines --header "X-Octopus-ApiKey:%%apiKey%%" --data "%%registerRequest%%" \ No newline at end of file diff --git a/IntegrationTests/DeployProjects.csx b/IntegrationTests/DeployProjects.csx index c373f3e..a97c891 100644 --- a/IntegrationTests/DeployProjects.csx +++ b/IntegrationTests/DeployProjects.csx @@ -55,7 +55,7 @@ ReleaseResource GetReleaseToDeploy(ProjectResource project) return null; } -void CreateRelease(ProjectResource project, ReleaseResource release) +void CreateDeployment(ProjectResource project, ReleaseResource release) { Console.WriteLine($"Deploying {project.Name} {release.Version}"); repository.Deployments.Create(new DeploymentResource() @@ -74,7 +74,7 @@ foreach (var project in projects) if (release == null) Console.WriteLine("Could not find a suitable release for " + project.Name); else - CreateRelease(project, release); + CreateDeployment(project, release); } // Wait for projects diff --git a/IntegrationTests/RunTests.csx b/IntegrationTests/RunTests.csx index 71f1cb8..a862a57 100644 --- a/IntegrationTests/RunTests.csx +++ b/IntegrationTests/RunTests.csx @@ -9,6 +9,7 @@ using System.Threading; var apiKey = Octopus.Parameters["ApiKey"]; var tenantId = Octopus.Parameters["Octopus.Deployment.Tenant.Id"]; +var testTimeout = int.Parse(Octopus.Parameters["TestTimeout"]); var endpoint = new OctopusServerEndpoint("https://droyad.gq", apiKey); var repository = new OctopusRepository(endpoint); @@ -25,7 +26,7 @@ var sw = Stopwatch.StartNew(); void TestEndpoint(SshEndpointResource ssh) { var url = $"http://{ssh.Host}:7000/20/50"; - while (sw.Elapsed < TimeSpan.FromMinutes(1)) + while (sw.Elapsed < TimeSpan.FromSeconds(testTimeout)) try { Console.WriteLine($"Requesting {url}");