Esempio n. 1
0
        public async System.Threading.Tasks.Task ImportImageAsync(
            Registry sourceRegistry,
            string sourceImage,
            bool force = true,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (sourceRegistry == null)
            {
                throw new ArgumentNullException(nameof(sourceRegistry));
            }

            var sourceResourceId  = sourceRegistry.ResourceId?.ToString();
            var sourceLoginServer = string.IsNullOrEmpty(sourceResourceId) ? sourceRegistry.LoginServer : null;
            var importSource      = new ImportSource()
            {
                ResourceId  = sourceResourceId,
                RegistryUri = sourceLoginServer,
                SourceImage = sourceImage
            };

            if (!string.IsNullOrEmpty(sourceRegistry.UserName))
            {
                importSource.Credentials = new ImportSourceCredentials()
                {
                    Username = sourceRegistry.UserName,
                    Password = sourceRegistry.Password
                };
            }

            var importImageParameters = new ImportImageParameters()
            {
                Mode       = force ? ImportModeForce : ImportModeNoForce,
                Source     = importSource,
                TargetTags = new List <string> {
                    sourceImage
                }
            };

            importImageParameters.Validate();

            await _registryClient.Registries.ImportImageAsync(
                _registryConfiguration.ResourceGroupName,
                _registryConfiguration.Name,
                importImageParameters,
                cancellationToken).ConfigureAwait(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Copies an image to this container registry from the specified container
 /// registry.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group to which the container registry belongs.
 /// </param>
 /// <param name='registryName'>
 /// The name of the container registry.
 /// </param>
 /// <param name='parameters'>
 /// The parameters specifying the image to copy and the source container
 /// registry.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task BeginImportImageAsync(this IRegistriesOperations operations, string resourceGroupName, string registryName, ImportImageParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.BeginImportImageWithHttpMessagesAsync(resourceGroupName, registryName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Esempio n. 3
0
 /// <summary>
 /// Copies an image to this container registry from the specified container
 /// registry.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group to which the container registry belongs.
 /// </param>
 /// <param name='registryName'>
 /// The name of the container registry.
 /// </param>
 /// <param name='parameters'>
 /// The parameters specifying the image to copy and the source container
 /// registry.
 /// </param>
 public static void BeginImportImage(this IRegistriesOperations operations, string resourceGroupName, string registryName, ImportImageParameters parameters)
 {
     operations.BeginImportImageAsync(resourceGroupName, registryName, parameters).GetAwaiter().GetResult();
 }