Skip to content

Commit 68ca465

Browse files
authored
Merge pull request #2 from wzshiming/ci/scheme
Add a script for automatically updating scheme
2 parents 29f8611 + 03134f9 commit 68ca465

15 files changed

+321
-193
lines changed

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,12 @@ release-docker-build:
6868
clean:
6969
rm -rf build
7070

71+
pkg/scheme/scheme.go: ./hack/gen_scheme.sh go.mod
72+
go mod vendor
73+
-rm ./pkg/scheme/scheme.go
74+
./hack/gen_scheme.sh > ./pkg/scheme/scheme.go
75+
76+
.PHONY: generate
77+
generate: pkg/scheme/scheme.go
78+
7179
.PHONY: build test release release-docker-build clean

cmd/analyze.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"sort"
2222

2323
"github.com/etcd-io/auger/pkg/data"
24+
"github.com/etcd-io/auger/pkg/scheme"
2425
"github.com/spf13/cobra"
2526
)
2627

@@ -44,7 +45,7 @@ func init() {
4445
}
4546

4647
func analyzeValidateAndRun() error {
47-
summaries, err := data.ListKeySummaries(analyzeOpts.filename, []data.Filter{}, &data.KeySummaryProjection{HasKey: true, HasValue: false}, 0)
48+
summaries, err := data.ListKeySummaries(scheme.Codecs, analyzeOpts.filename, []data.Filter{}, &data.KeySummaryProjection{HasKey: true, HasValue: false}, 0)
4849
if err != nil {
4950
return err
5051
}

cmd/decode.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"encoding/hex"
2727

2828
"github.com/etcd-io/auger/pkg/encoding"
29+
"github.com/etcd-io/auger/pkg/scheme"
2930
"github.com/spf13/cobra"
3031
)
3132

@@ -151,7 +152,7 @@ func runInBatchMode(metaOnly bool, outMediaType string, out io.Writer) (err erro
151152
}
152153

153154
buf := bytes.NewBufferString("")
154-
_, err = encoding.Convert(inMediaType, outMediaType, decodedinput, buf)
155+
_, err = encoding.Convert(scheme.Codecs, inMediaType, outMediaType, decodedinput, buf)
155156
if err != nil {
156157
fmt.Fprintf(out, "ERROR:%v|\n", err)
157158
} else {
@@ -173,7 +174,7 @@ func run(metaOnly bool, outMediaType string, in []byte, out io.Writer) error {
173174
return encoding.DecodeSummary(inMediaType, in, out)
174175
}
175176

176-
_, err = encoding.Convert(inMediaType, outMediaType, in, out)
177+
_, err = encoding.Convert(scheme.Codecs, inMediaType, outMediaType, in, out)
177178
return err
178179
}
179180

cmd/encode.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323

2424
"github.com/etcd-io/auger/pkg/encoding"
25+
"github.com/etcd-io/auger/pkg/scheme"
2526
"github.com/spf13/cobra"
2627
)
2728

@@ -80,6 +81,6 @@ func encodeValidateAndRun() error {
8081

8182
// encodeRun runs the encode command.
8283
func encodeRun(inMediaType string, in []byte, out io.Writer) error {
83-
_, err := encoding.Convert(inMediaType, encoding.StorageBinaryMediaType, in, out)
84+
_, err := encoding.Convert(scheme.Codecs, inMediaType, encoding.StorageBinaryMediaType, in, out)
8485
return err
8586
}

cmd/extract.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/coreos/etcd/mvcc/mvccpb"
2828
"github.com/etcd-io/auger/pkg/data"
2929
"github.com/etcd-io/auger/pkg/encoding"
30+
"github.com/etcd-io/auger/pkg/scheme"
3031
"github.com/google/safetext/yamltemplate"
3132
"github.com/spf13/cobra"
3233
)
@@ -221,7 +222,7 @@ func printValue(filename string, key string, version string, raw bool, outMediaT
221222
fmt.Fprintf(out, "%s\n", string(in))
222223
return nil
223224
}
224-
_, err = encoding.DetectAndConvert(outMediaType, in, out)
225+
_, err = encoding.DetectAndConvert(scheme.Codecs, outMediaType, in, out)
225226
return err
226227
}
227228

