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

Support private registries #381

Merged
merged 18 commits into from
Aug 24, 2018
Merged

Support private registries #381

merged 18 commits into from
Aug 24, 2018

Conversation

StephenWeatherford
Copy link
Contributor

@StephenWeatherford StephenWeatherford commented Aug 16, 2018

Fixes #18

  1. Connect/disconnect to private container registry
  2. TestTerminal modified to allow execution of and waiting on individual commands
  3. Some refactoring of Azure registry/container nodes, esp. to share code between Azure and custom nodes, but also some code issues
  4. Started tests, still need some work

image
image
image

Testcases added to OneNote tab "Custom registries"

@StephenWeatherford StephenWeatherford self-assigned this Aug 16, 2018
@StephenWeatherford StephenWeatherford requested review from ejizba and a team August 16, 2018 18:04
@StephenWeatherford
Copy link
Contributor Author

ping, thanks

this.sendText(command);
}

let results = await this.waitForCompletionCore({ ignoreErrors: options.ignoreErrors });
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You can just pass in options

}

// Remove files in preparation for next commands, if any
await fse.remove(this._semaphorePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect tests to run multiple things from the same terminal? I'm wondering if this should be in the dispose method instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm currently running multiple commands sometimes in tests. It's also possible we might add a setting to allow the user to do that eventually. I think this is safer and more flexible.

@@ -0,0 +1,110 @@
import * as ContainerModels from 'azure-arm-containerregistry/lib/models';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: copyright header

}

export async function getTags(registryUrl: string, repositoryName: string, credentials?: RegistryCredentials): Promise<TagInfo[]> {
let result = await registryRequest<{ tags: string[] }>(registryUrl, `v2/${repositoryName}/tags/list?page_size=100&page=1`, credentials);
Copy link
Contributor

Choose a reason for hiding this comment

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

So does this only get 100? Can we pull that out into a constant?

credentials: { userName, password }
};

let invalidMessage = await CustomRegistryNode.isValidRegistryUrl(newRegistry);
Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand isValidRegistryUrl correctly, this is what's happening:

let invalidMessage: string | undefined;
try {
    // check registry
} catch (error) {
    invalidMessage = parseError(error).message;
}
if (invalidMessage) {
    throw new Error(invalidMessage);
}

Which could just be written as this, correct?:

// check registry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:-) Artifacts from an original design.

repoNodes.push(new CustomRepositoryNode(repoName, this.registry));
}
} catch (error) {
vscode.window.showErrorMessage(parseError(error).message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you care that this will never be tracked in telemetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a work item for it: #358

function getKeytarModule(): typeof keytarType {
const keytar: typeof keytarType | undefined = getCoreNodeModule('keytar');
if (!keytar) {
throw new Error("Internal error: Could not find keytar module for reading and writing passwords");
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless you can prove this extension is useless without keytar, I think we should keep it optional (aka don't throw an error here and change the type to | undefined in ext like it was before your changes). We're relying on something shipped with VS Code and I just don't think we can assume it will always be there (I mean they've already changed it once).

@@ -275,6 +275,8 @@ export class RootNode extends NodeBase {
registryRootNodes.push(new RegistryRootNode('Azure', "azureRegistryRootNode", this.eventEmitter, this._azureAccount));
}

registryRootNodes.push(new RegistryRootNode('Private registries', 'customRootNode', null));
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like this is more of Attached registries. In other words, couldn't I use this to attach all types of things - including private/public/custom/Azure? Also - attached is consistent with Cosmos DB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now it only handles certain types of registries, we felt 'private registries' probably indicates that best. Might change later.

package.json Outdated
@@ -185,7 +187,7 @@
},
{
"command": "vscode-docker.createWebApp",
"when": "view == dockerExplorer && viewItem =~ /^(azureImageNode|dockerHubImageTag)$/"
"when": "view == dockerExplorer && viewItem =~ /^(azureImageTagNode|dockerHubImageTag|customImageTag)$/"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd prefer something like /^(azure|dockerHub|custom)ImageTag/$ (NOTE: You'd have to remove Node off of the Azure one or add it to the other ones to be consistent)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather not do it that way because it makes them harder to search for and also assumes something about their structure. Did take the time to make these more consistent, though.

utils/keytar.ts Outdated
}
}

export class TestKeytar implements IKeytar {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I prefer to keep all test code in the test folder


async function saveCustomRegistriesNonsensitive(registries: CustomRegistry[]): Promise<void> {
let minimal: CustomRegistryNonsensitive[] = registries.map(reg => <CustomRegistryNonsensitive>{ url: reg.url });
await ext.context.workspaceState.update(customRegistriesKey, minimal);
Copy link
Contributor

Choose a reason for hiding this comment

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

You missed this one (changing workspaceState to globalState)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks.

@StephenWeatherford StephenWeatherford merged commit 2d9e62b into master Aug 24, 2018
@StephenWeatherford StephenWeatherford deleted the saw/custom branch August 24, 2018 19:33
@microsoft microsoft locked and limited conversation to collaborators Oct 27, 2021
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