Skip to content

Commit

Permalink
Merge pull request #1462 from christopherhein/chore/utilruntime-schemes
Browse files Browse the repository at this point in the history
Using utilruntime.Must() for adding schemes
  • Loading branch information
k8s-ci-robot authored Apr 10, 2020
2 parents f722914 + 1f9742a commit b2ce2e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pkg/scaffold/internal/templates/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const (
// change, and thus should be done for next project version.
multiGroupControllerImportCodeFragment = `%scontroller "%s/controllers/%s"
`
addschemeCodeFragment = `_ = %s.AddToScheme(scheme)
addschemeCodeFragment = `utilruntime.Must(%s.AddToScheme(scheme))
`
reconcilerSetupCodeFragment = `if err = (&controllers.%sReconciler{
Client: mgr.GetClient(),
Expand Down Expand Up @@ -206,6 +206,7 @@ import (
"flag"
"os"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/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 @@ -219,7 +220,7 @@ var (
)
func init() {
_ = clientgoscheme.AddToScheme(scheme)
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
%s
}
Expand Down
5 changes: 3 additions & 2 deletions testdata/project-v2-addon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/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 @@ -37,9 +38,9 @@ var (
)

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

_ = crewv1.AddToScheme(scheme)
utilruntime.Must(crewv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
17 changes: 9 additions & 8 deletions testdata/project-v2-multigroup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/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 @@ -46,15 +47,15 @@ var (
)

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

_ = crewv1.AddToScheme(scheme)
_ = shipv1beta1.AddToScheme(scheme)
_ = shipv1.AddToScheme(scheme)
_ = shipv2alpha1.AddToScheme(scheme)
_ = seacreaturesv1beta1.AddToScheme(scheme)
_ = seacreaturesv1beta2.AddToScheme(scheme)
_ = foopolicyv1.AddToScheme(scheme)
utilruntime.Must(crewv1.AddToScheme(scheme))
utilruntime.Must(shipv1beta1.AddToScheme(scheme))
utilruntime.Must(shipv1.AddToScheme(scheme))
utilruntime.Must(shipv2alpha1.AddToScheme(scheme))
utilruntime.Must(seacreaturesv1beta1.AddToScheme(scheme))
utilruntime.Must(seacreaturesv1beta2.AddToScheme(scheme))
utilruntime.Must(foopolicyv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
5 changes: 3 additions & 2 deletions testdata/project-v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/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 @@ -37,9 +38,9 @@ var (
)

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

_ = crewv1.AddToScheme(scheme)
utilruntime.Must(crewv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down

0 comments on commit b2ce2e0

Please sign in to comment.