Repository: GoogleContainerTools/kpt
Pull request #3676 (2022-11-29 11:37:22)

Bump minimatch from 3.0.4 to 3.1.2 in /site
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/isaacs/minimatch/commit/699c459443a6bd98f5b28197978f76e7f71467ac"><code>699c459</code></a> 3.1.2</li>
<li><a href="https://github.com/isaacs/minimatch/commit/2f2b5ff1bb1b6a01f4404f7e475f0a2cba578ab7"><code>2f2b5ff</code></a> fix: trim pattern</li>
<li><a href="https://github.com/isaacs/minimatch/commit/25d7c0d09c47063c9b0d2ace17ef8e951d90eccc"><code>25d7c0d</code></a> 3.1.1</li>
<li><a href="https://github.com/isaacs/minimatch/commit/55dda291dfb595bd11b4edb19b45dd98eda76de0"><code>55dda29</code></a> fix: treat nocase:true as always having magic</li>
<li><a href="https://github.com/isaacs/minimatch/commit/5e1fb8dd2bb78c0ae22101b9229fac4c76ef039e"><code>5e1fb8d</code></a> 3.1.0</li>
<li><a href="https://github.com/isaacs/minimatch/commit/f8145c54f34075069f4a23cb214d871da4cd4006"><code>f8145c5</code></a> Add 'allowWindowsEscape' option</li>
<li><a href="https://github.com/isaacs/minimatch/commit/570e8b1aef6c9e823a824aa0b9be10db43857cd7"><code>570e8b1</code></a> add publishConfig for v3 publishes</li>
<li><a href="https://github.com/isaacs/minimatch/commit/5b7cd3372be253759fb4d865eb3f38f189a5fcdf"><code>5b7cd33</code></a> 3.0.6</li>
<li><a href="https://github.com/isaacs/minimatch/commit/20b4b562830680867feb75f9c635aca08e5c86ff"><code>20b4b56</code></a> [fix] revert all breaking syntax changes</li>
<li><a href="https://github.com/isaacs/minimatch/commit/2ff038852ec03e85e60e0eb333005c680ac8a543"><code>2ff0388</code></a> document, expose, and test 'partial:true' option</li>
<li>Additional commits viewable in <a href="https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=minimatch&package-manager=npm_and_yarn&previous-version=3.0.4&new-version=3.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/GoogleContainerTools/kpt/network/alerts).

</details>


Patch:
diff --git a/Formula/kpt.rb b/Formula/kpt.rb
index 2bd485c4..abec1223 100644
--- a/Formula/kpt.rb
+++ b/Formula/kpt.rb
@@ -15,8 +15,8 @@
 class Kpt < Formula
   desc "Toolkit to manage,and apply Kubernetes Resource config data files"
   homepage "https://googlecontainertools.github.io/kpt"
-  url "https://github.com/GoogleContainerTools/kpt/archive/v1.0.0-beta.23.tar.gz"
-  sha256 "45c34e7f6fb8246dbe1b35769d988fe18c64d668b2fba747d45fd1e22eacf99b"
+  url "https://github.com/GoogleContainerTools/kpt/archive/v1.0.0-beta.24.tar.gz"
+  sha256 "84d7389316f6915aea6e017cfe0b9425f1676ba6c41c2538b123e2d494b681f6"
 
   depends_on "go" => :build
 
diff --git a/internal/errors/resolver/git.go b/internal/errors/resolver/git.go
index 877ceca6..11e8903f 100644
--- a/internal/errors/resolver/git.go
+++ b/internal/errors/resolver/git.go
@@ -27,50 +27,6 @@ func init() {
 	AddErrorResolver(&gitExecErrorResolver{})
 }
 
-const (
-	genericGitExecError = `
-Error: Failed to execute git command {{ printf "%q " .gitcmd }}
-{{- if gt (len .repo) 0 -}}
-against repo {{ printf "%q " .repo }}
-{{- end }}
-{{- if gt (len .ref) 0 -}}
-for reference {{ printf "%q " .ref }}
-{{- end }}
-
-{{- template "ExecOutputDetails" . }}
-`
-
-	unknownRefGitExecError = `
-Error: Unknown ref {{ printf "%q" .ref }}. Please verify that the reference exists in upstream repo {{ printf "%q" .repo }}.
-
-{{- template "ExecOutputDetails" . }}
-`
-
-	noGitBinaryError = `
-Error: No git executable found. kpt requires git to be installed and available in the path.
-
-{{- template "ExecOutputDetails" . }}
-`
-
-	httpsAuthRequired = `
-Error: Repository {{ printf "%q" .repo }} requires authentication. kpt does not support this for the 'https' protocol. Please use the 'git' protocol instead.
-
-{{- template "ExecOutputDetails" . }}
-`
-
-	repositoryUnavailable = `
-Error: Unable to access repository {{ printf "%q" .repo }}.
-
-{{- template "ExecOutputDetails" . }}
-`
-
-	repositoryNotFound = `
-Error: Repository {{ printf "%q" .repo }} not found.
-
-{{- template "ExecOutputDetails" . }}
-`
-)
-
 // gitExecErrorResolver is an implementation of the ErrorResolver interface
 // that can produce error messages for errors of the gitutil.GitExecError type.
 type gitExecErrorResolver struct{}
@@ -82,29 +38,55 @@ func (*gitExecErrorResolver) Resolve(err error) (ResolvedResult, bool) {
 	}
 	fullCommand := fmt.Sprintf("git %s %s", gitExecErr.Command,
 		strings.Join(gitExecErr.Args, " "))
-	tmplArgs := map[string]interface{}{
-		"gitcmd": fullCommand,
-		"repo":   gitExecErr.Repo,
-		"ref":    gitExecErr.Ref,
-		"stdout": gitExecErr.StdOut,
-		"stderr": gitExecErr.StdErr,
-	}
+
 	var msg string
 	switch gitExecErr.Type {
 	case gitutil.UnknownReference:
-		msg = ExecuteTemplate(unknownRefGitExecError, tmplArgs)
+		msg = fmt.Sprintf("Error: Unknown ref %q. Please verify that the reference exists in upstream repo %q.", gitExecErr.Ref, gitExecErr.Repo)
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
+
 	case gitutil.GitExecutableNotFound:
-		msg = ExecuteTemplate(noGitBinaryError, tmplArgs)
+		msg = "Error: No git executable found. kpt requires git to be installed and available in the path."
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
+
 	case gitutil.HTTPSAuthRequired:
-		msg = ExecuteTemplate(httpsAuthRequired, tmplArgs)
+		msg = fmt.Sprintf("Error: Repository %q requires authentication.", gitExecErr.Repo)
+		msg += " kpt does not support this for the 'https' protocol."
+		msg += " Please use the 'git' protocol instead."
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
+
 	case gitutil.RepositoryUnavailable:
-		msg = ExecuteTemplate(repositoryUnavailable, tmplArgs)
+		msg = fmt.Sprintf("Error: Unable to access repository %q.", gitExecErr.Repo)
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
+
 	case gitutil.RepositoryNotFound:
-		msg = ExecuteTemplate(repositoryNotFound, tmplArgs)
+		msg = fmt.Sprintf("Error: Repository %q not found.", gitExecErr.Repo)
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
 	default:
-		msg = ExecuteTemplate(genericGitExecError, tmplArgs)
+		msg = fmt.Sprintf("Error: Failed to execute git command %q", fullCommand)
+		if gitExecErr.Repo != "" {
+			msg += fmt.Sprintf(" against repo %q", gitExecErr.Repo)
+		}
+		if gitExecErr.Ref != "" {
+			msg += fmt.Sprintf(" for reference %q", gitExecErr.Ref)
+		}
+		msg = msg + "\n" + BuildOutputDetails(gitExecErr.StdOut, gitExecErr.StdErr)
 	}
 	return ResolvedResult{
 		Message: msg,
 	}, true
 }
+
+func BuildOutputDetails(stdout string, stderr string) string {
+	var sb strings.Builder
+	if len(stdout) > 0 || len(stderr) > 0 {
+		sb.WriteString("\nDetails:\n")
+	}
+	if len(stdout) > 0 {
+		sb.WriteString(stdout)
+	}
+	if len(stderr) > 0 {
+		sb.WriteString(stderr)
+	}
+	return sb.String()
+}
diff --git a/internal/errors/resolver/live.go b/internal/errors/resolver/live.go
index ce70321c..a715e5f2 100644
--- a/internal/errors/resolver/live.go
+++ b/internal/errors/resolver/live.go
@@ -15,6 +15,8 @@
 package resolver
 
 import (
+	"fmt"
+
 	initialization "github.com/GoogleContainerTools/kpt/commands/live/init"
 	"github.com/GoogleContainerTools/kpt/internal/cmdutil"
 	"github.com/GoogleContainerTools/kpt/internal/errors"
@@ -45,14 +47,6 @@ Error: Package has multiple inventory object templates.
 The package should have one and only one inventory object template.
 `
 
-	resourceGroupCRDInstallErrorMsg = `
-Error: Unable to install the ResourceGroup CRD.
-
-{{- if gt (len .cause) 0 }}
-{{ printf "\nDetails:" }}
-{{ printf "%s" .cause }}
-{{- end }}
-`
 	//nolint:lll
 	noResourceGroupCRDMsg = `
 Error: The ResourceGroup CRD was not found in the cluster. Please install it either by using the '--install-resource-group' flag or the 'kpt live install-resource-group' command.
@@ -75,25 +69,6 @@ Error: Inventory information has already been added to the package Kptfile objec
 
 	multipleResourceGroupsMsg = `
 Error: Multiple ResourceGroup objects found. Please make sure at most one ResourceGroup object exists within the package.
-`
-
-	//nolint:lll
-	inventoryInfoValidationMsg = `
-Error: The inventory information is not valid. Please update the information in the ResourceGroup file or provide information with the command line flags. To generate the inventory information the first time, use the 'kpt live init' command.
-
-Details:
-{{- range .err.Violations}}
-{{printf "%s" .Reason }}
-{{- end}}
-`
-
-	unknownTypesMsg = `
-Error: {{ printf "%d" (len .err.GroupVersionKinds) }} resource types could not be found in the cluster or as CRDs among the applied resources.
-
-Resource types:
-{{- range .err.GroupVersionKinds}}
-{{ printf "%s" .String }}
-{{- end}}
 `
 )
 
