Repository: kubernetes-sigs/security-profiles-operator
Pull request #865 (2022-03-25 07:33:21)

Bump kustomize to v4.5.3


#### What type of PR is this?


/kind cleanup


#### What this PR does / why we need it:
Update kustomize to the latest release.
#### Which issue(s) this PR fixes:

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.

Fixes #

or

None
-->
None
#### Does this PR have test?
None
<!--
If tests aren't applicable just write N/A.
-->

#### Special notes for your reviewer:
None
#### Does this PR introduce a user-facing change?

<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note
None
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/865#" title="Author self-approved">saschagrunert</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [saschagrunert]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
k8s-ci-robot: @saschagrunert: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-security-profiles-operator-test-e2e | dc036c8e300362e1a6166287a332bed903f1b765 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_security-profiles-operator/865/pull-security-profiles-operator-test-e2e/1507259328627740672) | true | `/test pull-security-profiles-operator-test-e2e`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=security-profiles-operator&pr=865). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Asaschagrunert). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/security-profiles-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
JAORMX: /retest
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/865#pullrequestreview-921280789" title="Approved">JAORMX</a>*, *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/865#" title="Author self-approved">saschagrunert</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [JAORMX,saschagrunert]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
saschagrunert: /test pull-security-profiles-operator-test-e2e
saschagrunert: @k8s-ci-robot ?

/test pull-security-profiles-operator-test-e2e
saschagrunert: /override pull-security-profiles-operator-test-e2e
k8s-ci-robot: @saschagrunert: Overrode contexts on behalf of saschagrunert: pull-security-profiles-operator-test-e2e

<details>

In response to [this](https://github.com/kubernetes-sigs/security-profiles-operator/pull/865#issuecomment-1078753917):

>/override pull-security-profiles-operator-test-e2e


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

Patch:
diff --git a/Makefile b/Makefile
index 88aa978c6..5599b42fd 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ GO ?= go
 
 GOLANGCI_LINT_VERSION = v1.45.0
 REPO_INFRA_VERSION = v0.2.5
-KUSTOMIZE_VERSION = 4.5.2
+KUSTOMIZE_VERSION = 4.5.3
 KUBERNETES_SPLIT_YAML_VERSION = 0.3.0
 
 CONTROLLER_GEN_CMD := $(GO) run -tags generate sigs.k8s.io/controller-tools/cmd/controller-gen
diff --git a/cmd/security-profiles-operator/main.go b/cmd/security-profiles-operator/main.go
index 09a994336..511c97644 100644
--- a/cmd/security-profiles-operator/main.go
+++ b/cmd/security-profiles-operator/main.go
@@ -20,6 +20,7 @@ import (
 	"context"
 	"flag"
 	"fmt"
+	"log"
 	"net/http"
 	_ "net/http/pprof" // nolint:gosec // required for profiling
 	"os"
@@ -79,7 +80,13 @@ func main() {
 	app.Usage = "Kubernetes Security Profiles Operator"
 	app.Description = "The Security Profiles Operator makes it easier for cluster admins " +
 		"to manage their seccomp or AppArmor profiles and apply them to Kubernetes' workloads."
-	app.Version = version.Get().Version
+
+	info, err := version.Get()
+	if err != nil {
+		log.Fatal(err)
+	}
+	app.Version = info.Version
+
 	app.Commands = cli.Commands{
 		&cli.Command{
 			Name:    "version",
@@ -93,10 +100,9 @@ func main() {
 				},
 			},
 			Action: func(c *cli.Context) error {
-				v := version.Get()
-				res := v.String()
+				res := info.String()
 				if c.Bool(jsonFlag) {
-					j, err := v.JSONString()
+					j, err := info.JSONString()
 					if err != nil {
 						return errors.Wrap(err, "unable to generate JSON from version info")
 					}
@@ -111,14 +117,18 @@ func main() {
 			Name:    "manager",
 			Aliases: []string{"m"},
 			Usage:   "run the manager",
-			Action:  runManager,
+			Action: func(ctx *cli.Context) error {
+				return runManager(ctx, info)
+			},
 		},
 		&cli.Command{
 			Before:  initialize,
 			Name:    "daemon",
 			Aliases: []string{"d"},
 			Usage:   "run the daemon",
-			Action:  runDaemon,
+			Action: func(ctx *cli.Context) error {
+				return runDaemon(ctx, info)
+			},
 			Flags: []cli.Flag{
 				&cli.BoolFlag{
 					Name:  selinuxFlag,
@@ -137,7 +147,9 @@ func main() {
 			Name:    "webhook",
 			Aliases: []string{"w"},
 			Usage:   "run the webhook",
-			Action:  runWebhook,
+			Action: func(ctx *cli.Context) error {
+				return runWebhook(ctx, info)
+			},
 			Flags: []cli.Flag{
 				&cli.IntFlag{
 					Name:    "port",
@@ -151,21 +163,27 @@ func main() {
 			Before: initialize,
 			Name:   "non-root-enabler",
 			Usage:  "run the non root enabler",
-			Action: runNonRootEnabler,
+			Action: func(ctx *cli.Context) error {
+				return runNonRootEnabler(ctx, info)
+			},
 		},
 		&cli.Command{
 			Before:  initialize,
 			Name:    "log-enricher",
 			Aliases: []string{"l"},
 			Usage:   "run the audit's log enricher",
-			Action:  runLogEnricher,
+			Action: func(ctx *cli.Context) error {
+				return runLogEnricher(ctx, info)
+			},
 		},
 		&cli.Command{
 			Before:  initialize,
 			Name:    "bpf-recorder",
 			Aliases: []string{"b"},
 			Usage:   "run the bpf recorder",
-			Action:  runBPFRecorder,
+			Action: func(ctx *cli.Context) error {
+				return runBPFRecorder(ctx, info)
+			},
 		},
 	}
 	app.Flags = []cli.Flag{
@@ -237,15 +255,15 @@ func initProfiling(ctx *cli.Context) {
 	}
 }
 
-func printInfo(component string) {
+func printInfo(component string, info *version.Info) {
 	setupLog.Info(
 		fmt.Sprintf("starting component: %s", component),
-		version.Get().AsKeyValues()...,
+		info.AsKeyValues()...,
 	)
 }
 
-func runManager(ctx *cli.Context) error {
-	printInfo("security-profiles-operator")
+func runManager(ctx *cli.Context, info *version.Info) error {
+	printInfo("security-profiles-operator", info)
 	cfg, err := ctrl.GetConfig()
 	if err != nil {
 		return errors.Wrap(err, "get config")
@@ -349,9 +367,9 @@ func getEnabledControllers(ctx *cli.Context) []controller.Controller {
 	return controllers
 }
 
-func runDaemon(ctx *cli.Context) error {
+func runDaemon(ctx *cli.Context, info *version.Info) error {
 	// security-profiles-operator-daemon
-	printInfo("spod")
+	printInfo("spod", info)
 
 	enabledControllers := getEnabledControllers(ctx)
 	if len(enabledControllers) == 0 {
@@ -411,26 +429,26 @@ func runDaemon(ctx *cli.Context) error {
 	return nil
 }
 
-func runBPFRecorder(ctx *cli.Context) error {
+func runBPFRecorder(_ *cli.Context, info *version.Info) error {
 	const component = "bpf-recorder"
-	printInfo(component)
+	printInfo(component, info)
 	return bpfrecorder.New(ctrl.Log.WithName(component)).Run()
 }
 
-func runLogEnricher(ctx *cli.Context) error {
+func runLogEnricher(_ *cli.Context, info *version.Info) error {
 	const component = "log-enricher"
-	printInfo(component)
+	printInfo(component, info)
 	return enricher.New(ctrl.Log.WithName(component)).Run()
 }
 
-func runNonRootEnabler(ctx *cli.Context) error {
+func runNonRootEnabler(_ *cli.Context, info *version.Info) error {
 	const component = "non-root-enabler"
-	printInfo(component)
+	printInfo(component, info)
 	return nonrootenabler.New().Run(ctrl.Log.WithName(component))
 }
 
-func runWebhook(ctx *cli.Context) error {
-	printInfo("security-profiles-operator-webhook")
+func runWebhook(ctx *cli.Context, info *version.Info) error {
+	printInfo("security-profiles-operator-webhook", info)
 	cfg, err := ctrl.GetConfig()
 	if err != nil {
 		return errors.Wrap(err, "get config")
diff --git a/dependencies.yaml b/dependencies.yaml
index 8fb867260..36468bbd3 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -24,7 +24,7 @@ dependencies:
       match: REPO_INFRA_VERSION
 
   - name: kustomize
-    version: 4.5.2
+    version: 4.5.3
     refPaths:
     - path: Makefile
       match: KUSTOMIZE_VERSION
diff --git a/internal/pkg/version/version.go b/internal/pkg/version/version.go
index 67a2b2f8f..6186a9b33 100644
--- a/internal/pkg/version/version.go
+++ b/internal/pkg/version/version.go
@@ -50,8 +50,11 @@ type Info struct {
 	Dependencies  []string `json:"dependencies,omitempty"`
 }
 
-func Get() *Info {
-	info, _ := debug.ReadBuildInfo()
+func Get() (*Info, error) {
+	info, ok := debug.ReadBuildInfo()
+	if !ok {
+		return nil, errors.New("unable to retrieve build info")
+	}
 
 	const unknown = "unknown"
 	gitCommit := unknown
@@ -108,7 +111,7 @@ func Get() *Info {
 		LDFlags:       ldFlags,
 		CGOLDFlags:    cgoLdflags,
 		Dependencies:  dependencies,
-	}
+	}, nil
 }
 
 // String returns the string representation of the version info.


Test patch:
diff --git a/internal/pkg/version/version_test.go b/internal/pkg/version/version_test.go
index cfc0e9f01..eee1f95d7 100644
--- a/internal/pkg/version/version_test.go
+++ b/internal/pkg/version/version_test.go
@@ -25,7 +25,8 @@ import (
 func TestVersionText(t *testing.T) {
 	t.Parallel()
 
-	sut := Get()
+	sut, err := Get()
+	require.Nil(t, err)
 	require.NotEmpty(t, sut.BuildDate)
 	require.NotEmpty(t, sut.Compiler)
 	require.NotEmpty(t, sut.GitCommit)
@@ -39,13 +40,17 @@ func TestVersionText(t *testing.T) {
 func TestVersionJSON(t *testing.T) {
 	t.Parallel()
 
-	sut, err := Get().JSONString()
+	sut, err := Get()
+	require.Nil(t, err)
+	json, err := sut.JSONString()
 	require.Nil(t, err)
-	require.NotEmpty(t, sut)
+	require.NotEmpty(t, json)
 }
 
 func TestAsKeyValues(t *testing.T) {
 	t.Parallel()
-	sut := Get().AsKeyValues()
-	require.Len(t, sut, 2*14)
+	sut, err := Get()
+	require.Nil(t, err)
+	kv := sut.AsKeyValues()
+	require.Len(t, kv, 2*14)
 }