Tidy
This commit is contained in:
parent
be99d25fb2
commit
3288b488d3
|
@ -179,11 +179,7 @@ func (pw *PodWatcher) removePod(podName string) {
|
|||
func copyPodLogs(ctx context.Context, wg *sync.WaitGroup, client KubernetesClient, pod *corev1.Pod, container string, logStream chan string) *streamError {
|
||||
defer wg.Done()
|
||||
|
||||
podLogOpts := corev1.PodLogOptions{
|
||||
Follow: true,
|
||||
Container: container,
|
||||
}
|
||||
req := client.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts)
|
||||
req := client.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{Follow: true, Container: container})
|
||||
logs, err := req.Stream(ctx)
|
||||
|
||||
// If one container is still being created, do not treat this as a fatal error.
|
||||
|
|
|
@ -95,7 +95,6 @@ func (w *Watcher) Watch(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer watcher.Stop()
|
||||
|
||||
ticker := time.NewTicker(time.Second)
|
||||
|
@ -112,7 +111,6 @@ func (w *Watcher) Watch(ctx context.Context) error {
|
|||
switch evt.Type {
|
||||
case watch.Added, watch.Modified:
|
||||
resource := evt.Object.(*unstructured.Unstructured)
|
||||
uid := resource.GetUID()
|
||||
// TODO: handle matchExpressions
|
||||
selectorAsMap, ok, err := unstructured.NestedStringMap(resource.Object, "spec", "selector", "matchLabels")
|
||||
if !ok || err != nil {
|
||||
|
@ -121,12 +119,12 @@ func (w *Watcher) Watch(ctx context.Context) error {
|
|||
w.logger.Printf("warning: unable to parse matchLabels: ok = %t, err = %v", ok, err)
|
||||
continue
|
||||
}
|
||||
selector := labels.SelectorFromSet(selectorAsMap)
|
||||
w.addDeployment(ctx, uid, selector)
|
||||
|
||||
w.addDeployment(ctx, resource.GetUID(), labels.SelectorFromSet(selectorAsMap))
|
||||
case watch.Deleted:
|
||||
w.removeDeployment()
|
||||
}
|
||||
// errChan is never closed.
|
||||
case err := <-w.errChan:
|
||||
return err
|
||||
case <-ctx.Done():
|
||||
|
|
Loading…
Reference in New Issue