Skip to content

Commit

Permalink
Few fixes, removed API key
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Aug 16, 2017
1 parent d558e2d commit f9059dc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions AWS/DeployCloudFormation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion AWS/UserData.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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%%"
curl https://droyad.gq/api/machines --header "X-Octopus-ApiKey:%%apiKey%%" --data "%%registerRequest%%"
4 changes: 2 additions & 2 deletions IntegrationTests/DeployProjects.csx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/RunTests.csx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}");
Expand Down

0 comments on commit f9059dc

Please sign in to comment.