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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user