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

Function hasHookExecuted

pkg/devspace/hook/remote_command.go:96–117  ·  view source on GitHub ↗
(ctx context.Context, command string, args []string, podContainer *selector.SelectedPodContainer, client kubectl.Client)

Source from the content-addressed store, hash-verified

94}
95
96func hasHookExecuted(ctx context.Context, command string, args []string, podContainer *selector.SelectedPodContainer, client kubectl.Client) (bool, error) {
97 cmdHash := commandHash(command, args)
98 cmd := []string{"test", "-e", fmt.Sprintf(`/tmp/hook-%s`, cmdHash)}
99 stdout := new(bytes.Buffer)
100 stderr := new(bytes.Buffer)
101
102 err := client.ExecStream(ctx, &kubectl.ExecStreamOptions{
103 Pod: podContainer.Pod,
104 Container: podContainer.Container.Name,
105 Command: cmd,
106 Stdout: stdout,
107 Stderr: stderr,
108 })
109 if err != nil {
110 if errors.As(err, &exec.CodeExitError{}) {
111 return false, nil
112 }
113 return false, err
114 }
115
116 return true, nil
117}
118
119func recordHookExecuted(ctx context.Context, command string, args []string, podContainer *selector.SelectedPodContainer, client kubectl.Client) error {
120 cmdHash := commandHash(command, args)

Callers 1

ExecuteRemotelyMethod · 0.85

Calls 2

commandHashFunction · 0.85
ExecStreamMethod · 0.65

Tested by

no test coverage detected