// Code generated by actions-generator. DO NOT EDIT.

package main

import "fmt"

func New() *Trufflehog {
	return &Trufflehog{}
}

type Trufflehog struct{}

// Runs the trufflesecurity/trufflehog GitHub Action.
func (_ *Trufflehog) Run(
	// Directory containing the repository source. Takes precedence over `--repo`."
	// +optional=true
	source *Directory,
	// Repository name, format: owner/name.
	// +optional=true
	repo string,
	// Tag name to check out. Only works with `--repo`. Takes precedence over `--branch`.
	// +optional=true
	tag string,
	// Branch name to check out. Only works with `--repo`.
	// +optional=true
	branch string,
	// Container to use for the runner.
	// +optional=true
	container *Container,
	// Enables debug mode.
	// +optional=true
	// +default=false
	runnerDebug bool,
	// Start scanning from here (usually main branch).
	// +optional=true
	base string,
	// Extra args to be passed to the trufflehog cli.
	// +optional=true
	extraArgs string,
	// Scan commits until here (usually dev branch).
	// +optional=true
	head string,
	// Repository path
	// +optional=true
	// +default=./
	path string,
) *Container {
	return dag.Gale(toGaleOpts(source, repo, tag, branch)).
		Action("trufflesecurity/trufflehog@main", toGaleActionOpts(base, extraArgs, head, path)).
		Run(toGaleActionRunOpts(container, runnerDebug)).
		Sync()
}

// Converts the custom action inputs to Gale options.
func toGaleOpts(
	source *Directory,
	repo string,
	tag string,
	branch string,
) GaleOpts {
	return GaleOpts{
		Branch: branch,
		Repo:   repo,
		Source: source,
		Tag:    tag,
	}
}

// Converts the custom action inputs to Gale action run options.
func toGaleActionRunOpts(
	container *Container,
	debug bool,
) GaleActionsRunOpts {
	return GaleActionsRunOpts{
		Container:   container,
		RunnerDebug: debug,
	}
}

// Converts the custom action inputs to Gale action options.
func toGaleActionOpts(
	base string,
	extraArgs string,
	head string,
	path string,
) GaleActionOpts {
	return GaleActionOpts{
		With: []string{
			fmt.Sprintf("base=%s", base),
			fmt.Sprintf("extra_args=%s", extraArgs),
			fmt.Sprintf("head=%s", head),
			fmt.Sprintf("path=%s", path),
		},
	}
}
