Skip to content

Commit 74bc7c4

Browse files
committed
Move scheme to init
Signed-off-by: Shiming Zhang <[email protected]>
1 parent fb03bb4 commit 74bc7c4

File tree

6 files changed

+34
-11
lines changed

6 files changed

+34
-11
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ clean:
5757

5858
generate:
5959
go mod vendor
60-
rm ./pkg/encoding/scheme.go
61-
./hack/gen_scheme.sh > pkg/encoding/scheme.go
60+
rm ./pkg/scheme/scheme.go
61+
./hack/gen_scheme.sh > pkg/scheme/scheme.go
6262

6363
.PHONY: build test release release-docker-build clean generate

hack/gen_scheme.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ See the License for the specific language governing permissions and
3838
limitations under the License.
3939
*/
4040
41-
package encoding
41+
package scheme
4242
4343
// Don't edit this file directly. It is generated by scheme.sh.
4444
import (

main.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"fmt"
2020
"os"
2121

22+
_ "github.com/etcd-io/auger/pkg/scheme"
23+
2224
"github.com/etcd-io/auger/cmd"
2325
)
2426

pkg/encoding/init.go

-7
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,9 @@ limitations under the License.
1717
package encoding
1818

1919
import (
20-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2120
runtime "k8s.io/apimachinery/pkg/runtime"
22-
schema "k8s.io/apimachinery/pkg/runtime/schema"
2321
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
2422
)
2523

2624
var Scheme = runtime.NewScheme()
2725
var Codecs = serializer.NewCodecFactory(Scheme)
28-
29-
func init() {
30-
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
31-
AddToScheme(Scheme)
32-
}

pkg/scheme/init.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 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 scheme
18+
19+
import (
20+
"github.com/etcd-io/auger/pkg/encoding"
21+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
)
24+
25+
func init() {
26+
v1.AddToGroupVersion(encoding.Scheme, schema.GroupVersion{Version: "v1"})
27+
AddToScheme(encoding.Scheme)
28+
}

pkg/encoding/scheme.go pkg/scheme/scheme.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package encoding
17+
package scheme
1818

1919
// Don't edit this file directly. It is generated by scheme.sh.
2020
import (

0 commit comments

Comments
 (0)