Skip to content

Commit

Permalink
Merge pull request #234 from code-like-a-carpenter/fix-stack-detection
Browse files Browse the repository at this point in the history
fix stack detection
  • Loading branch information
ianwremmel authored Feb 13, 2024
2 parents fe2b538 + e7674d5 commit 8901f70
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/@code-like-a-carpenter/tool-stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"glob": "^10.3.10",
"http-proxy": "^1.18.1",
"lodash.snakecase": "^4.1.1",
"undici": "^6.6.2",
"vhost": "^3.0.2"
},
"devDependencies": {
Expand Down
12 changes: 11 additions & 1 deletion packages/@code-like-a-carpenter/tool-stack/src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from 'express';
import type Server from 'http-proxy';
import httpProxy from 'http-proxy';
import {Agent, fetch} from 'undici';
import vhost from 'vhost';

import {assert} from '@code-like-a-carpenter/assert';
Expand Down Expand Up @@ -84,7 +85,16 @@ export async function startAllProxies({
stackNames.map(async (stackName) => {
try {
const result = await fetch(
`http://${stackName}.localhost:${port}/api/v1/ping`
`http://${stackName}.localhost:${port}/api/v1/ping`,
{
dispatcher: new Agent({
connect: {
lookup: (hostname, options, callback) => {
callback(null, [{address: '127.0.0.1', family: 4}]);
},
},
}),
}
);
if (!result.ok) {
const error = new Error(`Stack ${stackName} is not available`);
Expand Down
3 changes: 2 additions & 1 deletion packages/@code-like-a-carpenter/tool-stack/src/stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export async function findEndpoints(
}

async function getStackUrl(stackName: string): Promise<string> {
if (!process.env.CI) {
// If we aleady have an AWS_SECRET_ACCESS_KEY, don't try to to use autoloading
if (!process.env.CI && !process.env.AWS_SECRET_ACCESS_KEY) {
process.env.AWS_REGION = process.env.AWS_REGION ?? 'us-east-1';
process.env.AWS_PROFILE = process.env.AWS_PROFILE ?? 'webstorm_playground';
process.env.AWS_SDK_LOAD_CONFIG = process.env.AWS_SDK_LOAD_CONFIG ?? '1';
Expand Down

0 comments on commit 8901f70

Please sign in to comment.