Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust providers endpoint #12154

Merged
merged 3 commits into from Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/cli/interactive-setup/aws-credentials.js
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
18 changes: 0 additions & 18 deletions lib/plugins/deploy.js
Expand Up @@ -3,13 +3,11 @@
const ServerlessError = require('../serverless-error');
const cliCommandsSchema = require('../cli/commands-schema');
const { awsRequest } = require('./../cli/interactive-setup/utils');
const dashboardService = require('../utils/serverless-dashboard');

class Deploy {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options || {};
this.dashboard = dashboardService(serverless, options);
this.commands = {
deploy: {
...cliCommandsSchema.get('deploy'),
Expand Down Expand Up @@ -49,24 +47,8 @@ class Deploy {
if (!this.options.package && !this.serverless.service.package.path) {
await this.serverless.pluginManager.spawn('package');
}

if (
this.serverless.configurationInput &&
this.serverless.configurationInput.org &&
this.serverless.configurationInput.app
) {
await this.dashboard.configureIntegrationContext();
await this.dashboard.ensureIntegrationIsConfigured();
}
},
'after:deploy:deploy': async () => {
if (
this.serverless.configurationInput &&
this.serverless.configurationInput.org &&
this.serverless.configurationInput.app
) {
await this.dashboard.instrumentService();
}
return true;
},
};
Expand Down