Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: version callouts #19452

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions content/build/building/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Setting `NO_COLOR` to anything turns off colorized output, as recommended by

### BUILDKIT_HOST

_Introduced in [Buildx v0.9.0](../release-notes.md#090)_
{{< introduced buildx 0.9.0 "../release-notes.md#090" >}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not rendered because 0.9.0 is below the threshold set in site.Params.min_version_thresholds.buildx

Also generates a warning: https://github.com/docker/docs/actions/runs/7974560715/job/21770734246?pr=19452#step:4:301


You use the `BUILDKIT_HOST` to specify the address of a BuildKit daemon to use
as a remote builder. This is the same as specifying the address as a positional
Expand Down Expand Up @@ -465,7 +465,7 @@ $ export BUILDX_EXPERIMENTAL=1

### BUILDX_GIT_CHECK_DIRTY

_Introduced in [Buildx v0.10.4](../release-notes.md#0104)_
{{< introduced buildx 0.10.4 "../release-notes.md#0104" >}}

When set to true, checks for dirty state in source control information for
[provenance attestations](../attestations/slsa-provenance.md).
Expand All @@ -478,7 +478,7 @@ $ export BUILDX_GIT_CHECK_DIRTY=1

### BUILDX_GIT_INFO

_Introduced in [Buildx v0.10.0](../release-notes.md#0100)_
{{< introduced buildx 0.10.0 "../release-notes.md#0100" >}}

When set to false, removes source control information from
[provenance attestations](../attestations/slsa-provenance.md).
Expand All @@ -491,7 +491,7 @@ $ export BUILDX_GIT_INFO=0

### BUILDX_GIT_LABELS

_Introduced in [Buildx v0.10.0](../release-notes.md#0100)_
{{< introduced buildx 0.10.0 "../release-notes.md#0100" >}}

Adds provenance labels, based on Git information, to images that you build. The
labels are:
Expand Down Expand Up @@ -520,7 +520,7 @@ If the repository is in a dirty state, the `revision` gets a `-dirty` suffix.

### BUILDX_NO_DEFAULT_ATTESTATIONS

_Introduced in [Buildx v0.10.4](../release-notes.md#0104)_
{{< introduced buildx 0.10.4 "../release-notes.md#0104" >}}

By default, BuildKit v0.11 and later adds
[provenance attestations](../attestations/slsa-provenance.md) to images you
Expand Down
10 changes: 8 additions & 2 deletions hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ params:
example_alpine_version: "3.19"
example_node_version: "20"

min_api_threshold: 1.41

min_version_thresholds:
Copy link
Member

Choose a reason for hiding this comment

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

Is it n-2 based? (n being the latest stable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, these are arbitrary atm so we need to decide. n-2 could be a good default. It might depend what the threshold is depending on the component, e.g. for Desktop n-2 might be too aggressive.

buildx: "0.10.0"
buildkit: "0.11.0"
engine: "24.0.0"
api: "1.41"
desktop: "4.20.0"
compose: "2.20.0"
scout: "1.0.0"

menus:
main:
Expand Down
17 changes: 17 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,20 @@ apiPropReq:
other: Required
apiPropDesc:
other: Description

## component names

buildx:
other: Buildx
buildkit:
other: BuildKit
engine:
other: Docker Engine
api:
other: Engine API
desktop:
other: Docker Desktop
compose:
other: Docker Compose
scout:
other: Docker Scout
59 changes: 59 additions & 0 deletions layouts/shortcodes/introduced.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- /*
Renders a version callout for when a feature was introduced in a component.

Accepts positional parameters.
Depends on site.Params.min_version_thresholds and i18n strings for component IDs

@param {string} component The ID of the component as defined in site config.
@param {string} version The version of the component in which the thing was introduced.
@param {string} [link] A relevant link to e.g. release note.

@returns {template.HTML}

@examples

{{< introduced buildx 0.12.0 "../release-notes.md#0120" >}}

{{< introduced desktop "4.28" "https://example.com/" >}}

*/ -}}

{{- $component := .Get 0 }}
{{- $v := .Get 1 }}
{{- $link := .Get 2 }}
{{- $pos := .Position }}
{{- with (index site.Params.min_version_thresholds $component) }}
{{- /*
Hacky semver comparison.

- Split the input version and threshold version strings
- Range over the input version []string
- Cast to ints and compare input with same index threshold []string
- Set threshold false if input is lower than config, and break
*/ -}}
{{ $vslice := strings.Split $v "." }}
{{ $tslice := strings.Split . "." }}
{{ $versionAboveThreshold := true }}
{{ range $i, $e := $vslice }}
{{ if compare.Lt (cast.ToInt $e) (cast.ToInt (index $tslice $i)) }}
{{ $versionAboveThreshold = false }}
{{ break }}
{{ end }}
{{ end }}
{{- if $versionAboveThreshold }}
<div class="text-gray-light dark:text-gray-dark flex items-center gap-2">
<span class="icon-svg flex items-center">{{ partial "icon.html" "chevron_right" }}</span>
<span>Introduced in {{ T $component }} version
{{- if $link }}
{{ page.RenderString (fmt.Printf `[%s](%s)` $v $link) }}
{{- else }}
{{ $v }}
{{- end }}
</span>
</div>
{{- else }}
{{ warnf "[introduced] version below threshold: %s %s %v" $component $v $pos }}
{{- end }}
{{- else }}
{{ errorf "[introduced] invalid component: %s %v" $component $pos }}
{{- end }}
Loading