Repository: shipwright-io/build
Pull request #1750 (2024-12-13 15:22:25)

Add file listing environment variables to documentation
# Changes

Add `GIT_SHOW_LISTING` and `BUNDLE_SHOW_LISTING` to the default configuration to make them explicit.

Add details about `GIT_SHOW_LISTING` and `BUNDLE_SHOW_LISTING` to the configuration documentation.

Reference: https://github.com/shipwright-io/website/issues/135

# Submitter Checklist

- [ ] Includes tests if functionality changed/was added
- [X] Includes docs if changes are user-facing
- [X] [Set a kind label on this PR](https://prow.k8s.io/command-help#kind)
- [X] Release notes block has been filled in, or marked NONE

See [the contributor guide](https://github.com/shipwright-io/build/blob/main/CONTRIBUTING.md)
for details on coding conventions, github and prow interactions, and the code review process.

# Release Notes

```release-note
NONE
```


openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
**Once this PR has been reviewed and has the lgtm label**, please ask for approval from [heavywombat](https://github.com/heavywombat). For more information see [the Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

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

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

- **[OWNERS](https://github.com/shipwright-io/build/blob/main/OWNERS)**

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":["heavywombat"]} -->

Patch:
diff --git a/docs/configuration.md b/docs/configuration.md
index ae23ebb9..1abecc1d 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -18,9 +18,9 @@ The following environment variables are available:
 | `REMOTE_ARTIFACTS_CONTAINER_IMAGE`               | Specify the container image used for the `.spec.sources` remote artifacts download, by default it uses `quay.io/quay/busybox:latest`.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
 | `TERMINATION_LOG_PATH`                           | Path of the termination log. This is where controller application will write the reason of its termination. Default value is `/dev/termination-log`.                                                                                                                                                                                                                                                                                                                                                                                                                     |
 | `GIT_ENABLE_REWRITE_RULE`                        | Enable Git wrapper to setup a URL `insteadOf` Git config rewrite rule for the respective source URL hostname. Default is `false`.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
-| `GIT_CONTAINER_TEMPLATE`                         | JSON representation of a [Container] template that is used for steps that clone a Git repository. Default is `{"image": "ghcr.io/shipwright-io/build/git:latest", "command": ["/ko-app/git"], "env": [{"name": "HOME", "value": "/shared-home"}], "securityContext":{"allowPrivilegeEscalation": false, "capabilities": {"drop": ["ALL"]}, "runAsUser": 1000,"runAsGroup": 1000}}` [^1]. The following properties are ignored as they are set by the controller: `args`, `name`.                                                                                         |
+| `GIT_CONTAINER_TEMPLATE`                         | JSON representation of a [Container] template that is used for steps that clone a Git repository. Default is `{"image": "ghcr.io/shipwright-io/build/git:latest", "command": ["/ko-app/git"], "env": [{"name": "HOME", "value": "/shared-home"},{"name": "GIT_SHOW_LISTING", "value": "false"}], "securityContext":{"allowPrivilegeEscalation": false, "capabilities": {"drop": ["ALL"]}, "runAsUser": 1000,"runAsGroup": 1000}}` [^1]. The following properties are ignored as they are set by the controller: `args`, `name`.                                          |
 | `GIT_CONTAINER_IMAGE`                            | Custom container image for Git clone steps. If `GIT_CONTAINER_TEMPLATE` is also specifying an image, then the value for `GIT_CONTAINER_IMAGE` has precedence.                                                                                                                                                                                                                                                                                                                                                                                                            |
-| `BUNDLE_CONTAINER_TEMPLATE`                      | JSON representation of a [Container] template that is used for steps that pulls a bundle image to obtain the packaged source code. Default is `{"image": "ghcr.io/shipwright-io/build/bundle:latest", "command": ["/ko-app/bundle"], "env": [{"name": "HOME","value": "/shared-home"}], "securityContext":{"allowPrivilegeEscalation": false, "capabilities": {"drop": ["ALL"]}, "runAsUser":1000,"runAsGroup":1000}}` [^1]. The following properties are ignored as they are set by the controller: `args`, `name`.                                                     |
+| `BUNDLE_CONTAINER_TEMPLATE`                      | JSON representation of a [Container] template that is used for steps that pulls a bundle image to obtain the packaged source code. Default is `{"image": "ghcr.io/shipwright-io/build/bundle:latest", "command": ["/ko-app/bundle"], "env": [{"name": "HOME","value": "/shared-home"},{"name": "BUNDLE_SHOW_LISTING","value": "false"}], "securityContext":{"allowPrivilegeEscalation": false, "capabilities": {"drop": ["ALL"]}, "runAsUser":1000,"runAsGroup":1000}}` [^1]. The following properties are ignored as they are set by the controller: `args`, `name`.    |
 | `BUNDLE_CONTAINER_IMAGE`                         | Custom container image that pulls a bundle image to obtain the packaged source code. If `BUNDLE_IMAGE_CONTAINER_TEMPLATE` is also specifying an image, then the value for `BUNDLE_IMAGE_CONTAINER_IMAGE` has precedence.                                                                                                                                                                                                                                                                                                                                                 |
 | `IMAGE_PROCESSING_CONTAINER_TEMPLATE`            | JSON representation of a [Container](https://pkg.go.dev/k8s.io/api/core/v1#Container) template that is used for steps that processes the image. Default is `{"image": "ghcr.io/shipwright-io/build/image-processing:latest", "command": ["/ko-app/image-processing"], "env": [{"name": "HOME","value": "/shared-home"}], "securityContext": {"allowPrivilegeEscalation": false, "capabilities": {"add": ["DAC_OVERRIDE"], "drop": ["ALL"]}, "runAsUser": 0, "runAsgGroup": 0}}`. The following properties are ignored as they are set by the controller: `args`, `name`. |
 | `IMAGE_PROCESSING_CONTAINER_IMAGE`               | Custom container image that is used for steps that processes the image. If `IMAGE_PROCESSING_CONTAINER_TEMPLATE` is also specifying an image, then the value for `IMAGE_PROCESSING_CONTAINER_IMAGE` has precedence.                                                                                                                                                                                                                                                                                                                                                      |
@@ -63,3 +63,19 @@ This can be changed by creating a separate [Kubernetes `ClusterRole`] with these
 [Kubernetes "view" role]:https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings
 [Kubernetes "edit" and "admin" roles]:https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings
 [Kubernetes `ClusterRole`]:https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole
+
+## Git Source Step Settings
+
+Environment variables for the Git Source Step need to be set via the respective container template, see `GIT_CONTAINER_TEMPLATE` for reference.
+
+| Environment Variable | Description                                                                                                             |
+|----------------------|-------------------------------------------------------------------------------------------------------------------------|
+| `GIT_SHOW_LISTING`   | Specify whether a file listing of the source step is printed, disabled by default. Use `true` to enable a file listing. |
+
+## Bundle Source Step Settings
+
+Environment variables for the Bundle Source Step need to be set via the respective container template, see `BUNDLE_CONTAINER_TEMPLATE` for reference.
+
+| Environment Variable  | Description                                                                                                             |
+|-----------------------|-------------------------------------------------------------------------------------------------------------------------|
+| `BUNDLE_SHOW_LISTING` | Specify whether a file listing of the source step is printed, disabled by default. Use `true` to enable a file listing. |
diff --git a/pkg/config/config.go b/pkg/config/config.go
index d61715dd..72d65335 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -175,6 +175,10 @@ func NewDefaultConfig() *Config {
 					Name:  "HOME",
 					Value: "/shared-home",
 				},
+				{
+					Name:  "GIT_SHOW_LISTING",
+					Value: "false",
+				},
 			},
 			SecurityContext: &corev1.SecurityContext{
 				AllowPrivilegeEscalation: ptr.To(false),
@@ -199,6 +203,10 @@ func NewDefaultConfig() *Config {
 					Name:  "HOME",
 					Value: "/shared-home",
 				},
+				{
+					Name:  "BUNDLE_SHOW_LISTING",
+					Value: "false",
+				},
 			},
 			SecurityContext: &corev1.SecurityContext{
 				AllowPrivilegeEscalation: ptr.To(false),


Test patch:
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 226940a9..569cc92d 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -131,7 +131,10 @@ var _ = Describe("Config", func() {
 					Command: []string{
 						"/ko-app/git",
 					},
-					Env: []corev1.EnvVar{{Name: "HOME", Value: "/shared-home"}},
+					Env: []corev1.EnvVar{
+						{Name: "HOME", Value: "/shared-home"},
+						{Name: "GIT_SHOW_LISTING", Value: "false"},
+					},
 					SecurityContext: &corev1.SecurityContext{
 						AllowPrivilegeEscalation: ptr.To(false),
 						Capabilities: &corev1.Capabilities{