Search in sources :

Example 1 with Registry

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();
}
Also used : Registry(com.microsoft.azure.management.containerregistry.Registry)

Example 2 with Registry

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;
    }
}
Also used : Azure(com.microsoft.azure.management.Azure) Registries(com.microsoft.azure.management.containerregistry.Registries) Registry(com.microsoft.azure.management.containerregistry.Registry)

Example 3 with Registry

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);
}
Also used : Registry(com.microsoft.azure.management.containerregistry.Registry) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with 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();
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DockerClient(com.spotify.docker.client.DockerClient) DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) Registry(com.microsoft.azure.management.containerregistry.Registry) Job(org.eclipse.core.runtime.jobs.Job) PartInitException(org.eclipse.ui.PartInitException)

Example 5 with Registry

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));
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) Gson(com.google.gson.Gson) Registry(com.microsoft.azure.management.containerregistry.Registry) Tag(com.microsoft.azuretools.core.mvp.model.container.pojo.Tag)

Aggregations

Registry (com.microsoft.azure.management.containerregistry.Registry)14 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)5 Azure (com.microsoft.azure.management.Azure)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Gson (com.google.gson.Gson)2 Registries (com.microsoft.azure.management.containerregistry.Registries)2 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)2 DockerClient (com.spotify.docker.client.DockerClient)2 ArrayList (java.util.ArrayList)2 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 Notification (com.intellij.notification.Notification)1 Page (com.microsoft.azure.Page)1 RegistryInner (com.microsoft.azure.management.containerregistry.implementation.RegistryInner)1 RegistryListCredentials (com.microsoft.azure.management.containerregistry.implementation.RegistryListCredentials)1 PushImageRunConfiguration (com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1