Skip to content

Commit 3c6374b

Browse files
committed
chore: update static scheme (argoproj#588)
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> fix cherry-pick and test Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
1 parent 5e154bb commit 3c6374b

File tree

4 files changed

+1147
-133
lines changed

4 files changed

+1147
-133
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ require (
9898
)
9999

100100
replace (
101+
// After bumping these versions, run hack/update_static_schema.sh in case the schema has changed.
101102
k8s.io/api => k8s.io/api v0.26.4
102103
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.4
103104
k8s.io/apimachinery => k8s.io/apimachinery v0.26.4

hack/update_static_schema.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
# Get the k8s library version from go.mod, stripping the trailing newline
6+
k8s_lib_version=$(grep "k8s.io/client-go" go.mod | awk '{print $2}' | head -n 1 | tr -d '\n')
7+
8+
# Download the parser file from the k8s library
9+
curl -sL "https://raw.githubusercontent.com/kubernetes/client-go/$k8s_lib_version/applyconfigurations/internal/internal.go" -o pkg/utils/kube/scheme/parser.go
10+
11+
# Add a line to the beginning of the file saying that this is the script that generated it.
12+
sed -i '' '1s/^/\/\/ Code generated by hack\/update_static_schema.sh; DO NOT EDIT.\n\/\/ Everything below is downloaded from applyconfigurations\/internal\/internal.go in kubernetes\/client-go.\n\n/' pkg/utils/kube/scheme/parser.go
13+
14+
# Replace "package internal" with "package scheme" in the parser file
15+
sed -i '' 's/package internal/package scheme/' pkg/utils/kube/scheme/parser.go
16+
17+
# Replace "func Parser" with "func StaticParser"
18+
sed -i '' 's/func Parser/func StaticParser/' pkg/utils/kube/scheme/parser.go

pkg/utils/kube/ctl_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package kube
33
import (
44
_ "embed"
55
"encoding/json"
6-
openapi_v2 "github.com/google/gnostic-models/openapiv2"
6+
openapi_v2 "github.com/google/gnostic/openapiv2"
77
"github.com/stretchr/testify/require"
88
"testing"
99

0 commit comments

Comments
 (0)