Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Conversation

dennisseah
Copy link
Collaborator

In the event that there are more than one subscription, user needs to select one of them. Display names shall be displayed as choices.

the subscription id value will be written to spk config.yaml file

closes microsoft/bedrock#1138

*/
export const getSubscriptions = (
rc: IRequestContext
): Promise<ISubscriptionItem[]> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using async since the entire code base using it? Promise is used in few places due to SDK dependency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you show me how you want the code to be written? async keyword is needed when we have await in the function; and wrapping the entire function as a Promise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is already returning promise which means you are using asynchronous or blocking code in the function. async functions use an implicit Promise to return results anyway. Keeping code consistent would be good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my point is we do not add async unnecessary and it is not encourage. it is not about consistency.
Sorry I do not get your point on why you want to add async?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can write the function in the manner but not simply adding an async keyword.

export const getSubscriptions = async (
  rc: IRequestContext
): Promise<ISubscriptionItem[]> => {
  logger.info("attempting to get subscription list");
  const creds = await loginWithServicePrincipalSecret(
    rc.servicePrincipalId!,
    rc.servicePrincipalPassword!,
    rc.servicePrincipalTenantId!
  );
  const client = new SubscriptionClient(creds);
  const subsciptions = await client.subscriptions.list();
  const result = (subsciptions || []).map(s => {
    return {
      id: s.subscriptionId!,
      name: s.displayName!
    };
  });
  logger.info("Successfully acquired subscription list");
  return result;
};

Copy link
Collaborator

@andrebriggs andrebriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good overall. Pending the comments from others

@dennisseah dennisseah requested a review from sarath-p March 11, 2020 20:13
@dennisseah dennisseah merged commit 725d409 into master Mar 11, 2020
@dennisseah dennisseah deleted the issue1138 branch March 11, 2020 20:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acquiring Subscription Id in spk setup command
3 participants