MCPcopy Create free account
hub / github.com/nhost/nhost / HasuraWrapper

Method HasuraWrapper

cli/dockercompose/docker.go:58–118  ·  view source on GitHub ↗
(
	ctx context.Context,
	subdomain,
	nhostfolder,
	hasuraVersion string,
	exrtaArgs ...string,
)

Source from the content-addressed store, hash-verified

56}
57
58func (d *Docker) HasuraWrapper(
59 ctx context.Context,
60 subdomain,
61 nhostfolder,
62 hasuraVersion string,
63 exrtaArgs ...string,
64) error {
65 absPath, err := filepath.Abs(nhostfolder)
66 if err != nil {
67 return fmt.Errorf("failed to get absolute path: %w", err)
68 }
69
70 args := []string{
71 "run",
72 "-v", absPath + ":/app",
73 "-e", "HASURA_GRAPHQL_ENABLE_TELEMETRY=false",
74 "-w", "/app",
75 "-it", "--rm",
76 "--entrypoint", "hasura-cli",
77 }
78
79 for _, host := range extraHosts(subdomain) {
80 args = append(args, "--add-host", host)
81 }
82
83 args = append(
84 args,
85 fmt.Sprintf("nhost/graphql-engine:%s.cli-migrations-v3", hasuraVersion),
86 )
87
88 cmd := exec.CommandContext( //nolint:gosec
89 ctx,
90 "docker",
91 append(args, exrtaArgs...)...,
92 )
93
94 f, err := pty.Start(cmd)
95 if err != nil {
96 return fmt.Errorf("failed to start pty: %w", err)
97 }
98 defer f.Close()
99
100 cleanup := setupInteractiveTerminal(f)
101 defer cleanup()
102
103 go func() {
104 _, _ = io.Copy(f, os.Stdin)
105 }()
106
107 if n, err := io.Copy(os.Stdout, f); err != nil {
108 var pathError *fs.PathError
109 switch {
110 case errors.As(err, &pathError) && n > 0 && pathError.Op == op:
111 return nil
112 default:
113 return fmt.Errorf("failed to copy pty output: %w", err)
114 }
115 }

Callers 4

deployFunction · 0.95
upFunction · 0.95
cloudFunction · 0.95
commandHasuraFunction · 0.95

Calls 6

extraHostsFunction · 0.85
setupInteractiveTerminalFunction · 0.85
cleanupFunction · 0.85
ErrorfMethod · 0.80
StartMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected