commit a local schema file so the CI tests do not need to talk to server to fetch it

pull/1217/merge^2
Ville Aikas 9 years ago
parent 36595555ed
commit fec50a075c

@ -24,6 +24,7 @@ package environment
import (
"io"
"os"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine"
@ -195,6 +196,8 @@ type Environment struct {
Releases *storage.Storage
// KubeClient is a Kubernetes API client.
KubeClient KubeClient
// Validation schema directory.
SchemaDir string
}
// New returns an environment initialized with the defaults.
@ -210,5 +213,6 @@ func New() *Environment {
EngineYard: ey,
Releases: storage.Init(driver.NewMemory()),
KubeClient: kube.New(nil),
SchemaDir: os.TempDir(),
}
}

@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"log"
"os"
"regexp"
"sort"
"strings"
@ -279,7 +278,7 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
// Validate the manifest
if req.Validate {
err := validateResources(updatedRelease.Namespace, modified)
err := validateResources(updatedRelease.Namespace, s.env.SchemaDir, modified)
if err != nil {
return nil, err
}
@ -578,7 +577,7 @@ func (s *releaseServer) performRelease(r *release.Release, req *services.Install
// Validate the manifest
if req.Validate {
err := validateResources(r.Namespace, b)
err := validateResources(r.Namespace, s.env.SchemaDir, b)
if err != nil {
return res, err
}
@ -714,9 +713,9 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
// validateResources takes a namespace and a manifest (fully expanded set of templates) and
// validates resources.
func validateResources(namespace string, manifest *bytes.Buffer) error {
func validateResources(namespace string, schemaDir string, manifest *bytes.Buffer) error {
f := cmdutil.NewFactory(nil)
schema, err := f.Validator(true, os.TempDir())
schema, err := f.Validator(true, schemaDir)
if err != nil {
return err
}

@ -1091,13 +1091,14 @@ func TestListReleasesFilter(t *testing.T) {
func testValidateResources(t *testing.T) {
b := bytes.NewBufferString("")
validateResources("default", b)
validateResources("default", "", b)
}
func mockEnvironment() *environment.Environment {
e := environment.New()
e.Releases = storage.Init(driver.NewMemory())
e.KubeClient = &environment.PrintingKubeClient{Out: os.Stdout}
e.SchemaDir = "./testdata"
return e
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save