Skip to content

Commit

Permalink
Moved the init of scheme to main,
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 66917f2 commit aa77ea0
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 6 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
21 changes: 21 additions & 0 deletions cmd/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 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 cmd

import (
_ "github.com/etcd-io/auger/pkg/scheme"
)
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
21 changes: 21 additions & 0 deletions pkg/data/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 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 data

import (
_ "github.com/etcd-io/auger/pkg/scheme"
)
3 changes: 1 addition & 2 deletions pkg/encoding/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package encoding
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
)

Expand All @@ -28,5 +28,4 @@ var Codecs = serializer.NewCodecFactory(Scheme)

func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(Scheme)
}
25 changes: 25 additions & 0 deletions pkg/scheme/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
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"
)

func init() {
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 aa77ea0

Please sign in to comment.