diff --git a/lib/backend/k8s/k8s.go b/lib/backend/k8s/k8s.go index b6ec186e4..d84933241 100644 --- a/lib/backend/k8s/k8s.go +++ b/lib/backend/k8s/k8s.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016 Tigera, Inc. All rights reserved. +// Copyright (c) 2016-2017 Tigera, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -718,10 +718,7 @@ func (c *KubeClient) deleteGlobalConfig(k *model.KVPair) error { } func (c *KubeClient) getHostConfig(k model.HostConfigKey) (*model.KVPair, error) { - return &model.KVPair{ - Key: k, - Value: nil, - }, nil + return nil, errors.ErrorResourceDoesNotExist{Identifier: k} } func (c *KubeClient) listHostConfig(l model.HostConfigListOptions) ([]*model.KVPair, error) { diff --git a/lib/backend/k8s/k8s_fv_test.go b/lib/backend/k8s/k8s_fv_test.go index 7316e60e0..6ab6a9a9d 100644 --- a/lib/backend/k8s/k8s_fv_test.go +++ b/lib/backend/k8s/k8s_fv_test.go @@ -1,3 +1,17 @@ +// Copyright (c) 2016-2017 Tigera, Inc. All rights reserved. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package k8s import ( @@ -10,6 +24,7 @@ import ( log "github.com/Sirupsen/logrus" "github.com/projectcalico/libcalico-go/lib/backend/api" "github.com/projectcalico/libcalico-go/lib/backend/model" + "github.com/projectcalico/libcalico-go/lib/errors" cnet "github.com/projectcalico/libcalico-go/lib/net" k8sapi "k8s.io/client-go/pkg/api/v1" extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1" @@ -344,6 +359,12 @@ var _ = Describe("Test Syncer API for Kubernetes backend", func() { Expect(len(objs)).To(Equal(0)) }) + It("should report ErrorResourceDoesNotExist for HostConfig", func() { + kv, err := c.Get(model.HostConfigKey{Hostname: "host", Name: "foo"}) + Expect(kv).To(BeNil()) + Expect(err).To(BeAssignableToTypeOf(errors.ErrorResourceDoesNotExist{})) + }) + It("should support setting and getting GlobalConfig", func() { gc := &model.KVPair{ Key: model.GlobalConfigKey{