Skip to content

Commit c4679da

Browse files
authoredJul 14, 2023
GitHub actions Build, Test and Release workflows (#94)
* Switching to Github Codeowners * Generate Codecoverage reports * Initial Build workflows * Upgrade to go1.18 * Fix Code Owners * Swith to ubuntu-latest * General fixes * Update to go 1.20 * Initial Dependabot setup * Upgrade all the things * Fix up testcoverage check * Switching to Go-lang/jwt * Only build the image if lint and tests pass * Simple Helm lint Test * Update Dockerfile to alpine:3.17.2 * helm chart fixes (#102) * Adding Error Counter Metric * Adding Semver Prefix and fix typo * Revert "helm chart fixes (#102)" (#103) This reverts commit 9185224. * Resolve issue 63 (#101) * Allow for overriding Token Path (#100) * Increase the number of Tags fetched for Docker Registries (#99) * Adding k8s.io support (#98) * Better support for selfHosted and SSL connections (#95) * Enable SSL Skip Verify if you're unable to provide a valid certificate bundle * Allow for additional Certs to be added into the CA Chain * Update README.md for helm installation * Adding initial release workflow * Build multi-arch images * Fix Dockerfile build artifact * Tag and Upload to quay.io/jetstack/version-checker instead of docker hub * Swithcing to main as the default branch changed * Set up for review * Switch to using sha for PR builds
1 parent 93df732 commit c4679da

File tree

16 files changed

+677
-525
lines changed

16 files changed

+677
-525
lines changed
 

‎.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @davidcollom

‎.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 0
8+
9+
- package-ecosystem: "gomod"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
13+
open-pull-requests-limit: 0

‎.github/workflows/build-test.yaml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Test & Build
2+
on:
3+
pull_request:
4+
branches:
5+
- 'main'
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
lint:
13+
permissions:
14+
contents: read # for actions/checkout to fetch code
15+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
16+
name: Lint Go code
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
21+
- name: Setup Golang
22+
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.0
23+
- name: Run golangci-lint
24+
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
25+
with:
26+
version: v1.53
27+
args: --timeout 10m --exclude SA5011 --verbose --issues-exit-code=0
28+
only-new-issues: true
29+
30+
test:
31+
name: Run unit tests for Go packages
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v3 # v3.5.3
36+
- name: Setup Go
37+
uses: actions/setup-go@v4
38+
39+
- name: Download and required packages
40+
run: |
41+
make deps
42+
43+
- name: Run all unit tests
44+
run: make test
45+
46+
- name: check test coverage
47+
uses: vladopajic/go-test-coverage@v2
48+
with:
49+
config: ./.testcoverage.yml
50+
51+
- name: Generate code coverage artifacts
52+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
53+
with:
54+
name: code-coverage
55+
path: coverage.out
56+
57+
build:
58+
needs:
59+
- test
60+
- lint
61+
runs-on: ubuntu-latest
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
platform:
66+
- linux/amd64
67+
- linux/arm64
68+
- linux/arm/v7
69+
name: Build Images
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v2
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v2
78+
with:
79+
platforms: ${{ matrix.platform }}
80+
81+
- name: Login to Docker Hub
82+
uses: docker/login-action@v2
83+
with:
84+
registry: quay.io
85+
username: ${{ secrets.QUAY_USERNAME }}
86+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
87+
88+
- name: Build and push
89+
uses: docker/build-push-action@v4
90+
with:
91+
context: .
92+
platforms: ${{ matrix.platform }}
93+
push: false
94+
tags: quay.io/jetstack/version-checker:${{github.sha}}
95+
cache-from: type=gha
96+
cache-to: type=gha,mode=max

‎.github/workflows/helm-test.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test Helm Chart
2+
on:
3+
pull_request:
4+
paths:
5+
- 'deploy/charts/version-checker/**'
6+
branches:
7+
- 'main'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
permissions:
16+
contents: read # for actions/checkout to fetch code
17+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
18+
name: Lint Helm Chart
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
23+
24+
- uses: azure/setup-helm@v3
25+
26+
- run: helm lint deploy/charts/version-checker
27+
28+
test:
29+
name: Run unit tests for Helm Chart
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
34+
35+
- uses: azure/setup-helm@v3
36+
with:
37+
token: ${{ github.token }}
38+
39+
- name: Install helm Plugins
40+
run: |
41+
if [ ! -e "${HELM_PLUGINS}/helm-unittest" ]; then
42+
helm plugin install https://github.com/helm-unittest/helm-unittest.git
43+
fi
44+
45+
- name: Run Tests
46+
run: |
47+
if [ ! -e "deploy/charts/verson-checker/tests" ]; then
48+
echo "Not running tests, directory doesn't exist: deploy/charts/verson-checker/tests"
49+
exit 0
50+
fi
51+
helm unittest --helm3 --color deploy/charts/verson-checker

‎.github/workflows/release.yaml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Version-Checker Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release-.*'
7+
tags:
8+
- '*'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
helm-release:
16+
if: startsWith(github.ref, 'refs/tags/')
17+
runs-on: ubuntu-latest
18+
steps:
19+
# Checkout our Repo
20+
- uses: actions/checkout@v3
21+
with:
22+
path: version-checker
23+
24+
- name: checkout jetstack-charts
25+
uses: actions/checkout@v3
26+
with:
27+
token: ${{ secrets.JETSTACK_CHARTS_PAT }}
28+
repository: jetstack/jetstack-charts
29+
ref: main
30+
path: jetstack-charts
31+
32+
- uses: azure/setup-helm@v3
33+
with:
34+
token: ${{ github.token }}
35+
36+
- name: package helm chart
37+
run: |
38+
helm package version-checker/deploy/charts/version-checker -d jetstack-charts/charts/
39+
40+
- name: Creating PR
41+
uses: peter-evans/create-pull-request@v5
42+
with:
43+
token: ${{ secrets.JETSTACK_CHARTS_PAT }}
44+
title: "Release version-checker ${{github.ref_name }}"
45+
commit-message: "Release version-checker ${{github.ref_name }}"
46+
branch: version-checker/${{github.ref_name}}
47+
path: jetstack-charts
48+
add-paths: charts/*.tgz
49+
delete-branch: true
50+
signoff: true
51+
base: main
52+
draft: ${{ contains('-rc', github.ref_name) || !startsWith(github.ref, 'refs/tags/') }}
53+
54+
docker-release:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
platform:
60+
- linux/amd64
61+
- linux/arm64
62+
- linux/arm/v7
63+
steps:
64+
- uses: actions/checkout@v3
65+
- name: Set up QEMU
66+
uses: docker/setup-qemu-action@v2
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v2
70+
with:
71+
platforms: ${{ matrix.platform }}
72+
73+
- name: Login to Docker Hub
74+
uses: docker/login-action@v2
75+
with:
76+
registry: quay.io
77+
username: ${{ secrets.QUAY_USERNAME }}
78+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
79+
80+
- name: Build and push (if applicable)
81+
uses: docker/build-push-action@v4
82+
with:
83+
context: .
84+
platforms: ${{ matrix.platform }}
85+
push: ${{ !startsWith(github.ref, 'refs/tags/') }}
86+
tags: quay.io/jetstack/version-checker:${{github.ref_name}}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
90+
91+
github-release:
92+
permissions:
93+
contents: write
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v3
97+
98+
- name: Create Release / Change Logs
99+
uses: softprops/action-gh-release@v1
100+
with:
101+
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
102+
prerelease: ${{ contains('-rc', github.ref_name) || !startsWith(github.ref, 'refs/tags/') }}
103+
generate_release_notes: true

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/bin
2+
coverage.out

‎.testcoverage.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# (mandatory)
2+
# Path to coverprofile file (output of `go test -coverprofile` command)
3+
profile: coverage.out
4+
5+
# (optional)
6+
# When specified reported file paths will not contain local prefix in the output
7+
# local-prefix: "github.com/org/project"
8+
9+
# Holds coverage thresholds percentages, values should be in range [0-100]
10+
threshold:
11+
# (optional; default 0)
12+
# The minimum coverage that each file should have
13+
file: 0
14+
15+
# (optional; default 0)
16+
# The minimum coverage that each package should have
17+
package: 0
18+
19+
# (optional; default 0)
20+
# The minimum total coverage project should have
21+
total: 0
22+
23+
# Holds regexp rules which will override thresholds for matched files or packages
24+
# override:
25+
# # Increase coverage threshold to 100% for `foo` package (default is 80, as configured above)
26+
# - threshold: 100
27+
# path: ^pkg/lib/foo$
28+
29+
# Holds regexp rules which will exclude matched files or packages from coverage statistics
30+
# exclude:
31+
# # Exclude files or packages matching their paths
32+
# paths:
33+
# - \.pb\.go$ # excludes all protobuf generated files
34+
# - ^pkg/bar # exclude package `pkg/bar`
35+
36+
# NOTES:
37+
# - symbol `/` in all path regexps will be replaced by
38+
# current OS file path separator to properly work on Windows

‎Dockerfile

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
FROM alpine:3.12
1+
FROM golang:1.20-alpine as builder
2+
3+
RUN apk --no-cache add make
4+
5+
COPY . /app/
6+
WORKDIR /app/
7+
8+
RUN make build
9+
10+
11+
FROM alpine:3.18.2
212
LABEL description="Kubernetes utility for exposing used image versions compared to the latest version, as metrics."
313

414
RUN apk --no-cache add ca-certificates
515

6-
COPY ./bin/version-checker-linux /usr/bin/version-checker
16+
COPY --from=builder /app/bin/version-checker /usr/bin/version-checker
717

818
ENTRYPOINT ["/usr/bin/version-checker"]

‎Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ help: ## display this help
66

77
.PHONY: help build image all clean
88

9-
test: ## test version-checker
10-
go test ./...
9+
deps: ## Download all Dependencies
10+
go mod download
1111

12-
build: ## build version-checker
12+
test: deps ## test version-checker
13+
go test ./... -coverprofile=coverage.out
14+
15+
$(BINDIR):
1316
mkdir -p $(BINDIR)
17+
18+
build: deps $(BINDIR) ## build version-checker
1419
CGO_ENABLED=0 go build -o ./bin/version-checker ./cmd/.
1520

1621
verify: test build ## tests and builds version-checker
1722

1823
image: ## build docker image
19-
GOARCH=$(ARCH) GOOS=linux CGO_ENABLED=0 go build -o ./bin/version-checker-linux ./cmd/.
2024
docker build -t quay.io/jetstack/version-checker:v0.2.2 .
2125

2226
clean: ## clean up created files

‎OWNERS

-6
This file was deleted.

‎README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ alert cluster operators.
77

88
> This tool is currently experimental.
99
10-
If you're interested in this tool, version checking is a built-in feature
11-
in our [Preflight](https://preflight.jetstack.io/) product. You may want to
12-
check it out if you would like multi-cluster component version checking.
13-
1410
## Registries
1511

1612
version-checker supports the following registries:
@@ -40,8 +36,15 @@ $ kubectl apply -k ./deploy/yaml
4036
Or through helm;
4137

4238
```sh
43-
$ cd ./deploy/charts/version-checker && kubectl create namespace version-checker
44-
$ helm install version-checker . -n version-checker
39+
$ helm repo add jetstack https://charts.jetstack.io
40+
"jetstack" has been added to your repositories
41+
$ helm install version-checker jetstack/version-checker
42+
NAME: version-checker
43+
LAST DEPLOYED: Wed Jul 12 17:47:41 2023
44+
NAMESPACE: default
45+
STATUS: deployed
46+
REVISION: 1
47+
TEST SUITE: None
4548
```
4649

4750
The helm chart supports creating a Prometheus/ServiceMonitor to expose the

‎deploy/charts/version-checker/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
appVersion: "v0.2.2"
3-
version: 0.2.3
3+
version: v0.2.3
44
description: A Helm chart for version-checker
55
home: https://github.com/jetstack/verison-checker
66
name: version-checker

‎go.mod

+90-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,96 @@
11
module github.com/jetstack/version-checker
22

3-
go 1.15
3+
go 1.20
4+
5+
// Do not remove this comment:
6+
// please place any replace statements here at the top for visibility and add a
7+
// comment to it as to when it can be removed
48

59
require (
6-
cloud.google.com/go v0.57.0 // indirect
7-
github.com/Azure/go-autorest/autorest v0.10.2
8-
github.com/Azure/go-autorest/autorest/adal v0.8.3
9-
github.com/aws/aws-sdk-go v1.34.10
10-
github.com/dgrijalva/jwt-go v3.2.0+incompatible
11-
github.com/google/go-github/v44 v44.0.0
12-
github.com/hashicorp/go-retryablehttp v0.6.8
13-
github.com/hashicorp/golang-lru v0.5.3 // indirect
14-
github.com/imdario/mergo v0.3.9 // indirect
15-
github.com/kr/text v0.2.0 // indirect
16-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
17-
github.com/prometheus/client_golang v1.7.1
18-
github.com/sirupsen/logrus v1.6.0
19-
github.com/spf13/cobra v1.0.0
10+
github.com/Azure/go-autorest/autorest v0.11.29
11+
github.com/Azure/go-autorest/autorest/adal v0.9.23
12+
github.com/aws/aws-sdk-go v1.44.298
13+
github.com/golang-jwt/jwt/v5 v5.0.0
14+
github.com/google/gnostic v0.6.9 // indirect
15+
github.com/google/go-github/v53 v53.2.0
16+
github.com/hashicorp/go-retryablehttp v0.7.4
17+
github.com/prometheus/client_golang v1.16.0
18+
github.com/sirupsen/logrus v1.9.3
19+
github.com/spf13/cobra v1.6.0
2020
github.com/spf13/pflag v1.0.5
21-
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
22-
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
23-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
24-
gopkg.in/yaml.v2 v2.3.0 // indirect
25-
k8s.io/api v0.19.0
26-
k8s.io/apimachinery v0.19.0
27-
k8s.io/cli-runtime v0.19.0
28-
k8s.io/client-go v0.19.0
29-
k8s.io/component-base v0.19.0
30-
k8s.io/utils v0.0.0-20200729134348-d5654de09c73
21+
golang.org/x/oauth2 v0.10.0
22+
k8s.io/api v0.27.3
23+
k8s.io/apimachinery v0.27.3
24+
k8s.io/cli-runtime v0.27.3
25+
k8s.io/client-go v0.27.3
26+
k8s.io/component-base v0.27.3
27+
k8s.io/utils v0.0.0-20230505201702-9f6742963106
28+
)
29+
30+
require (
31+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
32+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
33+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
34+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
35+
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
36+
github.com/beorn7/perks v1.0.1 // indirect
37+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
38+
github.com/cloudflare/circl v1.3.3 // indirect
39+
github.com/davecgh/go-spew v1.1.1 // indirect
40+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
41+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
42+
github.com/go-errors/errors v1.4.2 // indirect
43+
github.com/go-logr/logr v1.2.3 // indirect
44+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
45+
github.com/go-openapi/jsonreference v0.20.1 // indirect
46+
github.com/go-openapi/swag v0.22.3 // indirect
47+
github.com/gogo/protobuf v1.3.2 // indirect
48+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
49+
github.com/golang/protobuf v1.5.3 // indirect
50+
github.com/google/btree v1.0.1 // indirect
51+
github.com/google/go-cmp v0.5.9 // indirect
52+
github.com/google/go-querystring v1.1.0 // indirect
53+
github.com/google/gofuzz v1.1.0 // indirect
54+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
55+
github.com/google/uuid v1.3.0 // indirect
56+
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
57+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
58+
github.com/imdario/mergo v0.3.9 // indirect
59+
github.com/inconshreveable/mousetrap v1.0.1 // indirect
60+
github.com/jmespath/go-jmespath v0.4.0 // indirect
61+
github.com/josharian/intern v1.0.0 // indirect
62+
github.com/json-iterator/go v1.1.12 // indirect
63+
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
64+
github.com/mailru/easyjson v0.7.7 // indirect
65+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
66+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
67+
github.com/modern-go/reflect2 v1.0.2 // indirect
68+
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
69+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
70+
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
71+
github.com/pkg/errors v0.9.1 // indirect
72+
github.com/prometheus/client_model v0.3.0 // indirect
73+
github.com/prometheus/common v0.42.0 // indirect
74+
github.com/prometheus/procfs v0.10.1 // indirect
75+
github.com/rogpeppe/go-internal v1.11.0 // indirect
76+
github.com/xlab/treeprint v1.1.0 // indirect
77+
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
78+
golang.org/x/crypto v0.11.0 // indirect
79+
golang.org/x/net v0.12.0 // indirect
80+
golang.org/x/sys v0.10.0 // indirect
81+
golang.org/x/term v0.10.0 // indirect
82+
golang.org/x/text v0.11.0 // indirect
83+
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
84+
google.golang.org/appengine v1.6.7 // indirect
85+
google.golang.org/protobuf v1.31.0 // indirect
86+
gopkg.in/inf.v0 v0.9.1 // indirect
87+
gopkg.in/yaml.v2 v2.4.0 // indirect
88+
gopkg.in/yaml.v3 v3.0.1 // indirect
89+
k8s.io/klog/v2 v2.90.1 // indirect
90+
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
91+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
92+
sigs.k8s.io/kustomize/api v0.13.2 // indirect
93+
sigs.k8s.io/kustomize/kyaml v0.14.1 // indirect
94+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
95+
sigs.k8s.io/yaml v1.3.0 // indirect
3196
)

‎go.sum

+245-475
Large diffs are not rendered by default.

‎pkg/client/acr/acr.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"github.com/Azure/go-autorest/autorest"
1414
"github.com/Azure/go-autorest/autorest/adal"
15-
"github.com/dgrijalva/jwt-go"
15+
jwt "github.com/golang-jwt/jwt/v5"
1616

1717
"github.com/jetstack/version-checker/pkg/api"
1818
"github.com/jetstack/version-checker/pkg/client/util"
@@ -241,15 +241,18 @@ func (c *Client) getAccessTokenClient(ctx context.Context, host string) (*acrCli
241241
}, nil
242242
}
243243

244-
func getTokenExpiration(token string) (time.Time, error) {
245-
parser := jwt.Parser{SkipClaimsValidation: true}
244+
func getTokenExpiration(tokenString string) (time.Time, error) {
246245

247-
claims := make(jwt.MapClaims)
248-
_, _, err := parser.ParseUnverified(token, claims)
246+
token, err := jwt.Parse(tokenString, nil, jwt.WithoutClaimsValidation())
249247
if err != nil {
250248
return time.Time{}, err
251249
}
252250

251+
claims, ok := token.Claims.(jwt.MapClaims)
252+
if !ok {
253+
return time.Time{}, fmt.Errorf("failed to process claims in access token")
254+
}
255+
253256
if exp, ok := claims["exp"].(float64); ok {
254257
timestamp := time.Unix(int64(exp), 0)
255258
return timestamp, nil

‎pkg/client/ghcr/ghcr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http"
77
"time"
88

9-
"github.com/google/go-github/v44/github"
9+
"github.com/google/go-github/v53/github"
1010
"github.com/jetstack/version-checker/pkg/api"
1111
"golang.org/x/oauth2"
1212
)

0 commit comments

Comments
 (0)
Please sign in to comment.