(ctx context.Context, command string, args []string, podContainer *selector.SelectedPodContainer, client kubectl.Client)
| 94 | } |
| 95 | |
| 96 | func 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 | |
| 119 | func recordHookExecuted(ctx context.Context, command string, args []string, podContainer *selector.SelectedPodContainer, client kubectl.Client) error { |
| 120 | cmdHash := commandHash(command, args) |
no test coverage detected