diff --git a/layouts/_default/cve-feed.json b/layouts/_default/cve-feed.json index 3812e9533b..1f5f458d14 100644 --- a/layouts/_default/cve-feed.json +++ b/layouts/_default/cve-feed.json @@ -1 +1,20 @@ -{{ getJSON .Site.Params.cveFeedBucket | jsonify }} +{{- $url := .Site.Params.cveFeedBucket -}} +{{- with resources.GetRemote $url -}} + {{- if .Err -}} + {{- $message := printf "Failed to retrieve CVE data: %s" .Err -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} + {{- else -}} + {{- .Content | transform.Unmarshal | jsonify -}} + {{- end -}} +{{- else -}} + {{- $message := printf "Unable to fetch CVE data from the specified URL: %q" $url -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/layouts/_default/cve-feed.rss.xml b/layouts/_default/cve-feed.rss.xml index 811469c924..105cab7b8c 100644 --- a/layouts/_default/cve-feed.rss.xml +++ b/layouts/_default/cve-feed.rss.xml @@ -1,4 +1,25 @@ -{{ $feed := getJSON .Site.Params.cveFeedBucket -}} +{{- $url := .Site.Params.cveFeedBucket -}} +{{- $feed := "" -}} + +{{- with resources.GetRemote $url -}} + {{- if .Err -}} + {{- $message := printf "Failed to retrieve CVE data: %s" .Err -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} + {{- else -}} + {{- $feed = .Content | transform.Unmarshal -}} + {{- end -}} +{{- else -}} + {{- $message := printf "Unable to fetch CVE data from the specified URL: %q" $url -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} +{{- end -}} {{ $feed.title }} @@ -7,7 +28,10 @@ Hugo -- gohugo.io en-US {{ .Site.Params.Copyright_k8s }} + + {{- if ne $feed nil -}} {{ time.Format "Mon, 02 Jan 2006 15:04:05 -0700" $feed._kubernetes_io.updated_at | safeHTML }} + {{- end -}} {{ with .OutputFormats.Get "RSS" -}} {{ printf "" .Permalink .MediaType | safeHTML }} {{ end -}} diff --git a/layouts/shortcodes/cve-feed.html b/layouts/shortcodes/cve-feed.html index 8b829079fb..02a1918864 100644 --- a/layouts/shortcodes/cve-feed.html +++ b/layouts/shortcodes/cve-feed.html @@ -1,7 +1,39 @@ -{{ $feed := getJSON .Site.Params.cveFeedBucket }} -{{ if ne $feed.version "https://jsonfeed.org/version/1.1" }} - {{ warnf "CVE feed shortcode. KEP-3203: CVE feed does not comply with JSON feed v1.1." }} -{{ end }} +{{- $url := .Site.Params.cveFeedBucket }} +{{- $feed := "" -}} + +{{- with resources.GetRemote $url -}} + {{- if .Err -}} + + {{- $message := printf "Failed to retrieve CVE data: %s" .Err -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} + {{- else -}} + + {{- $feed = .Content | transform.Unmarshal -}} + {{- if ne $feed.version "https://jsonfeed.org/version/1.1" -}} + {{- $warningMessage := "CVE feed shortcode. KEP-3203: CVE feed does not comply with JSON feed v1.1." -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $warningMessage -}} + {{- else -}} + {{- warnf $warningMessage -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- else -}} + + {{- $message := printf "Unable to fetch CVE data from the specified URL: %q" $url -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} +{{- end -}} + + +{{ if ne $feed nil }} @@ -21,3 +53,4 @@ {{ end }}
{{ T "cve_table" }} {{ printf (T "cve_table_date_format_string") ($feed._kubernetes_io.updated_at | time.Format (T "cve_table_date_format")) }}
+{{- end -}} diff --git a/layouts/shortcodes/release-binaries.html b/layouts/shortcodes/release-binaries.html index 6eef11dda2..f34b6ac16d 100644 --- a/layouts/shortcodes/release-binaries.html +++ b/layouts/shortcodes/release-binaries.html @@ -1,6 +1,29 @@ -{{ $response := getJSON "https://raw.githubusercontent.com/kubernetes-sigs/downloadkubernetes/master/dist/release_binaries.json" }} +{{- $url := "https://raw.githubusercontent.com/kubernetes-sigs/downloadkubernetes/master/dist/release_binaries.json" }} +{{- $response := "" }} +{{- with resources.GetRemote $url -}} + {{- if .Err -}} + {{- $message := printf "Failed to retrieve release binaries data: %s" .Err -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} + {{- else -}} + {{- $response = .Content | transform.Unmarshal }} + {{- end -}} +{{- else -}} + {{ $message := printf "Unable to fetch release binaries data from the specified URL: %q" $url -}} + {{- if eq hugo.Environment "production" -}} + {{- errorf $message -}} + {{- else -}} + {{- warnf $message -}} + {{- end -}} +{{- end -}} + + +{{ if ne $response nil }} {{ $currentVersion := site.Params.version }} {{ $Binaries := slice }} @@ -127,4 +150,5 @@ - \ No newline at end of file + +{{- end -}} \ No newline at end of file