コード例 #1
0
        public async Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo)
        {
            if (module.Module is DockerModule dockerModule)
            {
                CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(dockerModule, runtimeInfo);

                var commands = new List <ICommand>();
                if (module.Module.ImagePullPolicy != ImagePullPolicy.Never)
                {
                    commands.Add(new PullCommand(this.client, combinedDockerConfig));
                }

                commands.Add(await CreateCommand.BuildAsync(this.client, dockerModule, module.ModuleIdentity, this.dockerLoggerConfig, this.configSource, module.Module is EdgeHubDockerModule));
                return(new GroupCommand(commands.ToArray()));
            }

            return(NullCommand.Instance);
        }
コード例 #2
0
        public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo)
        {
            if (current is DockerModule currentDockerModule && next.Module is DockerModule nextDockerModule)
            {
                CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(nextDockerModule, runtimeInfo);
                var commands = new List <ICommand>();
                if (next.Module.ImagePullPolicy != ImagePullPolicy.Never)
                {
                    commands.Add(new PullCommand(this.client, combinedDockerConfig));
                }

                commands.AddRange(
                    new ICommand[]
                {
                    new StopCommand(this.client, currentDockerModule),
                    new RemoveCommand(this.client, currentDockerModule),
                    await CreateCommand.BuildAsync(this.client, nextDockerModule, next.ModuleIdentity, this.dockerLoggerConfig, this.configSource, next.Module is EdgeHubDockerModule)
                });
                return(new GroupCommand(commands.ToArray()));
            }

            return(NullCommand.Instance);
        }