Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <fabian@progra.de>
pull/4499/head
Fabian Ruff 7 years ago
parent 2e9855b98b
commit 8175eeecf4

@ -19,6 +19,7 @@ package helm // import "k8s.io/helm/pkg/helm"
import (
"bytes"
"errors"
"fmt"
"math/rand"
"strings"
"sync"
@ -31,7 +32,6 @@ import (
rls "k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/proto/hapi/version"
"k8s.io/helm/pkg/renderutil"
storage "k8s.io/helm/pkg/storage/driver"
)
// FakeClient implements Interface
@ -138,7 +138,7 @@ func (c *FakeClient) DeleteRelease(rlsName string, opts ...DeleteOption) (*rls.U
}
}
return nil, storage.ErrReleaseNotFound(rlsName)
return nil, fmt.Errorf("release: %q not found", rlsName)
}
// GetVersion returns a fake version
@ -212,7 +212,7 @@ func (c *FakeClient) ReleaseStatus(rlsName string, opts ...StatusOption) (*rls.G
}, nil
}
}
return nil, storage.ErrReleaseNotFound(rlsName)
return nil, fmt.Errorf("release: %q not found", rlsName)
}
// ReleaseContent returns the configuration for the matching release name in the fake release client.
@ -224,7 +224,7 @@ func (c *FakeClient) ReleaseContent(rlsName string, opts ...ContentOption) (resp
}, nil
}
}
return resp, storage.ErrReleaseNotFound(rlsName)
return resp, fmt.Errorf("release: %q not found", rlsName)
}
// ReleaseHistory returns a release's revision history.

@ -18,8 +18,10 @@ package helm // import "k8s.io/helm/pkg/helm"
import (
"errors"
"os/exec"
"path/filepath"
"reflect"
"strings"
"testing"
"github.com/golang/protobuf/proto"
@ -361,3 +363,15 @@ func loadChart(t *testing.T, name string) *cpb.Chart {
}
return c
}
func TestDoesNotImportKubernetes(t *testing.T) {
cmd := exec.Command("go", "list", "-f", "{{.Deps}}", ".")
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Failed to execute %s %s: %s", cmd.Path, strings.Join(cmd.Args, " "), err)
}
if strings.Contains(string(output), "k8s.io/kubernetes") {
t.Fatal("k8s.io/helm/pkg/helm contains a dependency on k8s.io/kubernetes")
}
}

Loading…
Cancel
Save