Esempio n. 1
0
        public TransferClient(
            AzureEnvironmentConfiguration azureEnvironmentConfiguration,
            IdentityConfiguration identityConfiguration,
            RegistryConfiguration registryConfiguration)
        {
            _registryConfiguration = registryConfiguration ?? throw new ArgumentNullException(nameof(registryConfiguration));

            var env = AzureEnvironment.FromName(azureEnvironmentConfiguration.Name);

            if (env == null)
            {
                env = new AzureEnvironment
                {
                    Name = azureEnvironmentConfiguration.Name,
                    AuthenticationEndpoint  = azureEnvironmentConfiguration.AuthenticationEndpoint,
                    ManagementEndpoint      = azureEnvironmentConfiguration.ManagementEndpoint,
                    ResourceManagerEndpoint = azureEnvironmentConfiguration.ResourceManagerEndpoint,
                    GraphEndpoint           = azureEnvironmentConfiguration.GraphEndpoint,
                    KeyVaultSuffix          = azureEnvironmentConfiguration.KeyVaultSuffix,
                    StorageEndpointSuffix   = azureEnvironmentConfiguration.StorageEndpointSuffix
                };
            }

            var credential = new AzureCredentials(
                new ServicePrincipalLoginInformation
            {
                ClientId     = identityConfiguration.ClientId,
                ClientSecret = identityConfiguration.ClientSecret
            },
                registryConfiguration.TenantId,
                env);

            _registryClient = new ContainerRegistryManagementClient(credential.WithDefaultSubscription(registryConfiguration.SubscriptionId));
            _registryClient.SubscriptionId = registryConfiguration.SubscriptionId;
        }
Esempio n. 2
0
        public ImportWorker(
            ImportConfiguration importConfiguration,
            RegistryConfiguration registryConfiguration,
            TransferClient transferClient,
            ILogger <ImportWorker> logger)
        {
            if (registryConfiguration == null)
            {
                throw new ArgumentNullException(nameof(registryConfiguration));
            }

            _importConfiguration = importConfiguration ?? throw new ArgumentNullException(nameof(importConfiguration));
            _transferClient      = transferClient ?? throw new ArgumentNullException(nameof(transferClient));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (!string.IsNullOrWhiteSpace(importConfiguration.SourceRegistry.ResourceId))
            {
                var resourceId = ResourceId.Parse(importConfiguration.SourceRegistry.ResourceId);
                _sourceRegistry = new Registry(
                    null,
                    resourceId.SubscriptionId,
                    resourceId.ResourceGroupName,
                    resourceId.ResourceName);
            }
            else
            {
                _sourceRegistry = new Registry(
                    importConfiguration.SourceRegistry.RegistryUri,
                    importConfiguration.SourceRegistry.UserName,
                    importConfiguration.SourceRegistry.Password);
            }
        }
Esempio n. 3
0
        public ExportWorker(
            ExportConfiguration exportDefinition,
            RegistryConfiguration registryConfiguration,
            IdentityConfiguration identityConfiguration,
            TransferClient transferClient,
            ILogger <ExportWorker> logger)
        {
            _transferClient        = transferClient ?? throw new ArgumentNullException(nameof(transferClient));
            _exportConfiguration   = exportDefinition ?? throw new ArgumentNullException(nameof(exportDefinition));
            _identityConfiguration = identityConfiguration ?? throw new ArgumentNullException(nameof(identityConfiguration));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _registry = new Registry(
                registryConfiguration.TenantId,
                registryConfiguration.SubscriptionId,
                registryConfiguration.ResourceGroupName,
                registryConfiguration.Name);
        }