Skip to content

Enable new workspace re-deploy settings for deployWorkspaceProject#454

Merged
MicroFish91 merged 11 commits intomainfrom
mwf/deployWorkspaceProject-V-I
Sep 22, 2023
Merged

Enable new workspace re-deploy settings for deployWorkspaceProject#454
MicroFish91 merged 11 commits intomainfrom
mwf/deployWorkspaceProject-V-I

Conversation

@MicroFish91
Copy link
Copy Markdown
Contributor

@MicroFish91 MicroFish91 commented Sep 19, 2023

Related to #425

Another partial PR for deployWorkspaceProject.

Added support for 3 new (re-)deploy settings for deployWorkspaceProject. We use these three settings to check for existing resources to add to the context before executing the deployment.

The default resources affected by this PR are: container app, managed environment, resource group, ACR.

Logic goes:

  1. Check if workspace settings exist
  2. If yes, check that Azure actually has those resources available, and if so, grab them for re-use
  3. If no to any of the above, set/keep as undefined and allow the DefaultResourcesNameStep (added in previous PR) to name the resources for later creation

The workflow in general has been demo'd to Anthony and Misty including the showing of a re-deploy scenario with these same settings. Feel free to suggest any improvements as necessary though.

What the full thing will eventually look like: demo

@MicroFish91 MicroFish91 changed the title Enable default resources using workspace settings for deployWorkspaceProject Enable new workspace re-deploy settings for deployWorkspaceProject Sep 19, 2023
@MicroFish91 MicroFish91 changed the base branch from main to mwf/setting-utils September 19, 2023 22:45
Base automatically changed from mwf/setting-utils to main September 20, 2023 17:18
@MicroFish91 MicroFish91 marked this pull request as ready for review September 20, 2023 17:30
@MicroFish91 MicroFish91 requested a review from a team as a code owner September 20, 2023 17:30
containerRegistryName
};
}
} catch { /** Do nothing */ }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be useful to add a comment here that explains what errors are being ignored here and why

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok now that I see this again, you should probably log something inside that catch block too.

Copy link
Copy Markdown
Contributor Author

@MicroFish91 MicroFish91 Sep 21, 2023

Choose a reason for hiding this comment

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

This was a good suggestion, especially because it actually pushed me to test the get setting method a little bit more 😆

I realized that it doesn't actually throw an error even with bad settings path and property... so I removed the catch entirely. I also made a small change to the setting utils so that it reads a missing value as undefined rather than as an empty string '' (definitely not a behavior I expected it to have by default).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok that's great

const savedRegistry: Registry | undefined = registries.find(r => r.name === settings.containerRegistryName);

if (savedRegistry) {
ext.outputChannel.appendLog(localize('foundResourceMatch', 'Used saved workspace settings and found an existing container registry.'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Big fan of the logs in this function. You could include the found resource names in the log if you wanted to be even more verbose. But just an idea.

Copy link
Copy Markdown
Contributor Author

@MicroFish91 MicroFish91 Sep 20, 2023

Choose a reason for hiding this comment

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

This suggestion will be included in the following PR!

const containerAppResourceGroupName: string | undefined = settingUtils.getWorkspaceSetting(`${deployWorkspaceProjectPrefix}.containerAppResourceGroupName`, settingsPath);
const containerRegistryName: string | undefined = settingUtils.getWorkspaceSetting(`${deployWorkspaceProjectPrefix}.containerRegistryName`, settingsPath);

if (containerAppName || containerAppResourceGroupName || containerRegistryName) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't a blocker, but I think it's awkward to only return an object if one of the properties is defined. And otherwise we return undefined.

In the future, if you add more settings, then you need to add them to this if expression.

I think I'd prefer if you just always return an object, even if the object just contains undefined values.

@MicroFish91 MicroFish91 force-pushed the mwf/deployWorkspaceProject-V-I branch 2 times, most recently from 19ab5a8 to 206ab5b Compare September 20, 2023 23:03
@MicroFish91 MicroFish91 force-pushed the mwf/deployWorkspaceProject-V-I branch from 206ab5b to ad4f149 Compare September 21, 2023 14:45
@MicroFish91 MicroFish91 force-pushed the mwf/deployWorkspaceProject-V-I branch from d9e378f to 052fc86 Compare September 21, 2023 20:27
@MicroFish91 MicroFish91 merged commit 1f552f0 into main Sep 22, 2023
@MicroFish91 MicroFish91 deleted the mwf/deployWorkspaceProject-V-I branch September 22, 2023 21:19
@microsoft microsoft locked and limited conversation to collaborators Mar 8, 2024
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.

2 participants