Skip to content

docs: Document SOURCE_DATE_EPOCH for reproducible chart archives#2180

Open
promptless-for-oss wants to merge 2 commits into
helm:mainfrom
Promptless:promptless/document-source-date-epoch-reproducible-archives
Open

docs: Document SOURCE_DATE_EPOCH for reproducible chart archives#2180
promptless-for-oss wants to merge 2 commits into
helm:mainfrom
Promptless:promptless/document-source-date-epoch-reproducible-archives

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open this suggestion in Promptless to view citations and reasoning process

Adds a "Build Reproducible Chart Archives" section to the Chart Development Tips and Tricks how-to, documenting how SOURCE_DATE_EPOCH stamps archive file modification times via helm package, its value semantics (non-negative integer seconds, UTC, error on invalid/negative), and the limited scope for install/upgrade/dependency commands. Covers helm/helm#32162.

Trigger Events


Tip: Filter the Dashboard by labels or assignees to focus on what matters to you 🔎

Add a how-to section explaining how to set SOURCE_DATE_EPOCH to produce
reproducible chart archives with helm package, including value semantics
and the scope of the four other commands that honor it.

relates to helm/helm#32162

Signed-off-by: promptless[bot] <promptless[bot]@users.noreply.github.com>
## Build Reproducible Chart Archives

By default, the files inside a packaged chart archive (`.tgz`)
carry the modification times of the source files on disk.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented that Helm honors SOURCE_DATE_EPOCH to stamp chart archive file modification times, based on PR #32162 which added sourceDateEpochFromEnv() in pkg/cmd/source_date_epoch.go and StampModTimes in pkg/chart/v2/chart.go, applied before archiving in pkg/action/package.go.

Source: helm/helm#32162

Keep the following in mind when you use `SOURCE_DATE_EPOCH`:

- The value must be a non-negative integer.
Helm interprets it as whole seconds in UTC and does not support sub-second precision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value semantics come from sourceDateEpochFromEnv() in pkg/cmd/source_date_epoch.go: it parses the value with strconv.ParseInt as whole seconds and converts via time.Unix(epoch, 0).UTC(), returns nil for unset/empty, and errors with invalid SOURCE_DATE_EPOCH for non-numeric or negative values.

Source: https://github.com/helm/helm/pull/32162/files

- When the variable is unset or empty,
Helm keeps the default behavior,
where archive entries reflect the actual file modification times.
- `helm install`, `helm upgrade`, `helm dependency build`, and `helm dependency update`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file://-only scope for install/upgrade/dependency build/dependency update reflects pkg/downloader/manager.go, where the epoch is passed into the download Manager but only applied inside tarFromLocalDir when re-archiving dependencies from a local file:// repository; remotely fetched dependency archives are stored unchanged.

Source: https://github.com/helm/helm/pull/32162/files

…POCH

Charts with a Chart.lock now produce byte-identical archives across builds
when SOURCE_DATE_EPOCH is set, because the lockfile's generated: field is
stamped with the same normalized (UTC, whole-second) timestamp.

Refs helm/helm#32403, helm/helm#32396

Signed-off-by: promptless[bot] <promptless[bot]@users.noreply.github.com>

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Just a reminder: If you'd like me to act on any feedback you have via Github comments, just type @Promptless in your suggestion and I'll get right on it! (I won't show up in the user dropdown, but I'll process any request that has @Promptless in the comment body.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants