use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerSettingComposite method listRegistries.
@Override
public void listRegistries(@NotNull List<Registry> registryList) {
cbContainerRegistry.removeAll();
registryCache.clear();
cbContainerRegistry.add(SELECT_REGISTRY);
registryCache.add(null);
for (Registry registry : registryList) {
cbContainerRegistry.add(registry.name());
}
cbContainerRegistry.select(0);
registryCache.addAll(registryList);
layout();
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryMvpModel method setAdminUserEnabled.
/**
* Set AdminUser enabled status of container registry.
*/
public Registry setAdminUserEnabled(String sid, String id, boolean enabled) {
Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
Registries registries = azure.containerRegistries();
if (registries != null) {
Registry registry = registries.getById(id);
if (registry != null) {
clearTags(registry);
if (enabled) {
registry.update().withRegistryNameAsAdminUser().apply();
} else {
registry.update().withoutRegistryNameAsAdminUser().apply();
}
}
return registry;
} else {
return null;
}
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryMvpModelTest method testGetContainerRegistry.
@Test
public void testGetContainerRegistry() throws Exception {
Registry registry = containerRegistryMvpModel.getContainerRegistry(MOCK_SUBSCRIPTION_ID, MOCK_REGISTRY_ID);
assertEquals(registryMock1, registry);
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryExplorerEditor method pullImage.
private void pullImage() {
Job job = new Job(PULL_IMAGE) {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(PULL_IMAGE, IProgressMonitor.UNKNOWN);
String deploymentName = UUID.randomUUID().toString();
try {
if (Utils.isEmptyString(currentRepo) || Utils.isEmptyString(currentTag)) {
throw new Exception(REPO_TAG_NOT_AVAILABLE);
}
final String image = String.format("%s:%s", currentRepo, currentTag);
String jobDescription = String.format("Pulling: %s", image);
AzureDeploymentProgressNotification.createAzureDeploymentProgressNotification(deploymentName, jobDescription);
AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, "", 5, "Getting Registry...");
final Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(subscriptionId, registryId);
AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, "", 5, "Getting Credential...");
final PrivateRegistryImageSetting setting = ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
final String fullImageTagName = String.format("%s/%s", registry.loginServerUrl(), image);
AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, "", 10, "Pulling image...");
DockerClient docker = DefaultDockerClient.fromEnv().build();
DockerUtil.pullImage(docker, registry.loginServerUrl(), setting.getUsername(), setting.getPassword(), fullImageTagName);
AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, null, 100, "Finish.");
sendTelemetry(true, subscriptionId, null);
} catch (Exception ex) {
monitor.done();
AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, null, -1, ex.getMessage());
sendTelemetry(false, subscriptionId, ex.getMessage());
return Status.CANCEL_STATUS;
}
monitor.done();
return Status.OK_STATUS;
}
};
job.schedule();
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryPropertyViewPresenter method onListTags.
/**
* Called when listing image tags for the given repository.
*/
public void onListTags(String sid, String id, String repo, boolean isNextPage) {
if (isSubscriptionIdAndResourceIdInValid(sid, id)) {
return;
}
resetTagStack();
Observable.fromCallable(() -> {
Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(sid, id);
PrivateRegistryImageSetting setting = ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
Map<String, String> query = buildQueryMap(isNextPage, tagStack, nextTag);
Map<String, String> responseMap = ContainerExplorerMvpModel.getInstance().listTags(registry.loginServerUrl(), setting.getUsername(), setting.getPassword(), repo, query);
updatePaginationInfo(isNextPage, Type.TAG, responseMap.get(HEADER_LINK));
Gson gson = new Gson();
Tag tag = gson.fromJson(responseMap.get(BODY), Tag.class);
return tag.getTags();
}).subscribeOn(getSchedulerProvider().io()).subscribe(tags -> DefaultLoader.getIdeHelper().invokeLater(() -> {
if (isViewDetached()) {
return;
}
getMvpView().listTag(tags);
}), e -> errorHandler(CANNOT_GET_TAGS, (Exception) e));
}
Aggregations