private async Task Reconcile(List <ResourceEvent <V1Pod> > changes) { // invoke reconcilation here var obj = changes.First().Value; var sb = new StringBuilder(); // sb.AppendLine($"Received changes for object with ID {KubernetesObject.KeySelector(obj)} with {changes.Count} items"); sb.AppendLine($"Received changes for object with ID {KubernetesObject.KeySelector(obj)} with {changes.Count} items"); sb.AppendLine($"Last known state was {changes.Last().EventFlags}"); foreach (var item in changes) { sb.AppendLine($"==={item.EventFlags}==="); sb.AppendLine($"Name: {item.Value.Metadata.Name}"); sb.AppendLine($"Version: {item.Value.Metadata.ResourceVersion}"); if (item.EventFlags.HasFlag(EventTypeFlags.Modify)) { var updateDelta = _objectCompare.Compare(item.OldValue, item.Value); foreach (var difference in updateDelta.Differences) { sb.AppendLine($"{difference.PropertyName}: {difference.Object1} -> {difference.Object2}"); } } // sb.AppendLine(JsonConvert.SerializeObject(item, Formatting.Indented, new StringEnumConverter())); } _reconcilerLogger.LogInformation(sb.ToString()); await Task.Delay(TimeSpan.FromSeconds(10)); // simulate await Task.CompletedTask; }
private static Func <IInformer <TResource>, IInformer <TResource> > SharedKubernetesInformerFactory(ILoggerFactory loggerFactory, Func <ICache <string, TResource> > cacheFactory) => masterInformer => new SharedInformer <string, TResource>( masterInformer, loggerFactory.CreateLogger <ILogger <SharedInformer <string, TResource> > >(), x => KubernetesObject.KeySelector(x), cacheFactory());