@@ -243,7 +244,7 @@ func printLeafItemSummary(kv *mvccpb.KeyValue, out io.Writer) error {
243244

244245
// printLeafItemValue prints an etcd value for a given boltdb leaf item.
245246
func printLeafItemValue(kv *mvccpb.KeyValue, outMediaType string, out io.Writer) error {
246-
_, err := encoding.DetectAndConvert(outMediaType, kv.Value, out)
247+
_, err := encoding.DetectAndConvert(scheme.Codecs, outMediaType, kv.Value, out)
247248
return err
248249
}
249250

@@ -264,7 +265,7 @@ func printKeySummaries(filename string, keyPrefix string, revision int64, fields
264265
}
265266
}
266267
proj := &data.KeySummaryProjection{HasKey: hasKey, HasValue: hasValue}
267-
summaries, err := data.ListKeySummaries(filename, []data.Filter{data.NewPrefixFilter(keyPrefix)}, proj, revision)
268+
summaries, err := data.ListKeySummaries(scheme.Codecs, filename, []data.Filter{data.NewPrefixFilter(keyPrefix)}, proj, revision)
268269
if err != nil {
269270
return err
270271
}
@@ -300,7 +301,7 @@ func printTemplateSummaries(filename string, keyPrefix string, revision int64, t
300301
}
301302

302303
// We don't have a simple way to determine if the template uses the key or value or not
303-
summaries, err := data.ListKeySummaries(filename, append(filters, data.NewPrefixFilter(keyPrefix)), &data.KeySummaryProjection{HasKey: true, HasValue: true}, revision)
304+
summaries, err := data.ListKeySummaries(scheme.Codecs, filename, append(filters, data.NewPrefixFilter(keyPrefix)), &data.KeySummaryProjection{HasKey: true, HasValue: true}, revision)
304305
if err != nil {
305306
return err
306307
}

go.mod

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@ require (
88
github.com/google/safetext v0.0.0-20220914124124-e18e3fe012bf
99
github.com/spf13/cobra v1.8.0
1010
gopkg.in/yaml.v2 v2.4.0
11-
k8s.io/api v0.0.0-20180521142803-feb48db456a5
12-
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05
11+
k8s.io/api v0.29.3
12+
k8s.io/apimachinery v0.29.3
13+
k8s.io/client-go v0.29.3
1314
)
1415

1516
require (
16-
github.com/ghodss/yaml v1.0.0 // indirect
17+
github.com/go-logr/logr v1.3.0 // indirect
1718
github.com/gogo/protobuf v1.3.2 // indirect
18-
github.com/golang/glog v1.2.0 // indirect
1919
github.com/golang/protobuf v1.5.4 // indirect
2020
github.com/google/gofuzz v1.2.0 // indirect
2121
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2222
github.com/json-iterator/go v1.1.12 // indirect
23-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
23+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2424
github.com/modern-go/reflect2 v1.0.2 // indirect
2525
github.com/spf13/pflag v1.0.5 // indirect
2626
github.com/stretchr/testify v1.9.0 // indirect
2727
golang.org/x/net v0.22.0 // indirect
2828
golang.org/x/sys v0.18.0 // indirect
2929
golang.org/x/text v0.14.0 // indirect
3030
google.golang.org/protobuf v1.33.0 // indirect
31-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3231
gopkg.in/inf.v0 v0.9.1 // indirect
3332
gopkg.in/yaml.v3 v3.0.1 // indirect
33+
k8s.io/klog/v2 v2.110.1 // indirect
34+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
35+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
36+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
37+
sigs.k8s.io/yaml v1.3.0 // indirect
3438
)

go.sum

+28-14
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
66
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9-
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
10-
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
9+
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
10+
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
1111
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
1212
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
13-
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
14-
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
1513
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
1614
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
15+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1716
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1817
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1918
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -27,17 +26,19 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
2726
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
2827
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
2928
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
30-
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
31-
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
32-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
33-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
34-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
35-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
29+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
30+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
31+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
32+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3633
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
34+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
35+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
3736
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
3837
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
3938
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4039
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
40+
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
41+
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
4142
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
4243
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
4344
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
@@ -87,11 +88,24 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
8788
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
8889
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
8990
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
91+
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
9092
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
9193
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
9294
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
9395
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
94-
k8s.io/api v0.0.0-20180521142803-feb48db456a5 h1:ZkJvJIvl22AqkIYbow7+ZkJCZ/Vf5TnLyJ1Q5UpFXEI=
95-
k8s.io/api v0.0.0-20180521142803-feb48db456a5/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
96-
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05 h1:IxbzCht0hGNBVprna3ou1lB+jvFGT2Sh83htT2jL4sk=
97-
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
96+
k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw=
97+
k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80=
98+
k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU=
99+
k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU=
100+
k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg=
101+
k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0=
102+
k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
103+
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
104+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
105+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
106+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
107+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
108+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
109+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
110+
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
111+
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

hack/gen_scheme.sh

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
DIR="$(dirname "${BASH_SOURCE[0]}")"
21+
ROOT_DIR="$(realpath "${DIR}/..")"
22+
23+
function gen() {
24+
cat <<EOF
25+
/*
26+
Copyright The Kubernetes Authors.
27+
28+
Licensed under the Apache License, Version 2.0 (the "License");
29+
you may not use this file except in compliance with the License.
30+
You may obtain a copy of the License at
31+
32+
http://www.apache.org/licenses/LICENSE-2.0
33+
34+
Unless required by applicable law or agreed to in writing, software
35+
distributed under the License is distributed on an "AS IS" BASIS,
36+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37+
See the License for the specific language governing permissions and
38+
limitations under the License.
39+
*/
40+
41+
package scheme
42+
43+
// Don't edit this file directly. It is generated by gen_scheme.sh.
44+
import (
45+
EOF
46+
47+
find "${ROOT_DIR}/vendor/k8s.io/api" | grep register.go | sed "s#${ROOT_DIR}/vendor/##g" | sed "s#/register.go##g" | awk -F '/' '{print " "$3$4, "\""$1"\/"$2"\/"$3"\/"$4"\""}' | sort
48+
49+
cat <<EOF
50+
"k8s.io/apimachinery/pkg/runtime"
51+
)
52+
53+
// AddToScheme adds all types of this clientset into the given scheme.
54+
func AddToScheme(scheme *runtime.Scheme) {
55+
EOF
56+
57+
find "${ROOT_DIR}/vendor/k8s.io/api" | grep register.go | sed "s#${ROOT_DIR}/vendor/##g" | sed "s#/register.go##g" | awk -F '/' '{print " _ = " $3$4"\.AddToScheme(scheme)"}' | sort
58+
59+
cat <<EOF
60+
}
61+
EOF
62+
}
63+
64+
gen

hack/tools/tools.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package tools
18+
19+
import (
20+
// For gen_scheme.sh to work, the following import must be present, vending all api types.
21+
_ "k8s.io/client-go/kubernetes/scheme"
22+
)

pkg/data/data.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/coreos/etcd/mvcc/mvccpb"
3131
"github.com/etcd-io/auger/pkg/encoding"
3232
"k8s.io/apimachinery/pkg/runtime"
33+
"k8s.io/apimachinery/pkg/runtime/serializer"
3334
)
3435

3536
// See etcd/mvcc/kvstore.go:keyBucketName
@@ -200,7 +201,7 @@ func getCompactRevision(db *bolt.DB) (int64, error) {
200201
}
201202

202203
// ListKeySummaries returns a result set with all the provided filters and projections applied.
203-
func ListKeySummaries(filename string, filters []Filter, proj *KeySummaryProjection, revision int64) ([]*KeySummary, error) {
204+
func ListKeySummaries(codecs serializer.CodecFactory, filename string, filters []Filter, proj *KeySummaryProjection, revision int64) ([]*KeySummary, error) {
204205
var err error
205206
db, err := bolt.Open(filename, 0400, &bolt.Options{})
206207
if err != nil {
@@ -231,7 +232,7 @@ func ListKeySummaries(filename string, filters []Filter, proj *KeySummaryProject
231232
var valJson string
232233
var typeMeta *runtime.TypeMeta
233234
var err error
234-
if typeMeta, err = encoding.DetectAndConvert(encoding.JsonMediaType, kv.Value, buf); err == nil {
235+
if typeMeta, err = encoding.DetectAndConvert(codecs, encoding.JsonMediaType, kv.Value, buf); err == nil {
235236
valJson = strings.TrimSpace(buf.String())
236237
}
237238
var key string

pkg/data/data_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package data
1818

1919
import (
2020
"testing"
21+
22+
"github.com/etcd-io/auger/pkg/scheme"
2123
)
2224

2325
const (
@@ -84,7 +86,7 @@ func TestListKeySummariesFilters(t *testing.T) {
8486
missingKeys[key] = struct{}{}
8587
}
8688
unexpectedKeys := map[string]struct{}{}
87-
results, err := ListKeySummaries(tt.file, tt.filters, ProjectEverything, 0)
89+
results, err := ListKeySummaries(scheme.Codecs, tt.file, tt.filters, ProjectEverything, 0)
8890
if err != nil {
8991
t.Fatal(err)
9092
}

0 commit comments

Comments
 (0)