From 572e3b1cf93d2bd3147e7f95b3678ad032332b79 Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Wed, 12 Jun 2019 15:12:18 -0400 Subject: [PATCH] Import all checks from one package Introduce a "meta" check package, `checks/all`, that will import all the other packages that contain checks. Then main or other packages that want to use checks need only import `checks/all` and will get all the checks registered. This doesn't feel like a perfect solution, but I think it's tidy enough to go with for the moment at least. --- checks/all/all.go | 7 +++++++ cmd/clusterlint/main.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 checks/all/all.go diff --git a/checks/all/all.go b/checks/all/all.go new file mode 100644 index 0000000..9888908 --- /dev/null +++ b/checks/all/all.go @@ -0,0 +1,7 @@ +// Package all imports all other check-containing packages, for the side-effect +// of having them registered in the check registry. +package all + +import ( + _ "github.com/digitalocean/clusterlint/checks/noop" +) diff --git a/cmd/clusterlint/main.go b/cmd/clusterlint/main.go index c38a069..b476378 100644 --- a/cmd/clusterlint/main.go +++ b/cmd/clusterlint/main.go @@ -8,10 +8,12 @@ import ( "sync" "github.com/digitalocean/clusterlint/checks" - _ "github.com/digitalocean/clusterlint/checks/noop" "github.com/digitalocean/clusterlint/kube" "github.com/urfave/cli" "golang.org/x/sync/errgroup" + + // Side-effect import to get all the checks registered. + _ "github.com/digitalocean/clusterlint/checks/all" ) const all string = ""