• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

astronomer / astro-cli / 1b614b35-4125-4564-8d4c-c96218882fef

09 Sep 2025 05:45PM UTC coverage: 38.131% (+0.001%) from 38.13%
1b614b35-4125-4564-8d4c-c96218882fef

Pull #1934

circleci

pre-commit-ci[bot]
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
Pull Request #1934: Update user-facing strings from "Software" to "Astro Private Cloud"

13 of 13 new or added lines in 7 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

23747 of 62277 relevant lines covered (38.13%)

10.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.81
/docker/docker.go
1
package docker
2

3
import (
4
        "fmt"
5
        "io"
6
        "os"
7
        "os/exec"
8

9
        "github.com/astronomer/astro-cli/airflow/runtimes"
10
        "github.com/docker/docker/api/types"
11
        "github.com/docker/docker/pkg/stdcopy"
12
)
13

14
const (
15
        // Docker is the docker command.
16
        Docker = "docker"
17
)
18

19
// AirflowCommand is the main method of interaction with Airflow
20
func AirflowCommand(id, airflowCommand string) (string, error) {
×
21
        containerRuntime, err := runtimes.GetContainerRuntimeBinary()
×
22
        if err != nil {
×
23
                return "", err
×
24
        }
×
25
        cmd := exec.Command(containerRuntime, "exec", "-it", id, "bash", "-c", airflowCommand)
×
26
        cmd.Stdin = os.Stdin
×
27
        cmd.Stderr = os.Stderr
×
28

×
29
        out, err := cmd.Output()
×
30
        if err != nil {
×
31
                return "", fmt.Errorf("error encountered while running the airflow command: %w", err)
×
32
        }
×
33

34
        stringOut := string(out)
×
35
        return stringOut, nil
×
36
}
37

38
// ExecPipe does pipe stream into stdout/stdin and stderr
39
// so now we can pipe out during exec'ing any commands inside container
40
func ExecPipe(resp types.HijackedResponse, inStream io.Reader, outStream, errorStream io.Writer) error {
1✔
41
        var err error
1✔
42
        receiveStdout := make(chan error, 1)
1✔
43
        if outStream != nil || errorStream != nil {
2✔
44
                go func() {
2✔
45
                        // always do this because we are never tty
1✔
46
                        _, err = stdcopy.StdCopy(outStream, errorStream, resp.Reader)
1✔
47
                        receiveStdout <- err
1✔
48
                }()
1✔
49
        }
50

51
        stdinDone := make(chan struct{})
1✔
52
        go func() {
2✔
53
                if inStream != nil {
2✔
54
                        _, err := io.Copy(resp.Conn, inStream)
1✔
55
                        if err != nil {
1✔
56
                                fmt.Println("Error copying input stream: ", err.Error())
×
57
                        }
×
58
                }
59

60
                err := resp.CloseWrite()
1✔
61
                if err != nil {
1✔
62
                        fmt.Println("Error closing response body: ", err.Error())
×
63
                }
×
64
                close(stdinDone)
1✔
65
        }()
66

67
        select {
1✔
UNCOV
68
        case err := <-receiveStdout:
×
UNCOV
69
                if err != nil {
×
70
                        return err
×
71
                }
×
72
        case <-stdinDone:
1✔
73
                if outStream != nil || errorStream != nil {
2✔
74
                        if err := <-receiveStdout; err != nil {
1✔
75
                                return err
×
76
                        }
×
77
                }
78
        }
79

80
        return nil
1✔
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc