Skip to content

Commit

Permalink
Move scheme to init
Browse files Browse the repository at this point in the history
Signed-off-by: Shiming Zhang <[email protected]>
  • Loading branch information
wzshiming committed Feb 29, 2024
1 parent fb03bb4 commit 74bc7c4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ clean:

generate:
go mod vendor
rm ./pkg/encoding/scheme.go
./hack/gen_scheme.sh > pkg/encoding/scheme.go
rm ./pkg/scheme/scheme.go
./hack/gen_scheme.sh > pkg/scheme/scheme.go

.PHONY: build test release release-docker-build clean generate
2 changes: 1 addition & 1 deletion hack/gen_scheme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package encoding
package scheme
// Don't edit this file directly. It is generated by scheme.sh.
import (
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"fmt"
"os"

_ "github.com/etcd-io/auger/pkg/scheme"

"github.com/etcd-io/auger/cmd"
)

Expand Down
7 changes: 0 additions & 7 deletions pkg/encoding/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@ limitations under the License.
package encoding

import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
)

var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)

func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(Scheme)
}
28 changes: 28 additions & 0 deletions pkg/scheme/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheme

import (
"github.com/etcd-io/auger/pkg/encoding"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

func init() {
v1.AddToGroupVersion(encoding.Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(encoding.Scheme)
}
2 changes: 1 addition & 1 deletion pkg/encoding/scheme.go → pkg/scheme/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package encoding
package scheme

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

0 comments on commit 74bc7c4

Please sign in to comment.