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

package main

import "fmt"

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

type TrivyAction struct{}

// Runs the aquasecurity/trivy-action GitHub Action.
func (_ *TrivyAction) 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,
	// input artifact type (image, fs, repo, archive) for SBOM generation
	// +optional=true
	artifactType string,
	// specify where the cache is stored
	// +optional=true
	cacheDir string,
	// exit code when vulnerabilities were found
	// +optional=true
	exitCode string,
	// output format (table, json, template)
	// +optional=true
	// +default=table
	format string,
	// GitHub Personal Access Token (PAT) for submitting SBOM to GitHub Dependency Snapshot API
	// +optional=true
	githubPat string,
	// hide progress output
	// +optional=true
	hideProgress string,
	// filter vulnerabilities with OPA rego language
	// +optional=true
	ignorePolicy string,
	// ignore unfixed vulnerabilities
	// +optional=true
	// +default=false
	ignoreUnfixed string,
	// image reference(for backward compatibility)
	// +optional=true
	imageRef string,
	// reference of tar file to scan
	// +optional=true
	input string,
	// limit severities for SARIF format
	// +optional=true
	limitSeveritiesForSarif string,
	// output all packages regardless of vulnerability
	// +optional=true
	// +default=false
	listAllPkgs string,
	// writes results to a file with the specified file name
	// +optional=true
	output string,
	// Scan reference
	// +optional=true
	// +default=.
	scanRef string,
	// Scan type to use for scanning vulnerability
	// +optional=true
	// +default=image
	scanType string,
	// comma-separated list of what security issues to detect
	// +optional=true
	scanners string,
	// severities of vulnerabilities to be displayed
	// +optional=true
	// +default=UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
	severity string,
	// comma separated list of directories where traversal is skipped
	// +optional=true
	skipDirs string,
	// comma separated list of files to be skipped
	// +optional=true
	skipFiles string,
	// use an existing template for rendering output (@/contrib/gitlab.tpl, @/contrib/junit.tpl, @/contrib/html.tpl)
	// +optional=true
	template string,
	// path to terraform tfvars file
	// +optional=true
	tfVars string,
	// timeout (default 5m0s)
	// +optional=true
	timeout string,
	// path to trivy.yaml config
	// +optional=true
	trivyConfig string,
	// comma-separated list of relative paths in repository to one or more .trivyignore files
	// +optional=true
	trivyignores string,
	// comma-separated list of vulnerability types (os,library)
	// +optional=true
	// +default=os,library
	vulnType string,
) *Container {
	return dag.Gale(toGaleOpts(source, repo, tag, branch)).
		Action("aquasecurity/trivy-action@master", toGaleActionOpts(artifactType, cacheDir, exitCode, format, githubPat, hideProgress, ignorePolicy, ignoreUnfixed, imageRef, input, limitSeveritiesForSarif, listAllPkgs, output, scanRef, scanType, scanners, severity, skipDirs, skipFiles, template, tfVars, timeout, trivyConfig, trivyignores, vulnType)).
		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(
	artifactType string,
	cacheDir string,
	exitCode string,
	format string,
	githubPat string,
	hideProgress string,
	ignorePolicy string,
	ignoreUnfixed string,
	imageRef string,
	input string,
	limitSeveritiesForSarif string,
	listAllPkgs string,
	output string,
	scanRef string,
	scanType string,
	scanners string,
	severity string,
	skipDirs string,
	skipFiles string,
	template string,
	tfVars string,
	timeout string,
	trivyConfig string,
	trivyignores string,
	vulnType string,
) GaleActionOpts {
	return GaleActionOpts{
		With: []string{
			fmt.Sprintf("artifact-type=%s", artifactType),
			fmt.Sprintf("cache-dir=%s", cacheDir),
			fmt.Sprintf("exit-code=%s", exitCode),
			fmt.Sprintf("format=%s", format),
			fmt.Sprintf("github-pat=%s", githubPat),
			fmt.Sprintf("hide-progress=%s", hideProgress),
			fmt.Sprintf("ignore-policy=%s", ignorePolicy),
			fmt.Sprintf("ignore-unfixed=%s", ignoreUnfixed),
			fmt.Sprintf("image-ref=%s", imageRef),
			fmt.Sprintf("input=%s", input),
			fmt.Sprintf("limit-severities-for-sarif=%s", limitSeveritiesForSarif),
			fmt.Sprintf("list-all-pkgs=%s", listAllPkgs),
			fmt.Sprintf("output=%s", output),
			fmt.Sprintf("scan-ref=%s", scanRef),
			fmt.Sprintf("scan-type=%s", scanType),
			fmt.Sprintf("scanners=%s", scanners),
			fmt.Sprintf("severity=%s", severity),
			fmt.Sprintf("skip-dirs=%s", skipDirs),
			fmt.Sprintf("skip-files=%s", skipFiles),
			fmt.Sprintf("template=%s", template),
			fmt.Sprintf("tf-vars=%s", tfVars),
			fmt.Sprintf("timeout=%s", timeout),
			fmt.Sprintf("trivy-config=%s", trivyConfig),
			fmt.Sprintf("trivyignores=%s", trivyignores),
			fmt.Sprintf("vuln-type=%s", vulnType),
		},
	}
}