@@ -104,92 +79,79 @@ type liveErrorResolver struct{}
 func (*liveErrorResolver) Resolve(err error) (ResolvedResult, bool) {
 	var noInventoryObjError *inventory.NoInventoryObjError
 	if errors.As(err, &noInventoryObjError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(noInventoryObjErrorMsg, map[string]interface{}{
-				"err": *noInventoryObjError,
-			}),
-		}, true
+		msg := noInventoryObjErrorMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var multipleInventoryObjError *inventory.MultipleInventoryObjError
 	if errors.As(err, &multipleInventoryObjError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(multipleInventoryObjErrorMsg, map[string]interface{}{
-				"err": *multipleInventoryObjError,
-			}),
-		}, true
+		msg := multipleInventoryObjErrorMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var resourceGroupCRDInstallError *cmdutil.ResourceGroupCRDInstallError
 	if errors.As(err, &resourceGroupCRDInstallError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(resourceGroupCRDInstallErrorMsg, map[string]interface{}{
-				"cause": resourceGroupCRDInstallError.Err.Error(),
-			}),
-		}, true
+		msg := "Error: Unable to install the ResourceGroup CRD."
+
+		cause := resourceGroupCRDInstallError.Err
+		msg += fmt.Sprintf("\nDetails: %v", cause)
+
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var noResourceGroupCRDError *cmdutil.NoResourceGroupCRDError
 	if errors.As(err, &noResourceGroupCRDError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(noResourceGroupCRDMsg, map[string]interface{}{
-				"err": *noResourceGroupCRDError,
-			}),
-		}, true
+		msg := noResourceGroupCRDMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var invExistsError *initialization.InvExistsError
 	if errors.As(err, &invExistsError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(invInfoAlreadyExistsMsg, map[string]interface{}{
-				"err": *invExistsError,
-			}),
-		}, true
+		msg := invInfoAlreadyExistsMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var invInfoInRGAlreadyExistsError *initialization.InvInRGExistsError
 	if errors.As(err, &invInfoInRGAlreadyExistsError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(invInfoInRGAlreadyExistsMsg, map[string]interface{}{
-				"err": *invInfoInRGAlreadyExistsError,
-			}),
-		}, true
+		msg := invInfoInRGAlreadyExistsMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var invInKfExistsError *initialization.InvInKfExistsError
 	if errors.As(err, &invInKfExistsError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(invInfoInKfAlreadyExistsMsg, map[string]interface{}{
-				"err": *invInKfExistsError,
-			}),
-		}, true
+		msg := invInfoInKfAlreadyExistsMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var multipleResourceGroupsError *pkg.MultipleResourceGroupsError
 	if errors.As(err, &multipleResourceGroupsError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(multipleResourceGroupsMsg, map[string]interface{}{
-				"err": *multipleResourceGroupsError,
-			}),
-		}, true
+		msg := multipleResourceGroupsMsg
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var inventoryInfoValidationError *live.InventoryInfoValidationError
 	if errors.As(err, &inventoryInfoValidationError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(inventoryInfoValidationMsg, map[string]interface{}{
-				"err": *inventoryInfoValidationError,
-			}),
-		}, true
+		msg := "Error: The inventory information is not valid."
+		msg += " Please update the information in the ResourceGroup file or provide information with the command line flags."
+		msg += " To generate the inventory information the first time, use the 'kpt live init' command."
+
+		msg += "\nDetails:\n"
+		for _, v := range inventoryInfoValidationError.Violations {
+			msg += fmt.Sprintf("%s\n", v.Reason)
+		}
+
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var unknownTypesError *manifestreader.UnknownTypesError
 	if errors.As(err, &unknownTypesError) {
-		return ResolvedResult{
-			Message: ExecuteTemplate(unknownTypesMsg, map[string]interface{}{
-				"err": *unknownTypesError,
-			}),
-		}, true
+		msg := fmt.Sprintf("Error: %d resource types could not be found in the cluster or as CRDs among the applied resources.", len(unknownTypesError.GroupVersionKinds))
+		msg += "\n\nResource types:\n"
+		for _, gvk := range unknownTypesError.GroupVersionKinds {
+			msg += fmt.Sprintf("%s\n", gvk)
+		}
+
+		return ResolvedResult{Message: msg}, true
 	}
 
 	var resultError *common.ResultError
diff --git a/internal/errors/resolver/pkg.go b/internal/errors/resolver/pkg.go
index 63e17a85..71592aa2 100644
--- a/internal/errors/resolver/pkg.go
+++ b/internal/errors/resolver/pkg.go
@@ -15,6 +15,7 @@
 package resolver
 
 import (
+	"fmt"
 	"os"
 
 	"github.com/GoogleContainerTools/kpt/internal/errors"
@@ -27,33 +28,6 @@ func init() {
 	AddErrorResolver(&pkgErrorResolver{})
 }
 
-const (
-	noKptfileMsg = `
-Error: No Kptfile found at {{ printf "%q" .path }}.
-`
-
-	//nolint:lll
-	deprecatedv1Alpha1KptfileMsg = `
-Error: Kptfile at {{ printf "%q" .path }} has an old version ({{ printf "%q" .version }}) of the Kptfile schema.
-Please update the package to the latest format by following https://kpt.dev/installation/migration.
-`
-
-	deprecatedv1Alpha2KptfileMsg = `
-Error: Kptfile at {{ printf "%q" .path }} has an old version ({{ printf "%q" .version }}) of the Kptfile schema.
-Please run "kpt fn eval <PKG_PATH> -i gcr.io/kpt-fn/fix:v0.2 --include-meta-resources" to upgrade the package and retry.
-`
-
-	unknownKptfileResourceMsg = `
-Error: Kptfile at {{ printf "%q" .path }} has an unknown resource type ({{ printf "%q" .gvk.String }}).
-`
-
-	kptfileReadErrMsg = `
-Error: Kptfile at {{ printf "%q" .path }} can't be read.
-
-{{- template "NestedErrDetails" . }}
-`
-)
-
 // pkgErrorResolver is an implementation of the ErrorResolver interface
 // that can produce error messages for errors of the pkg.KptfileError type.
 type pkgErrorResolver struct{}
@@ -62,22 +36,15 @@ func (*pkgErrorResolver) Resolve(err error) (ResolvedResult, bool) {
 	var kptfileError *pkg.KptfileError
 	if errors.As(err, &kptfileError) {
 		path := kptfileError.Path
-		tmplArgs := map[string]interface{}{
-			"path": path,
-			"err":  kptfileError,
-		}
 
-		return resolveNestedErr(kptfileError, tmplArgs)
+		return resolveNestedErr(kptfileError, path.String())
 	}
 
 	var remoteKptfileError *pkg.RemoteKptfileError
 	if errors.As(err, &remoteKptfileError) {
 		path := remoteKptfileError.RepoSpec.RepoRef()
-		tmplArgs := map[string]interface{}{
-			"path": path,
-			"err":  kptfileError,
-		}
-		return resolveNestedErr(remoteKptfileError, tmplArgs)
+
+		return resolveNestedErr(remoteKptfileError, path)
 	}
 
 	var validateError *kptfile.ValidateError
@@ -90,42 +57,58 @@ func (*pkgErrorResolver) Resolve(err error) (ResolvedResult, bool) {
 	return ResolvedResult{}, false
 }
 
-func resolveNestedErr(err error, tmplArgs map[string]interface{}) (ResolvedResult, bool) {
+func resolveNestedErr(err error, path string) (ResolvedResult, bool) {
 	if errors.Is(err, os.ErrNotExist) {
+		msg := fmt.Sprintf("Error: No Kptfile found at %q.", path)
+
 		return ResolvedResult{
-			Message: ExecuteTemplate(noKptfileMsg, tmplArgs),
+			Message: msg,
 		}, true
 	}
 
 	var deprecatedv1alpha1KptfileError *pkg.DeprecatedKptfileError
 	if errors.As(err, &deprecatedv1alpha1KptfileError) &&
 		deprecatedv1alpha1KptfileError.Version == "v1alpha1" {
-		tmplArgs["version"] = deprecatedv1alpha1KptfileError.Version
-		errMsg := deprecatedv1Alpha1KptfileMsg
+		msg := fmt.Sprintf("Error: Kptfile at %q has an old version (%q) of the Kptfile schema.\n", path, deprecatedv1alpha1KptfileError.Version)
+		msg += "Please update the package to the latest format by following https://kpt.dev/installation/migration."
+
 		return ResolvedResult{
-			Message: ExecuteTemplate(errMsg, tmplArgs),
+			Message: msg,
 		}, true
 	}
 
 	var deprecatedv1alpha2KptfileError *pkg.DeprecatedKptfileError
 	if errors.As(err, &deprecatedv1alpha2KptfileError) &&
-		deprecatedv1alpha1KptfileError.Version == "v1alpha2" {
-		tmplArgs["version"] = deprecatedv1alpha2KptfileError.Version
-		errMsg := deprecatedv1Alpha2KptfileMsg
+		deprecatedv1alpha2KptfileError.Version == "v1alpha2" {
+		msg := fmt.Sprintf("Error: Kptfile at %q has an old version (%q) of the Kptfile schema.\n", path, deprecatedv1alpha2KptfileError.Version)
+		msg += "Please run \"kpt fn eval <PKG_PATH> -i gcr.io/kpt-fn/fix:v0.2 --include-meta-resources\" to upgrade the package and retry."
+
 		return ResolvedResult{
-			Message: ExecuteTemplate(errMsg, tmplArgs),
+			Message: msg,
 		}, true
 	}
 
 	var unknownKptfileResourceError *pkg.UnknownKptfileResourceError
 	if errors.As(err, &unknownKptfileResourceError) {
-		tmplArgs["gvk"] = unknownKptfileResourceError.GVK
+		msg := fmt.Sprintf("Error: Kptfile at %q has an unknown resource type (%q).", path, unknownKptfileResourceError.GVK.String())
 		return ResolvedResult{
-			Message: ExecuteTemplate(unknownKptfileResourceMsg, tmplArgs),
+			Message: msg,
 		}, true
 	}
 
+	msg := fmt.Sprintf("Error: Kptfile at %q can't be read.", path)
+	if err != nil {
+		var kptFileError *pkg.KptfileError
+		if errors.As(err, &kptFileError) {
+			if kptFileError.Err != nil {
+				msg += fmt.Sprintf("\n\nDetails:\n%v", kptFileError.Err)
+			}
+		} else {
+			msg += fmt.Sprintf("\n\nDetails:\n%v", err)
+		}
+	}
+
 	return ResolvedResult{
-		Message: ExecuteTemplate(kptfileReadErrMsg, tmplArgs),
+		Message: msg,
 	}, true
 }
diff --git a/internal/errors/resolver/template.go b/internal/errors/resolver/template.go
deleted file mode 100644
index 7ad186e2..00000000
--- a/internal/errors/resolver/template.go
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package resolver
-
-import (
-	"bytes"
-	"fmt"
-	"strings"
-	"text/template"
-)
-
-var baseTemplate = func() *template.Template {
-	tmpl := template.New("base")
-	tmpl = template.Must(tmpl.Parse(detailsHelperTemplate))
-	tmpl = template.Must(tmpl.Parse(nestedErrTemplate))
-	return tmpl
-}()
-
-var (
-	// detailsHelperTemplate is a helper subtemplate that is available to
-	// the top-level templates. It is useful when including information from
-	// execing other commands in the error message.
-	detailsHelperTemplate = `
-{{- define "ExecOutputDetails" }}
-{{- if or (gt (len .stdout) 0) (gt (len .stderr) 0)}}
-{{ printf "\nDetails:" }}
-{{- end }}
-
-{{- if gt (len .stdout) 0 }}
-{{ printf "%s" .stdout }}
-{{- end }}
-
-{{- if gt (len .stderr) 0 }}
-{{ printf "%s" .stderr }}
-{{- end }}
-{{ end }}
-`
-
-	// nestedErrTemplate is a helper subtemplate for printing details from
-	// a nested error.
-	nestedErrTemplate = `
-{{- define "NestedErrDetails" }}
-{{- if .err  }}
-{{- if .err.Err }}
-{{- if gt (len .err.Err.Error) 0 }}
-{{ printf "\nDetails:" }}
-{{ printf "%s" .err.Err.Error }}
-{{- end }}
-{{- end }}
-{{- end }}
-{{ end }}
-`
-)
-
-// ExecuteTemplate takes the provided template string and data, and renders
-// the template. If something goes wrong, it panics.
-func ExecuteTemplate(text string, data interface{}) string {
-	tmpl := template.Must(baseTemplate.Clone())
-	template.Must(tmpl.Parse(text))
-
-	var b bytes.Buffer
-	execErr := tmpl.Execute(&b, data)
-	if execErr != nil {
-		panic(fmt.Errorf("error executing template: %w", execErr))
-	}
-	return strings.TrimSpace(b.String())
-}
diff --git a/internal/errors/resolver/update.go b/internal/errors/resolver/update.go
index f5f17374..6b43e3ec 100644
--- a/internal/errors/resolver/update.go
+++ b/internal/errors/resolver/update.go
@@ -15,6 +15,8 @@
 package resolver
 
 import (
+	"fmt"
+
 	"github.com/GoogleContainerTools/kpt/internal/errors"
 	"github.com/GoogleContainerTools/kpt/internal/util/update"
 )
@@ -24,17 +26,6 @@ func init() {
 	AddErrorResolver(&updateErrorResolver{})
 }
 
-var (
-	//nolint:lll
-	pkgNotGitRepo = `
-Package {{ printf "%q" .repo }} is not within a git repository. Please initialize a repository using 'git init' and then commit the changes using 'git commit -m "<commit message>"'.
-`
-
-	pkgRepoDirty = `
-Package {{ printf "%q" .repo }} contains uncommitted changes. Please commit the changes using 'git commit -m "<commit message>"'.
-`
-)
-
 // updateErrorResolver is an implementation of the ErrorResolver interface
 // to resolve update errors.
 type updateErrorResolver struct{}
@@ -44,16 +35,15 @@ func (*updateErrorResolver) Resolve(err error) (ResolvedResult, bool) {
 
 	var pkgNotGitRepoError *update.PkgNotGitRepoError
 	if errors.As(err, &pkgNotGitRepoError) {
-		msg = ExecuteTemplate(pkgNotGitRepo, map[string]interface{}{
-			"repo": pkgNotGitRepoError.Path,
-		})
+		//nolint:lll
+		msg = fmt.Sprintf("Package %q is not within a git repository.", pkgNotGitRepoError.Path)
+		msg += " Please initialize a repository using 'git init' and then commit the changes using 'git commit -m \"<commit message>\"'."
 	}
 
 	var pkgRepoDirtyError *update.PkgRepoDirtyError
 	if errors.As(err, &pkgRepoDirtyError) {
-		msg = ExecuteTemplate(pkgRepoDirty, map[string]interface{}{
-			"repo": pkgRepoDirtyError.Path,
-		})
+		msg = fmt.Sprintf("Package %q contains uncommitted changes.", pkgRepoDirtyError.Path)
+		msg += " Please commit the changes using 'git commit -m \"<commit message>\"'."
 	}
 
 	if msg != "" {
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 3e553fa7..7f9736df 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -64,7 +64,7 @@ type KptfileError struct {
 }
 
 func (k *KptfileError) Error() string {
-	return fmt.Sprintf("error reading Kptfile at %q: %s", k.Path.String(), k.Err.Error())
+	return fmt.Sprintf("error reading Kptfile at %q: %v", k.Path.String(), k.Err)
 }
 
 func (k *KptfileError) Unwrap() error {
diff --git a/porch/Makefile b/porch/Makefile
index 9afa6cda..d241540c 100644
--- a/porch/Makefile
+++ b/porch/Makefile
@@ -135,7 +135,7 @@ tidy:
 
 .PHONY: test
 test:
-	@for f in $(MODULES); do (cd $$f; echo "Testing $$f"; E2E=1 go test --count=1 ./...) || exit 1; done
+	@for f in $(MODULES); do (cd $$f; echo "Testing $$f"; E2E=1 go test -race --count=1 ./...) || exit 1; done
 
 .PHONY: vet
 vet:
diff --git a/release/formula/main.go b/release/formula/main.go
index fdb4af1e..f534e133 100644
--- a/release/formula/main.go
+++ b/release/formula/main.go
@@ -15,103 +15,84 @@
 package main
 
 import (
-	"bytes"
+	"context"
+	"crypto/sha256"
+	"encoding/hex"
 	"fmt"
+	"hash"
 	"io"
 	"net/http"
 	"os"
-	"os/exec"
 	"path/filepath"
 	"strings"
-	"text/template"
 )
 
 func main() {
-	if len(os.Args) < 2 {
-		fmt.Fprintf(os.Stderr, "must specify new version\n")
-		os.Exit(1)
-	}
-	input := Input{Version: os.Args[1]}
-	var err error
-	input.Sha, err = getSha(input.Version)
+	err := run(context.Background())
 	if err != nil {
+		fmt.Fprintf(os.Stderr, "%v\n", err)
 		os.Exit(1)
 	}
+}
 
-	// generate the formula text
-	t, err := template.New("formula").Parse(formula)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
-		os.Exit(1)
+func run(ctx context.Context) error {
+	if len(os.Args) < 2 {
+		return fmt.Errorf("must specify new version")
 	}
 
-	// write the new formula
-	b := &bytes.Buffer{}
-	if err = t.Execute(b, input); err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
-		os.Exit(1)
+	version := os.Args[1]
+	url := "https://github.com/GoogleContainerTools/kpt/archive/" + version + ".tar.gz"
+
+	formula, err := buildFormula(http.DefaultClient, url)
+	if err != nil {
+		return err
 	}
 
-	err = os.WriteFile(filepath.Join("Formula", "kpt.rb"), b.Bytes(), 0644)
+	err = os.WriteFile(filepath.Join("Formula", "kpt.rb"), []byte(formula), 0644)
 	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
-		os.Exit(1)
+		return err
 	}
+	return nil
 }
 
-func getSha(version string) (string, error) {
-	// create the dir for the data
-	d, err := os.MkdirTemp("", "kpt-bin")
+func buildFormula(httpClient *http.Client, url string) (string, error) {
+	sha256, err := hashURL(httpClient, url, sha256.New())
 	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
 		return "", err
 	}
-	defer os.RemoveAll(d)
 
-	fmt.Println(
-		"fetching https://github.com/GoogleContainerTools/kpt/archive/" + version + ".tar.gz")
+	// generate the formula text
+	formula := formulaTemplate
+	formula = strings.ReplaceAll(formula, "{{url}}", url)
+	formula = strings.ReplaceAll(formula, "{{sha256}}", sha256)
+
+	return formula, nil
+}
+
+func hashURL(httpClient *http.Client, url string, hasher hash.Hash) (string, error) {
+	fmt.Printf("fetching %q\n", url)
+
 	// get the content
-	resp, err := http.Get(
-		"https://github.com/GoogleContainerTools/kpt/archive/" + version + ".tar.gz")
+	resp, err := httpClient.Get(url)
 	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
-		return "", err
+		return "", fmt.Errorf("error getting %q: %w", url, err)
 	}
 	defer resp.Body.Close()
 
-	// write the file
-	func() {
-		out, err := os.Create(filepath.Join(d, version+".tar.gz"))
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "%v", err)
-			os.Exit(1)
-		}
-
-		if _, err = io.Copy(out, resp.Body); err != nil {
-			fmt.Fprintf(os.Stderr, "%v", err)
-			os.Exit(1)
-		}
-		out.Close()
-	}()
+	if resp.StatusCode != 200 {
+		return "", fmt.Errorf("unexpected response from %q: %v", url, resp.Status)
+	}
 
-	// calculate the sha
-	e := exec.Command("sha256sum", filepath.Join(d, version+".tar.gz"))
-	o, err := e.Output()
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v", err)
-		return "", err
+	if _, err := io.Copy(hasher, resp.Body); err != nil {
+		return "", fmt.Errorf("error hashing response from %q: %w", url, err)
 	}
-	parts := strings.Split(string(o), " ")
-	fmt.Println("new sha: " + parts[0])
-	return parts[0], nil
-}
 
-type Input struct {
-	Version string
-	Sha     string
+	// calculate the sha
+	hash := hasher.Sum(nil)
+	return hex.EncodeToString(hash), nil
 }
 
-const formula = `# Copyright 2019 Google LLC
+const formulaTemplate = `# Copyright 2019 Google LLC
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -128,8 +109,8 @@ const formula = `# Copyright 2019 Google LLC
 class Kpt < Formula
   desc "Toolkit to manage,and apply Kubernetes Resource config data files"
   homepage "https://googlecontainertools.github.io/kpt"
-  url "https://github.com/GoogleContainerTools/kpt/archive/{{.Version}}.tar.gz"
-  sha256 "{{.Sha}}"
+  url "{{url}}"
+  sha256 "{{sha256}}"
 
   depends_on "go" => :build
 
diff --git a/site/installation/kpt-cli.md b/site/installation/kpt-cli.md
index 9d5251a4..60282434 100644
--- a/site/installation/kpt-cli.md
+++ b/site/installation/kpt-cli.md
@@ -103,7 +103,7 @@ Use one of the kpt docker images.
 ### `kpt`
 
 ```shell
-$ docker run gcr.io/kpt-dev/kpt:v1.0.0-beta.23 version
+$ docker run gcr.io/kpt-dev/kpt:v1.0.0-beta.24 version
 ```
 
 ### `kpt-gcloud`
@@ -111,7 +111,7 @@ $ docker run gcr.io/kpt-dev/kpt:v1.0.0-beta.23 version
 An image which includes kpt based upon the Google [cloud-sdk] alpine image.
 
 ```shell
-$ docker run gcr.io/kpt-dev/kpt-gcloud:v1.0.0-beta.23 version
+$ docker run gcr.io/kpt-dev/kpt-gcloud:v1.0.0-beta.24 version
 ```
 
 ## Source
@@ -134,12 +134,12 @@ $ kpt version
   https://console.cloud.google.com/gcr/images/kpt-dev/GLOBAL/kpt-gcloud?gcrImageListsize=30
 [cloud-sdk]: https://github.com/GoogleCloudPlatform/cloud-sdk-docker
 [linux-amd64]:
-  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.23/kpt_linux_amd64
+  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.24/kpt_linux_amd64
 [linux-arm64]:
-  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.23/kpt_linux_arm64
+  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.24/kpt_linux_arm64
 [darwin-amd64]:
-  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.23/kpt_darwin_amd64
+  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.24/kpt_darwin_amd64
 [darwin-arm64]:
-  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.23/kpt_darwin_arm64
+  https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.24/kpt_darwin_arm64
 [migration guide]: /installation/migration
 [bash-completion]: https://github.com/scop/bash-completion#installation
diff --git a/site/package-lock.json b/site/package-lock.json
index 2a894fef..556c8a05 100644
--- a/site/package-lock.json
+++ b/site/package-lock.json
@@ -5270,9 +5270,9 @@
       }
     },
     "node_modules/minimatch": {
-      "version": "3.0.4",
-      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
-      "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+      "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
       "dev": true,
       "dependencies": {
         "brace-expansion": "^1.1.7"
@@ -11001,9 +11001,9 @@
       "dev": true
     },
     "minimatch": {
-      "version": "3.0.4",
-      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
-      "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+      "version": "3.1.2",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+      "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
       "dev": true,
       "requires": {
         "brace-expansion": "^1.1.7"
diff --git a/tools/licensescan/main.go b/tools/licensescan/main.go
index 5e96fd9c..8a8d3f57 100644
--- a/tools/licensescan/main.go
+++ b/tools/licensescan/main.go
@@ -19,6 +19,7 @@ import (
 	"bytes"
 	"context"
 	"debug/buildinfo"
+	"embed"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -35,6 +36,9 @@ import (
 	"sigs.k8s.io/yaml"
 )
 
+//go:embed modules/*
+var modulesFS embed.FS
+
 func main() {
 	rootCmd := buildRootCommand()
 
@@ -125,7 +129,14 @@ func RunLicenseScan(ctx context.Context, opts RunLicenseScanOptions) error {
 		modules = append(modules, module)
 
 		p := filepath.Join("modules", module.Name, module.Version+".yaml")
-		b, err := ioutil.ReadFile(p)
+		b, err := os.ReadFile(p)
+		if err != nil && os.IsNotExist(err) {
+			b2, err2 := modulesFS.ReadFile(p)
+			if err2 == nil {
+				b = b2
+				err = err2
+			}
+		}
 		if err != nil {
 			if os.IsNotExist(err) {
 				if err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {
diff --git a/tools/licensescan/modules/bitbucket.org/creachadair/stringset/v0.0.8.yaml b/tools/licensescan/modules/bitbucket.org/creachadair/stringset/v0.0.8.yaml
new file mode 100644
index 00000000..a2b66018
--- /dev/null
+++ b/tools/licensescan/modules/bitbucket.org/creachadair/stringset/v0.0.8.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/bitbucket.org/creachadair/stringset@v0.0.8
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/cloud.google.com/go/bigtable/v1.16.0.yaml b/tools/licensescan/modules/cloud.google.com/go/bigtable/v1.16.0.yaml
new file mode 100644
index 00000000..83f4c576
--- /dev/null
+++ b/tools/licensescan/modules/cloud.google.com/go/bigtable/v1.16.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/cloud.google.com/go/bigtable@v1.16.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/cloud.google.com/go/iam/v0.3.0.yaml b/tools/licensescan/modules/cloud.google.com/go/iam/v0.3.0.yaml
new file mode 100644
index 00000000..4e01f9e8
--- /dev/null
+++ b/tools/licensescan/modules/cloud.google.com/go/iam/v0.3.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/cloud.google.com/go/iam@v0.3.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/cloud.google.com/go/v0.102.1.yaml b/tools/licensescan/modules/cloud.google.com/go/v0.102.1.yaml
new file mode 100644
index 00000000..71882c6c
--- /dev/null
+++ b/tools/licensescan/modules/cloud.google.com/go/v0.102.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/cloud.google.com/go@v0.102.1
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/adal/v0.9.20.yaml b/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/adal/v0.9.20.yaml
new file mode 100644
index 00000000..65605be4
--- /dev/null
+++ b/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/adal/v0.9.20.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/Azure/go-autorest/autorest/adal@v0.9.20
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/v0.11.27.yaml b/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/v0.11.27.yaml
new file mode 100644
index 00000000..10f0c7c4
--- /dev/null
+++ b/tools/licensescan/modules/github.com/Azure/go-autorest/autorest/v0.11.27.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/Azure/go-autorest/autorest@v0.11.27
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/GoogleCloudPlatform/declarative-resource-client-library/v1.26.1.yaml b/tools/licensescan/modules/github.com/GoogleCloudPlatform/declarative-resource-client-library/v1.26.1.yaml
new file mode 100644
index 00000000..19f25bd1
--- /dev/null
+++ b/tools/licensescan/modules/github.com/GoogleCloudPlatform/declarative-resource-client-library/v1.26.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/GoogleCloudPlatform/declarative-resource-client-library@v1.26.1
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/porch/api/v0.0.0-20221028161857-aa271f292cc0.yaml b/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/porch/api/v0.0.0-20221028161857-aa271f292cc0.yaml
new file mode 100644
index 00000000..e3e18cac
--- /dev/null
+++ b/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/porch/api/v0.0.0-20221028161857-aa271f292cc0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/GoogleContainerTools/kpt/porch/api@v0.0.0-20221028161857-aa271f292cc0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/v1.0.0-beta.23.0.20221117142901-c67b11f2e138.yaml b/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/v1.0.0-beta.23.0.20221117142901-c67b11f2e138.yaml
new file mode 100644
index 00000000..ea266734
--- /dev/null
+++ b/tools/licensescan/modules/github.com/GoogleContainerTools/kpt/v1.0.0-beta.23.0.20221117142901-c67b11f2e138.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/GoogleContainerTools/kpt@v1.0.0-beta.23.0.20221117142901-c67b11f2e138
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/MakeNowJust/heredoc/v1.0.0.yaml b/tools/licensescan/modules/github.com/MakeNowJust/heredoc/v1.0.0.yaml
new file mode 100644
index 00000000..49e5d3af
--- /dev/null
+++ b/tools/licensescan/modules/github.com/MakeNowJust/heredoc/v1.0.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/MakeNowJust/heredoc@v1.0.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/apparentlymart/go-cidr/v1.1.0.yaml b/tools/licensescan/modules/github.com/apparentlymart/go-cidr/v1.1.0.yaml
new file mode 100644
index 00000000..088002d1
--- /dev/null
+++ b/tools/licensescan/modules/github.com/apparentlymart/go-cidr/v1.1.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/apparentlymart/go-cidr@v1.1.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/apparentlymart/go-textseg/v13/v13.0.0.yaml b/tools/licensescan/modules/github.com/apparentlymart/go-textseg/v13/v13.0.0.yaml
new file mode 100644
index 00000000..babf0d98
--- /dev/null
+++ b/tools/licensescan/modules/github.com/apparentlymart/go-textseg/v13/v13.0.0.yaml
@@ -0,0 +1,4 @@
+# https://pkg.go.dev/github.com/apparentlymart/go-textseg/v13@v13.0.0
+license: Apache-2.0,MIT,Unicode-DFS-2016
+licenseURLs:
+- https://raw.githubusercontent.com/apparentlymart/go-textseg/master/LICENSE
diff --git a/tools/licensescan/modules/github.com/cenkalti/backoff/v2.2.1+incompatible.yaml b/tools/licensescan/modules/github.com/cenkalti/backoff/v2.2.1+incompatible.yaml
new file mode 100644
index 00000000..805e3d47
--- /dev/null
+++ b/tools/licensescan/modules/github.com/cenkalti/backoff/v2.2.1+incompatible.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/cenkalti/backoff@v2.2.1+incompatible
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/chai2010/gettext-go/v1.0.2.yaml b/tools/licensescan/modules/github.com/chai2010/gettext-go/v1.0.2.yaml
new file mode 100644
index 00000000..101401e0
--- /dev/null
+++ b/tools/licensescan/modules/github.com/chai2010/gettext-go/v1.0.2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/chai2010/gettext-go@v1.0.2
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/emicklei/go-restful/v3/v3.8.0.yaml b/tools/licensescan/modules/github.com/emicklei/go-restful/v3/v3.8.0.yaml
new file mode 100644
index 00000000..87682ce9
--- /dev/null
+++ b/tools/licensescan/modules/github.com/emicklei/go-restful/v3/v3.8.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/emicklei/go-restful/v3@v3.8.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/evanphx/json-patch/v5/v5.6.0.yaml b/tools/licensescan/modules/github.com/evanphx/json-patch/v5/v5.6.0.yaml
new file mode 100644
index 00000000..df574245
--- /dev/null
+++ b/tools/licensescan/modules/github.com/evanphx/json-patch/v5/v5.6.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/evanphx/json-patch/v5@v5.6.0
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/fatih/color/v1.13.0.yaml b/tools/licensescan/modules/github.com/fatih/color/v1.13.0.yaml
new file mode 100644
index 00000000..ecf53679
--- /dev/null
+++ b/tools/licensescan/modules/github.com/fatih/color/v1.13.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/fatih/color@v1.13.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/golang-jwt/jwt/v4/v4.2.0.yaml b/tools/licensescan/modules/github.com/golang-jwt/jwt/v4/v4.2.0.yaml
new file mode 100644
index 00000000..8b649c21
--- /dev/null
+++ b/tools/licensescan/modules/github.com/golang-jwt/jwt/v4/v4.2.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/golang-jwt/jwt/v4@v4.2.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/golang/glog/v1.0.0.yaml b/tools/licensescan/modules/github.com/golang/glog/v1.0.0.yaml
new file mode 100644
index 00000000..42736ee6
--- /dev/null
+++ b/tools/licensescan/modules/github.com/golang/glog/v1.0.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/golang/glog@v1.0.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/golang/groupcache/v0.0.0-20210331224755-41bb18bfe9da.yaml b/tools/licensescan/modules/github.com/golang/groupcache/v0.0.0-20210331224755-41bb18bfe9da.yaml
new file mode 100644
index 00000000..438f92c9
--- /dev/null
+++ b/tools/licensescan/modules/github.com/golang/groupcache/v0.0.0-20210331224755-41bb18bfe9da.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/golang/groupcache@v0.0.0-20210331224755-41bb18bfe9da
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/google/btree/v1.1.2.yaml b/tools/licensescan/modules/github.com/google/btree/v1.1.2.yaml
new file mode 100644
index 00000000..b260d300
--- /dev/null
+++ b/tools/licensescan/modules/github.com/google/btree/v1.1.2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/google/btree@v1.1.2
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/google/go-cmp/v0.5.9.yaml b/tools/licensescan/modules/github.com/google/go-cmp/v0.5.9.yaml
new file mode 100644
index 00000000..632b7317
--- /dev/null
+++ b/tools/licensescan/modules/github.com/google/go-cmp/v0.5.9.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/google/go-cmp@v0.5.9
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/google/go-cpy/v0.0.0-20211218193943-a9c933c06932.yaml b/tools/licensescan/modules/github.com/google/go-cpy/v0.0.0-20211218193943-a9c933c06932.yaml
new file mode 100644
index 00000000..bb2bc017
--- /dev/null
+++ b/tools/licensescan/modules/github.com/google/go-cpy/v0.0.0-20211218193943-a9c933c06932.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/google/go-cpy@v0.0.0-20211218193943-a9c933c06932
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/googleapis/enterprise-certificate-proxy/v0.1.0.yaml b/tools/licensescan/modules/github.com/googleapis/enterprise-certificate-proxy/v0.1.0.yaml
new file mode 100644
index 00000000..fb0522fb
--- /dev/null
+++ b/tools/licensescan/modules/github.com/googleapis/enterprise-certificate-proxy/v0.1.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/googleapis/enterprise-certificate-proxy@v0.1.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/googleapis/gax-go/v2/v2.4.0.yaml b/tools/licensescan/modules/github.com/googleapis/gax-go/v2/v2.4.0.yaml
new file mode 100644
index 00000000..756ffdc2
--- /dev/null
+++ b/tools/licensescan/modules/github.com/googleapis/gax-go/v2/v2.4.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/googleapis/gax-go/v2@v2.4.0
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/googleapis/gnostic/v0.5.5.yaml b/tools/licensescan/modules/github.com/googleapis/gnostic/v0.5.5.yaml
new file mode 100644
index 00000000..67a3706b
--- /dev/null
+++ b/tools/licensescan/modules/github.com/googleapis/gnostic/v0.5.5.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/googleapis/gnostic@v0.5.5
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/grpc-ecosystem/go-grpc-middleware/v1.3.0.yaml b/tools/licensescan/modules/github.com/grpc-ecosystem/go-grpc-middleware/v1.3.0.yaml
new file mode 100644
index 00000000..75d2ae52
--- /dev/null
+++ b/tools/licensescan/modules/github.com/grpc-ecosystem/go-grpc-middleware/v1.3.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-checkpoint/v0.5.0.yaml b/tools/licensescan/modules/github.com/hashicorp/go-checkpoint/v0.5.0.yaml
new file mode 100644
index 00000000..07d36397
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-checkpoint/v0.5.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-checkpoint@v0.5.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-cty/v1.4.1-0.20200414143053-d3edf31b6320.yaml b/tools/licensescan/modules/github.com/hashicorp/go-cty/v1.4.1-0.20200414143053-d3edf31b6320.yaml
new file mode 100644
index 00000000..437163a5
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-cty/v1.4.1-0.20200414143053-d3edf31b6320.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-hclog/v1.2.1.yaml b/tools/licensescan/modules/github.com/hashicorp/go-hclog/v1.2.1.yaml
new file mode 100644
index 00000000..08f431d1
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-hclog/v1.2.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-hclog@v1.2.1
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-multierror/v1.1.1.yaml b/tools/licensescan/modules/github.com/hashicorp/go-multierror/v1.1.1.yaml
new file mode 100644
index 00000000..38de2263
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-multierror/v1.1.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-multierror@v1.1.1
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-plugin/v1.4.4.yaml b/tools/licensescan/modules/github.com/hashicorp/go-plugin/v1.4.4.yaml
new file mode 100644
index 00000000..cd54fe61
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-plugin/v1.4.4.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-plugin@v1.4.4
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-uuid/v1.0.3.yaml b/tools/licensescan/modules/github.com/hashicorp/go-uuid/v1.0.3.yaml
new file mode 100644
index 00000000..478935f4
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-uuid/v1.0.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-uuid@v1.0.3
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/go-version/v1.6.0.yaml b/tools/licensescan/modules/github.com/hashicorp/go-version/v1.6.0.yaml
new file mode 100644
index 00000000..8d281702
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/go-version/v1.6.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/go-version@v1.6.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/hc-install/v0.4.0.yaml b/tools/licensescan/modules/github.com/hashicorp/hc-install/v0.4.0.yaml
new file mode 100644
index 00000000..1b9d8cc1
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/hc-install/v0.4.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/hc-install@v0.4.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/hcl/v2/v2.13.0.yaml b/tools/licensescan/modules/github.com/hashicorp/hcl/v2/v2.13.0.yaml
new file mode 100644
index 00000000..cc6a9720
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/hcl/v2/v2.13.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/hcl/v2@v2.13.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-exec/v0.17.2.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-exec/v0.17.2.yaml
new file mode 100644
index 00000000..397ec6f5
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-exec/v0.17.2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.2
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-json/v0.14.0.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-json/v0.14.0.yaml
new file mode 100644
index 00000000..6c158486
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-json/v0.14.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-json@v0.14.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-go/v0.10.0.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-go/v0.10.0.yaml
new file mode 100644
index 00000000..d2182792
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-go/v0.10.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go@v0.10.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-log/v0.4.1.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-log/v0.4.1.yaml
new file mode 100644
index 00000000..8a0fadba
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-log/v0.4.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-plugin-log@v0.4.1
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-sdk/v2/v2.18.0.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-sdk/v2/v2.18.0.yaml
new file mode 100644
index 00000000..e17d67f3
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-plugin-sdk/v2/v2.18.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2@v2.18.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/(devel).yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/(devel).yaml
new file mode 100644
index 00000000..f0161a68
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/(devel).yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-provider-google-beta@(devel)
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.0.0-20220623143253-7d51757b572c.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.0.0-20220623143253-7d51757b572c.yaml
new file mode 100644
index 00000000..91081335
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.0.0-20220623143253-7d51757b572c.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-registry-address@v0.0.0-20220623143253-7d51757b572c
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.0.0-20200729002733-f050f53b9734.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.0.0-20200729002733-f050f53b9734.yaml
new file mode 100644
index 00000000..8179cb3d
--- /dev/null
+++ b/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.0.0-20200729002733-f050f53b9734.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/hashicorp/terraform-svchost@v0.0.0-20200729002733-f050f53b9734
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mattn/go-colorable/v0.1.12.yaml b/tools/licensescan/modules/github.com/mattn/go-colorable/v0.1.12.yaml
new file mode 100644
index 00000000..c43bf060
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mattn/go-colorable/v0.1.12.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mattn/go-colorable@v0.1.12
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mattn/go-isatty/v0.0.14.yaml b/tools/licensescan/modules/github.com/mattn/go-isatty/v0.0.14.yaml
new file mode 100644
index 00000000..c9ac5953
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mattn/go-isatty/v0.0.14.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mattn/go-isatty@v0.0.14
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mitchellh/copystructure/v1.2.0.yaml b/tools/licensescan/modules/github.com/mitchellh/copystructure/v1.2.0.yaml
new file mode 100644
index 00000000..5f321619
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mitchellh/copystructure/v1.2.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mitchellh/copystructure@v1.2.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mitchellh/hashstructure/v1.1.0.yaml b/tools/licensescan/modules/github.com/mitchellh/hashstructure/v1.1.0.yaml
new file mode 100644
index 00000000..4fc99cdb
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mitchellh/hashstructure/v1.1.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mitchellh/hashstructure@v1.1.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mitchellh/mapstructure/v1.5.0.yaml b/tools/licensescan/modules/github.com/mitchellh/mapstructure/v1.5.0.yaml
new file mode 100644
index 00000000..25692002
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mitchellh/mapstructure/v1.5.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mitchellh/mapstructure@v1.5.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/mitchellh/reflectwalk/v1.0.2.yaml b/tools/licensescan/modules/github.com/mitchellh/reflectwalk/v1.0.2.yaml
new file mode 100644
index 00000000..c0d526e6
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mitchellh/reflectwalk/v1.0.2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mitchellh/reflectwalk@v1.0.2
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/nasa9084/go-openapi/v0.0.0-20200604141640-2875b7376353.yaml b/tools/licensescan/modules/github.com/nasa9084/go-openapi/v0.0.0-20200604141640-2875b7376353.yaml
new file mode 100644
index 00000000..6b6d86db
--- /dev/null
+++ b/tools/licensescan/modules/github.com/nasa9084/go-openapi/v0.0.0-20200604141640-2875b7376353.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/nasa9084/go-openapi@v0.0.0-20200604141640-2875b7376353
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/sirupsen/logrus/v1.8.1.yaml b/tools/licensescan/modules/github.com/sirupsen/logrus/v1.8.1.yaml
new file mode 100644
index 00000000..c113a53a
--- /dev/null
+++ b/tools/licensescan/modules/github.com/sirupsen/logrus/v1.8.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/sirupsen/logrus@v1.8.1
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/spf13/cobra/v1.2.1.yaml b/tools/licensescan/modules/github.com/spf13/cobra/v1.2.1.yaml
new file mode 100644
index 00000000..c932c73f
--- /dev/null
+++ b/tools/licensescan/modules/github.com/spf13/cobra/v1.2.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/spf13/cobra@v1.2.1
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/spyzhov/ajson/v0.7.1.yaml b/tools/licensescan/modules/github.com/spyzhov/ajson/v0.7.1.yaml
new file mode 100644
index 00000000..62b68af4
--- /dev/null
+++ b/tools/licensescan/modules/github.com/spyzhov/ajson/v0.7.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/spyzhov/ajson@v0.7.1
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/terraform-providers/terraform-provider-google-beta/v1.20.0.yaml b/tools/licensescan/modules/github.com/terraform-providers/terraform-provider-google-beta/v1.20.0.yaml
new file mode 100644
index 00000000..d0f56617
--- /dev/null
+++ b/tools/licensescan/modules/github.com/terraform-providers/terraform-provider-google-beta/v1.20.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/terraform-providers/terraform-provider-google-beta@v1.20.0
+license: MPL-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/vmihailenco/msgpack/v4/v4.3.12.yaml b/tools/licensescan/modules/github.com/vmihailenco/msgpack/v4/v4.3.12.yaml
new file mode 100644
index 00000000..cdaae21b
--- /dev/null
+++ b/tools/licensescan/modules/github.com/vmihailenco/msgpack/v4/v4.3.12.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/vmihailenco/msgpack/v4@v4.3.12
+license: BSD-2-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/vmihailenco/tagparser/v0.1.1.yaml b/tools/licensescan/modules/github.com/vmihailenco/tagparser/v0.1.1.yaml
new file mode 100644
index 00000000..4c58dbfd
--- /dev/null
+++ b/tools/licensescan/modules/github.com/vmihailenco/tagparser/v0.1.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/vmihailenco/tagparser@v0.1.1
+license: BSD-2-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/github.com/zclconf/go-cty/v1.10.0.yaml b/tools/licensescan/modules/github.com/zclconf/go-cty/v1.10.0.yaml
new file mode 100644
index 00000000..6b581e1e
--- /dev/null
+++ b/tools/licensescan/modules/github.com/zclconf/go-cty/v1.10.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/zclconf/go-cty@v1.10.0
+license: MIT
\ No newline at end of file
diff --git a/tools/licensescan/modules/go.opencensus.io/v0.23.0.yaml b/tools/licensescan/modules/go.opencensus.io/v0.23.0.yaml
new file mode 100644
index 00000000..f5fc8303
--- /dev/null
+++ b/tools/licensescan/modules/go.opencensus.io/v0.23.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/go.opencensus.io@v0.23.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220315160706-3147a52a75dd.yaml b/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220315160706-3147a52a75dd.yaml
new file mode 100644
index 00000000..a520b32f
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220315160706-3147a52a75dd.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/crypto@v0.0.0-20220315160706-3147a52a75dd
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220517005047-85d78b3ac167.yaml b/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220517005047-85d78b3ac167.yaml
new file mode 100644
index 00000000..656a8a08
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/crypto/v0.0.0-20220517005047-85d78b3ac167.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/crypto@v0.0.0-20220517005047-85d78b3ac167
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/oauth2/v0.0.0-20220622183110-fd043fe589d2.yaml b/tools/licensescan/modules/golang.org/x/oauth2/v0.0.0-20220622183110-fd043fe589d2.yaml
new file mode 100644
index 00000000..810cb83f
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/oauth2/v0.0.0-20220622183110-fd043fe589d2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/oauth2@v0.0.0-20220622183110-fd043fe589d2
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/sync/v0.0.0-20220722155255-886fb9371eb4.yaml b/tools/licensescan/modules/golang.org/x/sync/v0.0.0-20220722155255-886fb9371eb4.yaml
new file mode 100644
index 00000000..8a834f47
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/sync/v0.0.0-20220722155255-886fb9371eb4.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/sync@v0.0.0-20220722155255-886fb9371eb4
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/time/v0.0.0-20210723032227-1f47c861a9ac.yaml b/tools/licensescan/modules/golang.org/x/time/v0.0.0-20210723032227-1f47c861a9ac.yaml
new file mode 100644
index 00000000..f0a53fd4
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/time/v0.0.0-20210723032227-1f47c861a9ac.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/time@v0.0.0-20210723032227-1f47c861a9ac
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/time/v0.0.0-20220609170525-579cf78fd858.yaml b/tools/licensescan/modules/golang.org/x/time/v0.0.0-20220609170525-579cf78fd858.yaml
new file mode 100644
index 00000000..535d399b
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/time/v0.0.0-20220609170525-579cf78fd858.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/time@v0.0.0-20220609170525-579cf78fd858
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/golang.org/x/xerrors/v0.0.0-20220609144429-65e65417b02f.yaml b/tools/licensescan/modules/golang.org/x/xerrors/v0.0.0-20220609144429-65e65417b02f.yaml
new file mode 100644
index 00000000..184c80c2
--- /dev/null
+++ b/tools/licensescan/modules/golang.org/x/xerrors/v0.0.0-20220609144429-65e65417b02f.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/golang.org/x/xerrors@v0.0.0-20220609144429-65e65417b02f
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/google.golang.org/api/v0.92.0.yaml b/tools/licensescan/modules/google.golang.org/api/v0.92.0.yaml
new file mode 100644
index 00000000..4c6956fa
--- /dev/null
+++ b/tools/licensescan/modules/google.golang.org/api/v0.92.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/google.golang.org/api@v0.92.0
+license: BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/google.golang.org/genproto/v0.0.0-20220725144611-272f38e5d71b.yaml b/tools/licensescan/modules/google.golang.org/genproto/v0.0.0-20220725144611-272f38e5d71b.yaml
new file mode 100644
index 00000000..c93e6b04
--- /dev/null
+++ b/tools/licensescan/modules/google.golang.org/genproto/v0.0.0-20220725144611-272f38e5d71b.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/google.golang.org/genproto@v0.0.0-20220725144611-272f38e5d71b
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/google.golang.org/grpc/v1.48.0.yaml b/tools/licensescan/modules/google.golang.org/grpc/v1.48.0.yaml
new file mode 100644
index 00000000..99bcb9f2
--- /dev/null
+++ b/tools/licensescan/modules/google.golang.org/grpc/v1.48.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/google.golang.org/grpc@v1.48.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/api/v0.23.0.yaml b/tools/licensescan/modules/k8s.io/api/v0.23.0.yaml
new file mode 100644
index 00000000..0ae6abce
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/api/v0.23.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/api@v0.23.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/api/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/api/v0.25.3.yaml
new file mode 100644
index 00000000..22db3e37
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/api/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/api@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.23.0.yaml b/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.23.0.yaml
new file mode 100644
index 00000000..52e5df92
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.23.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/apiextensions-apiserver@v0.23.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.24.0.yaml b/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.24.0.yaml
new file mode 100644
index 00000000..efa02738
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/apiextensions-apiserver/v0.24.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/apiextensions-apiserver@v0.24.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/apimachinery/v0.23.0.yaml b/tools/licensescan/modules/k8s.io/apimachinery/v0.23.0.yaml
new file mode 100644
index 00000000..6bcb4832
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/apimachinery/v0.23.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/apimachinery@v0.23.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/apimachinery/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/apimachinery/v0.25.3.yaml
new file mode 100644
index 00000000..0213e841
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/apimachinery/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/apimachinery@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/cli-runtime/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/cli-runtime/v0.25.3.yaml
new file mode 100644
index 00000000..ac010d89
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/cli-runtime/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/cli-runtime@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/client-go/v0.23.0.yaml b/tools/licensescan/modules/k8s.io/client-go/v0.23.0.yaml
new file mode 100644
index 00000000..09f80125
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/client-go/v0.23.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/client-go@v0.23.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/client-go/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/client-go/v0.25.3.yaml
new file mode 100644
index 00000000..1e25ab13
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/client-go/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/client-go@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/component-base/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/component-base/v0.25.3.yaml
new file mode 100644
index 00000000..c76ab192
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/component-base/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/component-base@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/klog/v2/v2.70.1.yaml b/tools/licensescan/modules/k8s.io/klog/v2/v2.70.1.yaml
new file mode 100644
index 00000000..9d2cfe46
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/klog/v2/v2.70.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/klog/v2@v2.70.1
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20211115234752-e816edb12b65.yaml b/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20211115234752-e816edb12b65.yaml
new file mode 100644
index 00000000..20508462
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20211115234752-e816edb12b65.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/kube-openapi@v0.0.0-20211115234752-e816edb12b65
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20220803162953-67bda5d908f1.yaml b/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20220803162953-67bda5d908f1.yaml
new file mode 100644
index 00000000..562a78b4
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/kube-openapi/v0.0.0-20220803162953-67bda5d908f1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/kube-openapi@v0.0.0-20220803162953-67bda5d908f1
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/kubectl/v0.25.3.yaml b/tools/licensescan/modules/k8s.io/kubectl/v0.25.3.yaml
new file mode 100644
index 00000000..9759480c
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/kubectl/v0.25.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/kubectl@v0.25.3
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/k8s.io/utils/v0.0.0-20220823124924-e9cbc92d1a73.yaml b/tools/licensescan/modules/k8s.io/utils/v0.0.0-20220823124924-e9cbc92d1a73.yaml
new file mode 100644
index 00000000..649c3f4f
--- /dev/null
+++ b/tools/licensescan/modules/k8s.io/utils/v0.0.0-20220823124924-e9cbc92d1a73.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/k8s.io/utils@v0.0.0-20220823124924-e9cbc92d1a73
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/cli-utils/v0.34.0.yaml b/tools/licensescan/modules/sigs.k8s.io/cli-utils/v0.34.0.yaml
new file mode 100644
index 00000000..d83ef6c4
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/cli-utils/v0.34.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/cli-utils@v0.34.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/controller-runtime/v0.13.0.yaml b/tools/licensescan/modules/sigs.k8s.io/controller-runtime/v0.13.0.yaml
new file mode 100644
index 00000000..4597e17d
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/controller-runtime/v0.13.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20211020170558-c049b76a60c6.yaml b/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20211020170558-c049b76a60c6.yaml
new file mode 100644
index 00000000..366a857f
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20211020170558-c049b76a60c6.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6
+license: Apache-2.0, BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20220713155537-f223a00ba0e2.yaml b/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20220713155537-f223a00ba0e2.yaml
new file mode 100644
index 00000000..9d0ede8e
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/json/v0.0.0-20220713155537-f223a00ba0e2.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/json@v0.0.0-20220713155537-f223a00ba0e2
+license: Apache-2.0, BSD-3-Clause
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.0.yaml b/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.0.yaml
new file mode 100644
index 00000000..e5f25276
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.0.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/structured-merge-diff/v4@v4.2.0
+license: Apache-2.0
\ No newline at end of file
diff --git a/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.3.yaml b/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.3.yaml
new file mode 100644
index 00000000..b2110b2f
--- /dev/null
+++ b/tools/licensescan/modules/sigs.k8s.io/structured-merge-diff/v4/v4.2.3.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/sigs.k8s.io/structured-merge-diff/v4@v4.2.3
+license: Apache-2.0
\ No newline at end of file


Test patch:
diff --git a/internal/testutil/pkgbuilder/builder.go b/internal/testutil/pkgbuilder/builder.go
index ac959686..2495d4fd 100644
--- a/internal/testutil/pkgbuilder/builder.go
+++ b/internal/testutil/pkgbuilder/builder.go
@@ -15,14 +15,12 @@
 package pkgbuilder
 
 import (
-	"bytes"
 	"fmt"
 	"os"
 	"path/filepath"
 	"regexp"
 	"strconv"
 	"testing"
-	"text/template"
 
 	kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1"
 	rgfilev1alpha1 "github.com/GoogleContainerTools/kpt/pkg/api/resourcegroup/v1alpha1"
@@ -561,53 +559,6 @@ func buildRGFile(pkg *pkg) string {
 	return string(b)
 }
 
-// TODO: Consider using the Kptfile struct for this instead of a template.
-var kptfileTemplate = `apiVersion: kpt.dev/v1
-kind: Kptfile
-metadata:
-  name: {{.PkgName}}
-{{- if .Pkg.Kptfile.Upstream }}
-upstream:
-  type: git
-  git:
-    repo: {{.Pkg.Kptfile.Upstream.Repo}}
-    directory: {{.Pkg.Kptfile.Upstream.Dir}}
-    ref: {{.Pkg.Kptfile.Upstream.Ref}}
-  updateStrategy: {{.Pkg.Kptfile.Upstream.Strategy}}
-{{- end }}
-{{- if .Pkg.Kptfile.UpstreamLock }}
-upstreamLock:
-  type: git
-  git:
-    repo: {{.Pkg.Kptfile.UpstreamLock.Repo}}
-    directory: {{.Pkg.Kptfile.UpstreamLock.Dir}}
-    ref: {{.Pkg.Kptfile.UpstreamLock.Ref}}
-    commit: {{.Pkg.Kptfile.UpstreamLock.Commit}}
-{{- end }}
-{{- if .Pkg.Kptfile.Pipeline }}
-pipeline:
-  mutators:
-{{- range .Pkg.Kptfile.Pipeline.Functions }}
-  - image: {{ .Image }}
-{{- if .ConfigPath }}
-  - configPath: {{ .ConfigPath }}
-{{- end }}
-{{- end }}
-{{- end }}
-{{- if .Pkg.Kptfile.Inventory }}
-inventory:
-{{- if .Pkg.Kptfile.Inventory.Name }}
-  name: {{ .Pkg.Kptfile.Inventory.Name }}
-{{- end }}
-{{- if .Pkg.Kptfile.Inventory.Namespace }}
-  namespace: {{ .Pkg.Kptfile.Inventory.Namespace }}
-{{- end }}
-{{- if .Pkg.Kptfile.Inventory.ID }}
-  inventoryID: {{ .Pkg.Kptfile.Inventory.ID }}
-{{- end }}
-{{- end }}
-`
-
 type ReposInfo interface {
 	ResolveRepoRef(repoRef string) (string, bool)
 	ResolveCommitIndex(repoRef string, index int) (string, bool)
@@ -635,20 +586,62 @@ func buildKptfile(pkg *pkg, pkgName string, reposInfo ReposInfo) string {
 			pkg.Kptfile.UpstreamLock.Ref = newRef
 		}
 	}
-	tmpl, err := template.New("test").Parse(kptfileTemplate)
-	if err != nil {
-		panic(err)
+
+	kptfile := &kptfilev1.KptFile{}
+	kptfile.APIVersion, kptfile.Kind = kptfilev1.KptFileGVK().ToAPIVersionAndKind()
+	kptfile.ObjectMeta.Name = pkgName
+	if pkg.Kptfile.Upstream != nil {
+		kptfile.Upstream = &kptfilev1.Upstream{
+			Type: "git",
+			Git: &kptfilev1.Git{
+				Repo:      pkg.Kptfile.Upstream.Repo,
+				Directory: pkg.Kptfile.Upstream.Dir,
+				Ref:       pkg.Kptfile.Upstream.Ref,
+			},
+			UpdateStrategy: kptfilev1.UpdateStrategyType(pkg.Kptfile.Upstream.Strategy),
+		}
 	}
-	var buf bytes.Buffer
-	err = tmpl.Execute(&buf, map[string]interface{}{
-		"Pkg":     pkg,
-		"PkgName": pkgName,
-	})
+	if pkg.Kptfile.UpstreamLock != nil {
+		kptfile.UpstreamLock = &kptfilev1.UpstreamLock{
+			Type: "git",
+			Git: &kptfilev1.GitLock{
+				Repo:      pkg.Kptfile.UpstreamLock.Repo,
+				Directory: pkg.Kptfile.UpstreamLock.Dir,
+				Ref:       pkg.Kptfile.UpstreamLock.Ref,
+				Commit:    pkg.Kptfile.UpstreamLock.Commit,
+			},
+		}
+	}
+	if pkg.Kptfile.Pipeline != nil {
+		kptfile.Pipeline = &kptfilev1.Pipeline{}
+		for _, fn := range pkg.Kptfile.Pipeline.Functions {
+			mutator := kptfilev1.Function{
+				Image: fn.Image,
+			}
+			if fn.ConfigPath != "" {
+				mutator.ConfigPath = fn.ConfigPath
+			}
+			kptfile.Pipeline.Mutators = append(kptfile.Pipeline.Mutators, mutator)
+		}
+	}
+
+	if inventory := pkg.Kptfile.Inventory; inventory != nil {
+		kptfile.Inventory = &kptfilev1.Inventory{}
+		if inventory.Name != "" {
+			kptfile.Inventory.Name = inventory.Name
+		}
+		if inventory.Namespace != "" {
+			kptfile.Inventory.Namespace = inventory.Namespace
+		}
+		if inventory.ID != "" {
+			kptfile.Inventory.InventoryID = inventory.ID
+		}
+	}
+	b, err := yaml.Marshal(kptfile)
 	if err != nil {
 		panic(err)
 	}
-	result := buf.String()
-	return result
+	return string(b)
 }
 
 // resolveRepoRef looks up the repo path for a repo from the reposInfo
diff --git a/internal/testutil/pkgbuilder/builder_test.go b/internal/testutil/pkgbuilder/builder_test.go
new file mode 100644
index 00000000..7e7e0ae8
--- /dev/null
+++ b/internal/testutil/pkgbuilder/builder_test.go
@@ -0,0 +1,37 @@
+package pkgbuilder
+
+import (
+	"testing"
+
+	"github.com/google/go-cmp/cmp"
+)
+
+func TestBuildKptfile(t *testing.T) {
+	var repos ReposInfo
+	pkg := &pkg{}
+	pkg.Kptfile = &Kptfile{
+		Pipeline: &Pipeline{
+			Functions: []Function{
+				{Image: "example.com/fn1"},
+				{ConfigPath: "config1"},
+				{Image: "example.com/fn2"},
+			},
+		},
+	}
+
+	got := buildKptfile(pkg, "test1", repos)
+	want := `apiVersion: kpt.dev/v1
+kind: Kptfile
+metadata:
+  name: test1
+pipeline:
+  mutators:
+  - image: example.com/fn1
+  - configPath: config1
+  - image: example.com/fn2
+`
+
+	if diff := cmp.Diff(want, got); diff != "" {
+		t.Errorf("buildKptfile returned unexpected diff (-want +got):\n%s", diff)
+	}
+}
diff --git a/release/formula/main_test.go b/release/formula/main_test.go
new file mode 100644
index 00000000..7ea62ebb
--- /dev/null
+++ b/release/formula/main_test.go
@@ -0,0 +1,87 @@
+// Copyright 2022 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+	"bytes"
+	"io"
+	"net/http"
+	"testing"
+
+	"github.com/google/go-cmp/cmp"
+)
+
+func TestFormula(t *testing.T) {
+	want := `# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class Kpt < Formula
+  desc "Toolkit to manage,and apply Kubernetes Resource config data files"
+  homepage "https://googlecontainertools.github.io/kpt"
+  url "https://github.com/GoogleContainerTools/kpt/archive/v0.0.0-fake.tar.gz"
+  sha256 "4e42c5ce1a23511405beb5f51cfe07885fa953db448265fe74ee9b81e0def277"
+
+  depends_on "go" => :build
+
+  def install
+    ENV["GO111MODULE"] = "on"
+    system "go", "build", "-ldflags", "-X github.com/GoogleContainerTools/kpt/run.version=#{version}", *std_go_args
+  end
+
+  test do
+    assert_match version.to_s, shell_output("#{bin}/kpt version")
+  end
+end
+`
+
+	httpClient := &http.Client{
+		Transport: &fakeServer{t: t},
+	}
+	url := "https://github.com/GoogleContainerTools/kpt/archive/v0.0.0-fake.tar.gz"
+	got, err := buildFormula(httpClient, url)
+	if err != nil {
+		t.Fatalf("error from buildFormula(%q): %v", url, err)
+	}
+	if diff := cmp.Diff(want, got); diff != "" {
+		t.Errorf("buildFormula(%q) returned unexpected diff (-want +got):\n%s", url, diff)
+	}
+}
+
+type fakeServer struct {
+	t *testing.T
+}
+
+func (s *fakeServer) RoundTrip(req *http.Request) (*http.Response, error) {
+	if req.URL.Path != "/GoogleContainerTools/kpt/archive/v0.0.0-fake.tar.gz" {
+		s.t.Errorf("Expected to request '/GoogleContainerTools/kpt/archive/v0.0.0-fake.tar.gz', got: %s", req.URL.Path)
+	}
+	body := bytes.NewReader([]byte(`This is fake content so that our tests don't download big files`))
+	return &http.Response{
+		Status:     http.StatusText(http.StatusOK),
+		StatusCode: http.StatusOK,
+		Body:       io.NopCloser(body),
+	}, nil
+}
diff --git a/tools/licensescan/modules/github.com/mitchellh/go-testing-interface/v1.14.1.yaml b/tools/licensescan/modules/github.com/mitchellh/go-testing-interface/v1.14.1.yaml
new file mode 100644
index 00000000..3cd2653c
--- /dev/null
+++ b/tools/licensescan/modules/github.com/mitchellh/go-testing-interface/v1.14.1.yaml
@@ -0,0 +1,2 @@
+# https://pkg.go.dev/github.com/mitchellh/go-testing-interface@v1.14.1
+license: MIT
\ No newline at end of file