Skip to content

Commit

Permalink
Add existing k8s types to new scheme
Browse files Browse the repository at this point in the history
It's generally not good practice to modify someone else's scheme, so we
add k8s types to our new scheme instead.
  • Loading branch information
DirectXMan12 committed Jun 20, 2019
1 parent 11e1b13 commit 148510f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pkg/scaffold/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ import (
)
var (
scheme = clientgoscheme.Scheme
setupLog = ctrl.Log.WithName("setup")
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
)
func init() {
_ = clientgoscheme.AddToScheme(scheme)
%s
}
Expand All @@ -160,7 +161,7 @@ func main() {
}
%s
%s
setupLog.Info("starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion testdata/project-v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -31,11 +32,12 @@ import (
)

var (
scheme = clientgoscheme.Scheme
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
)

func init() {
_ = clientgoscheme.AddToScheme(scheme)

_ = crewv1.AddToScheme(scheme)
_ = corev1.AddToScheme(scheme)
Expand Down

0 comments on commit 148510f

Please sign in to comment.