func (p *Plugin) Exec(ctx context.Context, args []string) error {
	// Prepare env so plugin has Dir available
	p.setDirInEnv()
	main, cmdArgs, err := p.MetaData.Command.Prepare()
	if err != nil {
		return fmt.Errorf("plugin exec prepare: %w", err)
	}

	execArgs := append(cmdArgs, args...)
	cmd := exec.CommandContext(ctx, main, execArgs...)
	cmd.Stdin = p.stdIn
	cmd.Stdout = p.stdOut
	cmd.Stderr = p.stdErr
	cmd.Env = p.env

	if err = cmd.Run(); err != nil {
		// Check for a 1 exit status to check if it is a conftest test failure
		if exiterr, ok := err.(*exec.ExitError); ok {
			if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
				if status.ExitStatus() == 1 {
					return nil
				}

				return fmt.Errorf("plugin exec: %w", err)
			}
		}

		return fmt.Errorf("plugin exec: %w", err)
	}

	return nil
}
// Exec executes the plugin command
Exec executes the plugin command
// Exec executes the plugin command
func (p *Plugin) Exec(ctx context.Context, args []string) error {
	p.setDirInEnv()
	main, cmdArgs, err := p.MetaData.Command.Prepare()
	if err != nil {
		return fmt.Errorf("plugin exec prepare: %w", err)
	}
	execArgs := append(cmdArgs, args...)
	cmd := exec.CommandContext(ctx, main, execArgs...)
	cmd.Stdin = p.stdIn
	cmd.Stdout = p.stdOut
	cmd.Stderr = p.stdErr
	cmd.Env = p.env
	if err = cmd.Run(); err != nil {
		if exiterr, ok := err.(*exec.ExitError); ok {
			if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
				if status.ExitStatus() == 1 {
					return nil
				}
				return fmt.Errorf("plugin exec: %w", err)
			}
		}
		return fmt.Errorf("plugin exec: %w", err)
	}
	return nil
}
func ( p * Plugin ) Exec ( ctx context . Context , args [ ] string ) error { p . setDirInEnv ( ) main , cmdArgs , err := p . MetaData . Command . Prepare ( ) if err != nil { return fmt . Errorf ( " " , err ) } execArgs := append ( cmdArgs , args ... ) cmd := exec . CommandContext ( ctx , main , execArgs ... ) cmd . Stdin = p . stdIn cmd . Stdout = p . stdOut cmd . Stderr = p . stdErr cmd . Env = p . env if err = cmd . Run ( ) ; err != nil { if exiterr , ok := err . ( * exec . ExitError ) ; ok { if status , ok := exiterr . Sys ( ) . ( syscall . WaitStatus ) ; ok { if status . ExitStatus ( ) == 1 { return nil } return fmt . Errorf ( " " , err ) } } return fmt . Errorf ( " " , err ) } return nil }
Exec executes the plugin command
Exec executes the plugin command
// Prepare env so plugin has Dir available // Check for a 1 exit status to check if it is a conftest test failure