-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from shomron/namespaced-cache
Scope secrets cache to single namespace
- Loading branch information
Showing
4 changed files
with
343 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package rotator | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/envtest" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
) | ||
|
||
var cfg *rest.Config | ||
|
||
// TestMain runs before package tests and starts a local apiserver instance. | ||
func TestMain(m *testing.M) { | ||
t := &envtest.Environment{} | ||
|
||
var err error | ||
if cfg, err = t.Start(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
code := m.Run() | ||
if err := t.Stop(); err != nil { | ||
log.Fatal(fmt.Errorf("shutting down: %w", err)) | ||
} | ||
os.Exit(code) | ||
} | ||
|
||
// StartTestManager adds recFn | ||
func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) (chan struct{}, *sync.WaitGroup) { | ||
stop := make(chan struct{}) | ||
wg := &sync.WaitGroup{} | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
g.Expect(mgr.Start(stop)).NotTo(gomega.HaveOccurred()) | ||
}() | ||
return stop, wg | ||
} |
Oops, something went wrong.