-
Notifications
You must be signed in to change notification settings - Fork 927
Expand file tree
/
Copy pathkf-version-notice.html
More file actions
111 lines (106 loc) · 5.64 KB
/
Copy pathkf-version-notice.html
File metadata and controls
111 lines (106 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{{ .Page.Store.Set "hasPopper" true }}
{{- $version_full := replaceRE `\s` "" .Inner }}
{{- $version_short := cond (eq (strings.Count "." $version_full) 1) $version_full (replaceRE `^(\d+)\.(\d+)\.(\d+).*` `$1.$2` $version_full) }}
{{- $latest_release_json_path := "release-info/latest.json" }}
{{- $latest_release_json := .Page.Resources.Get $latest_release_json_path }}
{{- if not $latest_release_json }}
{{- errorf `Failed to get "latest" release info, no file at %q.` $latest_release_json_path }}
{{- end }}
{{- $latest_release := $latest_release_json | transform.Unmarshal }}
{{- $latest_release_full := cond (strings.HasPrefix $latest_release.tag "v") ($latest_release.tag | replaceRE `^v(\d+)\.(\d+)\.(\d+).*` `$1.$2.$3`) $latest_release.tag }}
{{- $latest_release_major := 0 }}
{{- $latest_release_minor := 0 }}
{{- if strings.HasPrefix $latest_release.tag "v" }}
{{- $latest_release_major = $latest_release.tag | replaceRE `^v(\d+)\.(\d+)\.(\d+).*` `$1` | int }}
{{- $latest_release_minor = $latest_release.tag | replaceRE `^v(\d+)\.(\d+)\.(\d+).*` `$2` | int }}
{{- else }}
{{- /* CalVer format: YY.MM (e.g. "26.03") */}}
{{- $latest_release_major = $latest_release.tag | replaceRE `^(\d+)\..*` `$1` | int }}
{{- $latest_release_minor = $latest_release.tag | replaceRE `^\d+\.(\d+).*` `$1` | int }}
{{- end }}
{{- $version_is_calver := eq (strings.Count "." $version_full) 1 }}
{{- $this_release_json_path := cond $version_is_calver (printf "release-info/%s.json" $version_full) (printf "release-info/v%s.json" $version_full) }}
{{- $this_release_json := .Page.Resources.Get $this_release_json_path }}
{{- if not $this_release_json }}
{{- errorf "Failed to get release info for version %q, no file at %q.\n\n\n!!!! TIP: run the './content/en/docs/started/installing-kubeflow/get_new_releases.sh' to update Kubeflow release information !!!!\n\n\n" $version_full $this_release_json_path $version_full }}
{{- end }}
{{- $this_release := $this_release_json | transform.Unmarshal }}
{{- $this_release_major := 0 }}
{{- $this_release_minor := 0 }}
{{- if strings.HasPrefix $this_release.tag "v" }}
{{- $this_release_major = $this_release.tag | replaceRE `^v(\d+)\.(\d+)\.(\d+).*` `$1` | int }}
{{- $this_release_minor = $this_release.tag | replaceRE `^v(\d+)\.(\d+)\.(\d+).*` `$2` | int }}
{{- else }}
{{- /* CalVer format: YY.MM (e.g. "26.03") */}}
{{- $this_release_major = $this_release.tag | replaceRE `^(\d+)\..*` `$1` | int }}
{{- $this_release_minor = $this_release.tag | replaceRE `^\d+\.(\d+).*` `$1` | int }}
{{- end }}
{{- $this_release_date := $this_release.publish_date | time.AsTime }}
{{- $this_release_date_string := $this_release_date | time.Format ":date_long" }}
{{- $latest_is_calver := not (strings.HasPrefix $latest_release.tag "v") }}
{{- $this_is_calver := not (strings.HasPrefix $this_release.tag "v") }}
{{- $this_version_lag := 0 }}
{{- if and $latest_is_calver $this_is_calver }}
{{- /* Both CalVer: compute lag in months */}}
{{- $this_version_lag = sub (add (mul $latest_release_major 12) $latest_release_minor) (add (mul $this_release_major 12) $this_release_minor) }}
{{- else if and (not $latest_is_calver) (not $this_is_calver) }}
{{- /* Both semver: compare minor versions */}}
{{- $this_version_lag = sub $latest_release_minor $this_release_minor }}
{{- else }}
{{- /* Mixed schemes: this is a legacy semver release, latest is CalVer */}}
{{- $this_version_lag = -1 }}
{{- end }}
{{- $popup_content_prefix := "" }}
{{- if lt $this_version_lag 0 }}
{{- $popup_content_prefix = printf "Kubeflow %s was initially released on <strong>%s</strong> and is 1 version behind the latest release. This is a legacy semver release; the project has since moved to CalVer versioning." $version_full $this_release_date_string }}
{{- else }}
{{- $popup_content_prefix = printf "Kubeflow %s was initially released on <strong>%s</strong> and is <strong>%d</strong> minor versions behind the latest release." $version_full $this_release_date_string $this_version_lag }}
{{- end }}
{{- $popup_content_suffix := "Distributions are supported by their maintainers. Contact the provider for information on support and updates." }}
{{- $button_style := "" }}
{{- $popup_icon := "" }}
{{- $popup_title := "" }}
{{- $popup_content := "" }}
{{- if eq $this_version_lag 0 }}
{{- $button_style = "btn-outline-primary" }}
{{- $popup_icon = "" }}
{{- $popup_title = "Version Info" }}
{{- $popup_content = printf `%s<br><br>%s` $popup_content_prefix $popup_content_suffix }}
{{- else if eq $this_version_lag 1 }}
{{- $button_style = "btn-outline-primary" }}
{{- $popup_icon = "" }}
{{- $popup_title = "Version Info" }}
{{- $popup_content = printf `%s<br><br>%s` $popup_content_prefix $popup_content_suffix }}
{{- else if eq $this_version_lag 2 }}
{{- $button_style = "btn-outline-primary" }}
{{- $popup_icon = "" }}
{{- $popup_title = "Version Info" }}
{{- $popup_content = printf `%s<br><br>%s` $popup_content_prefix $popup_content_suffix }}
{{- else }}
{{- $button_style = "btn-outline-primary" }}
{{- $popup_icon = "" }}
{{- $popup_title = "Version Info" }}
{{- $popup_content = printf `%s<br><br>%s` $popup_content_prefix $popup_content_suffix }}
{{- end }}
<button
type="button"
class="btn btn-sm {{ $button_style }} d-block d-lg-inline mb-2 mb-lg-0"
data-container="body"
data-placement="right"
data-toggle="popover"
data-trigger="hover focus"
data-html="true"
title="{{ $popup_title }}"
data-content="{{ $popup_content }}"
>
{{- if $popup_icon }}
<i class="fas {{ $popup_icon }}"></i>
{{- end }}
<span>
{{- if eq $this_version_lag 0 }}
<strong>{{ $version_short }}</strong>
{{- else }}
{{ $version_short }}
{{- end }}
</span>
</button>