Skip to content

Commit

Permalink
fix: Adjust providers endpoint (#12154)
Browse files Browse the repository at this point in the history
* fix: Fiormatting

* feat: Remove Dashboard onboarding from framework (#12151)

* fix: Providers test

---------

Co-authored-by: Max Marze <max@marze.dev>
  • Loading branch information
austencollins and Mmarzex committed Sep 15, 2023
1 parent 590bb7e commit 9b770a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
22 changes: 12 additions & 10 deletions lib/cli/interactive-setup/aws-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ const steps = {
},
handleProviderCreation: async ({ configuration: { org: orgName }, stepHistory }) => {
const providersUrl = `${dashboardFrontend}/${orgName}/settings/providers?source=cli&providerId=new&provider=aws`;

openBrowser(providersUrl);

log.notice('To learn more about providers, visit: http://slss.io/add-providers-dashboard');

const providerProgress = progress.get('provider');
Expand Down Expand Up @@ -227,26 +229,26 @@ const steps = {
});
}, timeoutDuration);

onEvent = (event) => {
onEvent = (provider) => {
if (inquirerPrompt) {
// Disable inquirer prompt asking to skip without setting provider
inquirerPrompt.ui.close();
}

clearTimeout(showSkipPromptTimeout);
resolve(event);
resolve(provider);
};
});

// Get orgUid
const orgUid = await getOrgUidByName(orgName);

// Listen for `provider.created` event to detect creation of new provider
const sdk = await getSdkInstance(orgName);
try {
await sdk.connect({
orgName,
orgUid,
onEvent,
filter: {
events: ['provider.created'],
},
});
} catch (err) {
// Ensure that prompt timeout is cleared in case of error
Expand All @@ -261,19 +263,19 @@ const steps = {
throw err;
}

let maybeEvent;
let provider;
try {
maybeEvent = await p;
provider = await p;
} finally {
sdk.disconnect();
}

providerProgress.remove();

log.notice();
if (maybeEvent) {
if (provider) {
log.notice.success('AWS Access Role provider was successfully created');
return maybeEvent.data.object.provider_uid;
return provider.providerUid;
}

log.notice.skip(
Expand Down
8 changes: 1 addition & 7 deletions test/unit/lib/cli/interactive-setup/aws-credentials.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,7 @@ describe('test/unit/lib/cli/interactive-setup/aws-credentials.test.js', () => {
const internalMockedSdk = {
...mockedSdk,
connect: ({ onEvent }) => {
onEvent({
data: {
object: {
provider_uid: providerUid,
},
},
});
onEvent({ providerUid });
},
getProviders: async () => {
return {
Expand Down

0 comments on commit 9b770a2

Please sign in to comment.