-
Notifications
You must be signed in to change notification settings - Fork 527
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
Generalize registry support #1097
Conversation
So that it's much easier for the community to add support for more providers
} | ||
|
||
await pullImages(context, node.parent.parent, node.fullTag); | ||
await pullImages(context, node.parent.parent, node.repoNameAndTag); | ||
} | ||
|
||
async function pullImages(context: IActionContext, node: RegistryTreeItemBase, imageRequest: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR. This function name is not apt given that it also pulls repositories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the file name is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y'all there's only so much refactoring/file-renaming a person can do at a time 😂
With the caveat that I didn't name this, I think it's named like this because pulling a repository is technically just pulling multiple images at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving from request change to comment since I'll be OOF.
{ | ||
"command": "vscode-docker.registries.pullImage", | ||
"when": "view == dockerRegistries && viewItem =~ /tag$/i", | ||
"when": "view == dockerRegistries && viewItem =~ /Tag;/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pardon my Dockgerance (Docker + ignorance), but why are all the viewItems for the images called Tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,63 @@ | |||
/*--------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the design decision to create this file to parse all of the contextValues instead of letting the treeItemBase
classes contain the values? I was wondering since it's a pretty different design pattern from our other repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to create a common pattern for context values so that people wouldn't have to edit package.json when adding new registry providers. The GitLab PR shows that. I found that the previous pattern wasn't flexible enough to support that.
@@ -29,7 +34,8 @@ export async function deployImageToAzure(context: IActionContext, node?: RemoteT | |||
newSiteKind: AppKind.app | |||
}; | |||
const promptSteps: AzureWizardPromptStep<IAppServiceWizardContext>[] = []; | |||
const azureAccountTreeItem = await validateAzureAccountInstalled(); | |||
// Create a temporary azure account tree item since Azure might not be connected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connected as in the user isn't logged in yet? Or is there special work to have Azure integrated with Docker (similar to GitHub?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connected is referencing the "registries" view. You can deploy a docker hub image to azure, which means you may have never connected the Azure "registries" provider since your images are in Docker Hub, not Azure.
} | ||
} else { | ||
imagePath = registryTI.host; | ||
password = await registryTI.parent.getPassword(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There used to be an error thrown here if either username or password were undefined. Does getPassword
throw an error if it fails to retrieve the password from the keytar or whatever it's using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
99% of the time there will be a username and password. It's not clear what should happen if there isn't, but I decided to err on the side of letting them deploy. There are plenty of self-hosted registries out there with weird auth schemes and I don't want to block people.
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_USERNAME", value: username }); | ||
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_PASSWORD", value: password }); | ||
if (username && password) { | ||
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_USERNAME", value: username }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these settings only needed for specific types of Registries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only ones that need authentication. For example, there are public docker hub images. Plus you could always add these settings later yourself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or more likely - self hosted registries might exist that don't have auth setup yet
} | ||
|
||
const confirmUntag: string = `Are you sure you want to untag "${node.fullTag}"? This does not delete the manifest referenced by the tag.`; | ||
const confirmUntag: string = `Are you sure you want to untag "${node.repoNameAndTag}"? This does not delete the manifest referenced by the tag.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this isn't destructive, do we need to prompt for it? I realize that you aren't the one who made it a prompt, just wondering if we needed to have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is (partially) destructive
@@ -22,7 +23,8 @@ export async function openDockerHubInBrowser(context: IActionContext, node?: Doc | |||
} else if (node instanceof DockerHubRepositoryTreeItem) { | |||
url += `r/${node.parent.namespace}/${node.repoName}`; | |||
} else { | |||
url += `r/${node.parent.parent.namespace}/${node.parent.repoName}/tags` | |||
const repoTI = <DockerHubRepositoryTreeItem>node.parent; | |||
url += `r/${repoTI.parent.namespace}/${repoTI.repoName}/tags`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why it's using += here? It doesn't look like there was anything assigned to dockerHubUrl
previously anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dockerHubUrl is defined in constants.ts
const terminal: Terminal = ext.terminalProvider.createTerminal('docker logout'); | ||
terminal.sendText(command); | ||
terminal.sendText(`docker logout ${creds.registryPath}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to replace all of the terminal calls with dockerode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered it, but that's a pretty big refactor and I've probably already gone too far down the refactoring rabbit-hole lately
ext.registriesTree = new AzExtTreeDataProvider(registriesTreeItem, registriesLoadMore); | ||
ext.registriesTreeView = window.createTreeView('dockerRegistries', { treeDataProvider: ext.registriesTree }); | ||
ext.registriesTree = new AzExtTreeDataProvider(ext.registriesRoot, registriesLoadMore); | ||
ext.registriesTreeView = window.createTreeView('dockerRegistries', { treeDataProvider: ext.registriesTree, showCollapseAll: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🎉 🎉 🎉 🎉
break; | ||
} | ||
let placeHolder: string = 'Select the provider for your registry'; | ||
const provider = (await ext.ui.showQuickPick(picks, { placeHolder, suppressPersistence: true })).data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a learnMore property that we can leverage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's only for warning messages, not quick picks. Also that logic will re-show the message, but there's no point of re-showing the quick pick if your provider isn't listed
I'm skeptical that we'll ever have time to support all of the providers listed in #869, so my goal with this PR was to make it as easy as possible for the community to add support for their provider. I used GitLab as a test subject, and I'll send out a separate PR so that you can see what that looks like.
The main things that are now generalized:
Since the list of providers will theoretically grow and make the registries view cluttered, the default view will now be this:
Once you select to connect one, you will see this:
That means you will only see the providers you have connected. This is a breaking change from the previous experience and it means all users will essentially have to re-connect to their registry provider when we ship this update. Here's an example of a few registries that are connected:
(You may notice one side-benefit of this work is that you can log in to multiple docker hub accounts 🙂)
Fixes #1091