MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / Multiple

Method Multiple

pkg/podlogs/writer.go:96–119  ·  view source on GitHub ↗

Multiple streams the pod logs, sending each container's stream to a separate writer

(
	ctx context.Context,
	opts *corev1.PodLogOptions,
	writerConstructor writerConstructor,
	filePathGenerator func(string) string,
)

Source from the content-addressed store, hash-verified

94
95// Multiple streams the pod logs, sending each container's stream to a separate writer
96func (spl *Writer) Multiple(
97 ctx context.Context,
98 opts *corev1.PodLogOptions,
99 writerConstructor writerConstructor,
100 filePathGenerator func(string) string,
101) error {
102 if opts.Container != "" {
103 return fmt.Errorf("use Single method to handle a single container output")
104 }
105
106 for _, container := range spl.Pod.Spec.Containers {
107 writer, err := writerConstructor.Create(filePathGenerator(container.Name))
108 if err != nil {
109 return err
110 }
111 containerOpts := opts.DeepCopy()
112 containerOpts.Container = container.Name
113
114 if err := spl.sendLogsToWriter(ctx, writer, containerOpts); err != nil {
115 return err
116 }
117 }
118 return nil
119}
120
121func executeGetLogRequest(ctx context.Context, logRequest *rest.Request, writer io.Writer) error {
122 logStream, err := logRequest.Stream(ctx)

Callers 3

writer_test.goFile · 0.80
streamClusterLogsToZipFunction · 0.80

Calls 3

sendLogsToWriterMethod · 0.95
CreateMethod · 0.65
DeepCopyMethod · 0.45

Tested by

no test coverage detected