public CombinedKubernetesConfigProvider(
     IEnumerable <global::Docker.DotNet.Models.AuthConfig> authConfigs,
     Uri workloadUri,
     Uri managementUri,
     bool enableKubernetesExtensions)
 {
     this.dockerConfigProvider       = new CombinedDockerConfigProvider(authConfigs);
     this.workloadUri                = Preconditions.CheckNotNull(workloadUri, nameof(workloadUri));
     this.managementUri              = Preconditions.CheckNotNull(managementUri, nameof(managementUri));
     this.enableKubernetesExtensions = enableKubernetesExtensions;
 }
예제 #2
0
        internal override InitializationResult _Init(IConfigurationRoot configuration, IContainer container)
        {
            _dockerClient = new DockerClientConfiguration(new Uri(configuration.GetValue <string>("DockerUri")))
                            .CreateClient();

            var configSource = new EmulatorConfigSource(configuration);

            var dockerLoggingOptions = new Dictionary <string, string>
            {
                { "max-size", "1m" },
                { "max-file", "1" }
            };
            var loggingConfig = new DockerLoggingConfig("json-file", dockerLoggingOptions);

            var dockerAuthConfig = configuration.GetSection("DockerRegistryAuth").Get <List <AuthConfig> >() ??
                                   new List <AuthConfig>();
            var combinedDockerConfigProvider = new CombinedDockerConfigProvider(dockerAuthConfig);
            //var runtimeInfoProvider = RuntimeInfoProvider.CreateAsync(_dockerClient);

            var dockerModule = new Devices.Edge.Agent.Docker.DockerModule(
                Name,
                DockerHostingSettings.Version,
                DockerHostingSettings.DesiredStatus.Value,
                DockerHostingSettings.RestartPolicy.Value,
                DockerHostingSettings.Config,
                null,
                null
                );

            var connectionString =
                configuration.GetValue <string>(Devices.Edge.Agent.Core.Constants.EdgeHubConnectionStringKey);
            var connectionStringBuilder = IotHubConnectionStringBuilder.Create(connectionString);

            var moduleIdentity = new ModuleIdentity(connectionStringBuilder.IotHubName,
                                                    Environment.MachineName,
                                                    connectionStringBuilder.DeviceId,
                                                    connectionStringBuilder.ModuleId,
                                                    new ConnectionStringCredentials(connectionString));

            _moduleWithIdentity = new ModuleWithIdentity(dockerModule, moduleIdentity);
            //var combinedDockerConfig = combinedDockerConfigProvider.GetCombinedConfig(dockerModule, runtimeInfo);

            _dockerFactory = new LoggingCommandFactory(new DockerCommandFactory(_dockerClient,
                                                                                loggingConfig,
                                                                                configSource,
                                                                                combinedDockerConfigProvider),
                                                       Devices.Edge.Util.Logger.Factory);

            //var updateCommand = new GroupCommand(
            //      new RemoveCommand(_dockerClient, dockerModule),
            //        new GroupCommand(
            //            new PullCommand(_dockerClient, combinedDockerConfig),
            //            CreateCommand.BuildAsync(_dockerClient,
            //            dockerModule,
            //            dockerModuleWithIdentity.ModuleIdentity,
            //            loggingConfig,
            //            configSource,
            //            false).Result));

            //_createCommand = new GroupCommand(
            //   new PullCommand(_dockerClient, combinedDockerConfig),
            //   CreateCommand.BuildAsync(_dockerClient,
            //   dockerModule,
            //   dockerModuleWithIdentity.ModuleIdentity,
            //   loggingConfig,
            //   configSource,
            //   false).Result);

            //_startCommand = dockerFactory.StartAsync(dockerModule).Result;
            return(base._Init(configuration, container));
        }