Add controller API client interface (#1467)

This PR adds an interface for controller API client, it allows us to
implement mock API client for unit testing with ease and we are
able to generate spec file without accessing the real Fission server.
This commit is contained in:
Ta-Ching Chen
2019-12-16 23:14:14 +08:00
committed by GitHub
parent 01bdc5bf89
commit bfbb80efcf
71 changed files with 1021 additions and 1025 deletions
+3 -3
View File
@@ -34,7 +34,7 @@ type (
// packageBuildWatcher is used to watch a set of in-progress builds.
packageBuildWatcher struct {
// fission client
fclient *client.Client
fclient client.Interface
// set of packages already printed, ensures we don't duplicate the notifications
finished map[string]bool
@@ -44,7 +44,7 @@ type (
}
)
func makePackageBuildWatcher(fclient *client.Client) *packageBuildWatcher {
func makePackageBuildWatcher(fclient client.Interface) *packageBuildWatcher {
return &packageBuildWatcher{
fclient: fclient,
finished: make(map[string]bool),
@@ -68,7 +68,7 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
}
// pull list of packages (TODO: convert to watch)
pkgs, err := w.fclient.PackageList(metav1.NamespaceAll)
pkgs, err := w.fclient.V1().Package().List(metav1.NamespaceAll)
if err != nil {
fmt.Printf("Getting list of packages: %v", err)
os.Exit(1)