Skip to content

Commit 27c3bfc

Browse files
committed
Improve scheme registration for clusters-service.
Use the runtime builder to add them all in one, and return an error if any fail.
1 parent 8be3952 commit 27c3bfc

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

cmd/clusters-service/app/server.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,21 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)
401401
return fmt.Errorf("could not parse auth methods: %w", err)
402402
}
403403

404-
cobra.CheckErr(capiv1.AddToScheme(clustersManagerScheme))
405-
cobra.CheckErr(pacv2beta1.AddToScheme(clustersManagerScheme))
406-
cobra.CheckErr(pacv2beta2.AddToScheme(clustersManagerScheme))
407-
cobra.CheckErr(esv1beta1.AddToScheme(clustersManagerScheme))
408-
cobra.CheckErr(flaggerv1beta1.AddToScheme(clustersManagerScheme))
409-
cobra.CheckErr(pipelinev1alpha1.AddToScheme(clustersManagerScheme))
410-
cobra.CheckErr(tfctrl.AddToScheme(clustersManagerScheme))
411-
cobra.CheckErr(gitopsv1alpha1.AddToScheme(clustersManagerScheme))
412-
cobra.CheckErr(clusterv1.AddToScheme(clustersManagerScheme))
413-
cobra.CheckErr(gapiv1.AddToScheme(clustersManagerScheme))
404+
builder := runtime.NewSchemeBuilder(
405+
capiv1.AddToScheme,
406+
pacv2beta1.AddToScheme,
407+
pacv2beta2.AddToScheme,
408+
esv1beta1.AddToScheme,
409+
flaggerv1beta1.AddToScheme,
410+
pipelinev1alpha1.AddToScheme,
411+
tfctrl.AddToScheme,
412+
gitopsv1alpha1.AddToScheme,
413+
clusterv1.AddToScheme,
414+
gapiv1.AddToScheme,
415+
)
416+
if err := builder.AddToScheme(clustersManagerScheme); err != nil {
417+
return err
418+
}
414419

415420
mgmtCluster, err := cluster.NewSingleCluster(p.Cluster, rest, clustersManagerScheme, cluster.DefaultKubeConfigOptions...)
416421
if err != nil {

0 commit comments

Comments
 (0)