From b8bf4db3479da545a7ea151e48ee6708e8c06d2f Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 13 Apr 2016 12:06:11 -0600 Subject: [PATCH] fix(environment): make KubeClient take multiple files Rather than just taking a []byte for Install, take a map of filenames->contents. --- cmd/tiller/environment/environment.go | 8 +++++++- cmd/tiller/environment/environment_test.go | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/tiller/environment/environment.go b/cmd/tiller/environment/environment.go index f7d863b6d..3a9487305 100644 --- a/cmd/tiller/environment/environment.go +++ b/cmd/tiller/environment/environment.go @@ -38,7 +38,13 @@ type ReleaseStorage interface { // // A KubeClient must be concurrency safe. type KubeClient interface { - Install(manifest []byte) error + // Install takes a map where the key is a "file name" (read: unique relational + // id) and the value is a Kubernetes manifest containing one or more resource + // definitions. + // + // TODO: Can these be in YAML or JSON, or must they be in one particular + // format? + Install(manifests map[string]string) error } // Environment provides the context for executing a client request. diff --git a/cmd/tiller/environment/environment_test.go b/cmd/tiller/environment/environment_test.go index e42376f6e..e13f4def1 100644 --- a/cmd/tiller/environment/environment_test.go +++ b/cmd/tiller/environment/environment_test.go @@ -30,7 +30,7 @@ func (r *mockReleaseStorage) Set(k string, v *hapi.Release) error { type mockKubeClient struct { } -func (k *mockKubeClient) Install(manifest []byte) error { +func (k *mockKubeClient) Install(manifests map[string]string) error { return nil } @@ -76,7 +76,9 @@ func TestKubeClient(t *testing.T) { env := New() env.KubeClient = kc - if err := env.KubeClient.Install([]byte("apiVersion: v1\n")); err != nil { + manifests := map[string]string{} + + if err := env.KubeClient.Install(manifests); err != nil { t.Errorf("Kubeclient failed: %s", err) } }