MCPcopy Index your code
hub / github.com/devspace-sh/devspace / readAll

Function readAll

pkg/devspace/services/sync/controller.go:582–628  ·  view source on GitHub ↗

Taken from Dockerignore ReadAll reads a .dockerignore file and returns the list of file patterns to ignore. Note this will trim whitespace from each line as well as use GO's "clean" func to get the shortest/cleanest path for each.

(reader io.Reader)

Source from the content-addressed store, hash-verified

580// to ignore. Note this will trim whitespace from each line as well
581// as use GO's "clean" func to get the shortest/cleanest path for each.
582func readAll(reader io.Reader) ([]string, error) {
583 if reader == nil {
584 return nil, nil
585 }
586
587 scanner := bufio.NewScanner(reader)
588 var excludes []string
589 currentLine := 0
590
591 utf8bom := []byte{0xEF, 0xBB, 0xBF}
592 for scanner.Scan() {
593 scannedBytes := scanner.Bytes()
594 // We trim UTF8 BOM
595 if currentLine == 0 {
596 scannedBytes = bytes.TrimPrefix(scannedBytes, utf8bom)
597 }
598 pattern := string(scannedBytes)
599 currentLine++
600 // Lines starting with # (comments) are ignored before processing
601 if strings.HasPrefix(pattern, "#") {
602 continue
603 }
604 pattern = strings.TrimSpace(pattern)
605 if pattern == "" {
606 continue
607 }
608 // normalize absolute paths to paths relative to the context
609 // (taking care of '!' prefix)
610 invert := pattern[0] == '!'
611 if invert {
612 pattern = strings.TrimSpace(pattern[1:])
613 }
614 if len(pattern) > 0 {
615 pattern = filepath.Clean(pattern)
616 pattern = filepath.ToSlash(pattern)
617 }
618 if invert {
619 pattern = "!" + pattern
620 }
621
622 excludes = append(excludes, pattern)
623 }
624 if err := scanner.Err(); err != nil {
625 return nil, fmt.Errorf("error reading .dockerignore: %v", err)
626 }
627 return excludes, nil
628}
629
630func StartStream(ctx context.Context, client kubectl.Client, pod *v1.Pod, container string, command []string, reader io.Reader, stdoutWriter io.Writer, buffer bool, log logpkg.Logger) error {
631 stderrBuffer := &bytes.Buffer{}

Callers 1

parseExcludeFileFunction · 0.85

Calls 2

ErrMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected