pull/1007/head
fibonacci1729 9 years ago
parent b28c3793a0
commit cba0c6615f

@ -27,9 +27,9 @@ import (
rspb "k8s.io/helm/pkg/proto/hapi/release" rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/labels"
kberrs "k8s.io/kubernetes/pkg/api/errors" kberrs "k8s.io/kubernetes/pkg/api/errors"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels"
) )
var b64 = base64.StdEncoding var b64 = base64.StdEncoding
@ -65,7 +65,7 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) {
logerrf(err, "get: failed to decode data %q", key) logerrf(err, "get: failed to decode data %q", key)
return nil, err return nil, err
} }
// return the release object // return the release object
return r, nil return r, nil
} }
@ -105,7 +105,7 @@ func (cfgmaps *ConfigMaps) Create(rls *rspb.Release) error {
if kberrs.IsAlreadyExists(err) { if kberrs.IsAlreadyExists(err) {
return ErrReleaseExists return ErrReleaseExists
} }
logerrf(err, "create: failed to create") logerrf(err, "create: failed to create")
return err return err
} }
@ -174,7 +174,7 @@ func newConfigMapsObject(rls *rspb.Release) (*api.ConfigMap, error) {
// create and return configmap object // create and return configmap object
return &api.ConfigMap{ return &api.ConfigMap{
ObjectMeta: api.ObjectMeta{Name: rls.Name}, ObjectMeta: api.ObjectMeta{Name: rls.Name},
Data: map[string]string{"release": s}, Data: map[string]string{"release": s},
}, nil }, nil
} }
@ -211,4 +211,4 @@ func decodeRelease(data string) (*rspb.Release, error) {
// for debugging // for debugging
func logerrf(err error, format string, args ...interface{}) { func logerrf(err error, format string, args ...interface{}) {
log.Printf("configmaps: %s: %s\n", fmt.Sprintf(format, args...), err) log.Printf("configmaps: %s: %s\n", fmt.Sprintf(format, args...), err)
} }

@ -17,19 +17,19 @@ limitations under the License.
package driver package driver
import ( import (
"testing"
"reflect" "reflect"
"testing"
"k8s.io/kubernetes/pkg/runtime"
rspb "k8s.io/helm/pkg/proto/hapi/release" rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/client/unversioned/testclient" "k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
) )
func TestConfigMapGet(t *testing.T) { func TestConfigMapGet(t *testing.T) {
// test release // test release
key := "key-1" key := "key-1"
rls := &rspb.Release{Name: key, Version: 1} rls := &rspb.Release{Name: key, Version: 1}
// create test fixture // create test fixture
cfgmaps := newTestFixture(t, rls) cfgmaps := newTestFixture(t, rls)
@ -65,7 +65,7 @@ func TestConfigMapCreate(t *testing.T) {
if err := cfgmaps.Create(rls); err != nil { if err := cfgmaps.Create(rls); err != nil {
t.Fatalf("failed to create release: %s", key, err) t.Fatalf("failed to create release: %s", key, err)
} }
// get the release back // get the release back
got, err := cfgmaps.Get(key) got, err := cfgmaps.Get(key)
if err != nil { if err != nil {
@ -142,4 +142,4 @@ func newTestFixture(t *testing.T, list ...*rspb.Release) *ConfigMaps {
return NewConfigMaps(&testclient.FakeConfigMaps{ return NewConfigMaps(&testclient.FakeConfigMaps{
Fake: testclient.NewSimpleFake(objs...), Fake: testclient.NewSimpleFake(objs...),
}) })
} }

Loading…
Cancel
Save