use of com.microsoft.azure.management.containerregistry.Registry in project azure-sdk-for-java by Azure.
the class TestContainerRegistry method createResource.
@Override
public Registry createResource(Registries registries) throws Exception {
final String newName = "registry" + this.testId;
Registry registry = registries.define(newName).withRegion(Region.US_WEST).withNewResourceGroup().withNewStorageAccount("crsa" + this.testId).withRegistryNameAsAdminUser().create();
Assert.assertTrue(registry.adminUserEnabled());
Assert.assertEquals(registry.storageAccountName(), "crsa" + this.testId);
RegistryListCredentials registryCredentials = registry.listCredentials();
Assert.assertNotNull(registryCredentials);
Assert.assertEquals(newName, registryCredentials.username());
Assert.assertEquals(2, registryCredentials.passwords().size());
return registry;
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryPropertyViewPresenter method onListRepositories.
/**
* Called when listing repositories of ACR.
*/
public void onListRepositories(String sid, String id, 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, repoStack, nextRepo);
Map<String, String> responseMap = ContainerExplorerMvpModel.getInstance().listRepositories(registry.loginServerUrl(), setting.getUsername(), setting.getPassword(), query);
updatePaginationInfo(isNextPage, Type.REPO, responseMap.get(HEADER_LINK));
Gson gson = new Gson();
Catalog catalog = gson.fromJson(responseMap.get(BODY), Catalog.class);
return catalog.getRepositories();
}).subscribeOn(getSchedulerProvider().io()).subscribe(repos -> DefaultLoader.getIdeHelper().invokeLater(() -> {
if (isViewDetached()) {
return;
}
getMvpView().listRepo(repos);
}), e -> errorHandler(CANNOT_GET_REPOS, (Exception) e));
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerRegistryPropertyView method pullImage.
private void pullImage() {
final AzureString title = AzureOperationBundle.title("docker|image.pull", currentRepo);
AzureTaskManager.getInstance().runInBackground(new AzureTask(null, title, false, () -> {
try {
if (Utils.isEmptyString(currentRepo) || Utils.isEmptyString(currentTag)) {
throw new Exception(REPO_TAG_NOT_AVAILABLE);
}
final Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(subscriptionId, registryId);
final PrivateRegistryImageSetting setting = ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
final String image = String.format("%s:%s", currentRepo, currentTag);
final String fullImageTagName = String.format("%s/%s", registry.loginServerUrl(), image);
DockerClient docker = DefaultDockerClient.fromEnv().build();
DockerUtil.pullImage(docker, registry.loginServerUrl(), setting.getUsername(), setting.getPassword(), fullImageTagName);
String message = String.format(IMAGE_PULL_SUCCESS, fullImageTagName);
UIUtils.showNotification(statusBar, message, MessageType.INFO);
sendTelemetry(true, subscriptionId, null);
} catch (Exception e) {
UIUtils.showNotification(statusBar, e.getMessage(), MessageType.ERROR);
sendTelemetry(false, subscriptionId, e.getMessage());
}
}));
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class ContainerSettingPanel method listRegistries.
@Override
public void listRegistries(@NotNull final List<Registry> registries) {
DefaultComboBoxModel<Object> model = (DefaultComboBoxModel<Object>) cbContainerRegistry.getModel();
model.removeAllElements();
model.addElement(SELECT_REGISTRY);
for (Registry registry : registries) {
model.addElement(registry);
}
}
use of com.microsoft.azure.management.containerregistry.Registry in project azure-tools-for-java by Microsoft.
the class PushToContainerRegistryAction method runConfiguration.
@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(@NotNull Project project) {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final ConfigurationFactory factory = configType.getPushImageRunConfigurationFactory();
RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s", factory.getName(), project.getName()));
Observable.fromCallable(() -> {
Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(currentNode.getSubscriptionId(), currentNode.getResourceId());
return ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
}).subscribeOn(SchedulerProviderFactory.getInstance().getSchedulerProvider().io()).subscribe(ret -> {
if (settings != null) {
PushImageRunConfiguration conf = (PushImageRunConfiguration) settings.getConfiguration();
PrivateRegistryImageSetting imageSetting = conf.getPrivateRegistryImageSetting();
imageSetting.setServerUrl(ret.getServerUrl());
imageSetting.setUsername(ret.getUsername());
imageSetting.setPassword(ret.getPassword());
AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, settings));
return;
}
AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, ret));
}, err -> {
err.printStackTrace();
Notification notification = new Notification(NOTIFICATION_GROUP_ID, DIALOG_TITLE, err.getMessage(), NotificationType.ERROR);
Notifications.Bus.notify(notification);
});
}
Aggregations