mirror of https://github.com/kubernetes/kops.git
Return apierrors NotFound when object not found
This commit is contained in:
parent
7bd0a6a703
commit
65aea59418
|
@ -52,8 +52,14 @@ func (c *ClusterVFS) Get(name string, options metav1.GetOptions) (*api.Cluster,
|
|||
if options.ResourceVersion != "" {
|
||||
return nil, fmt.Errorf("ResourceVersion not supported in ClusterVFS::Get")
|
||||
}
|
||||
// TODO: Return not found
|
||||
return c.find(name)
|
||||
o, err := c.find(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if o == nil {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "Cluster"}, name)
|
||||
}
|
||||
return o, nil
|
||||
}
|
||||
|
||||
// Deprecated, but we need this for now..
|
||||
|
|
|
@ -63,7 +63,7 @@ func (c *commonVFS) init(kind string, basePath vfs.Path, storeVersion runtime.Gr
|
|||
c.basePath = basePath
|
||||
}
|
||||
|
||||
func (c *commonVFS) get(name string) (runtime.Object, error) {
|
||||
func (c *commonVFS) find(name string) (runtime.Object, error) {
|
||||
o, err := c.readConfig(c.basePath.Join(name))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -240,7 +240,7 @@ func (c *commonVFS) readAll(items interface{}) (interface{}, error) {
|
|||
}
|
||||
|
||||
for _, name := range names {
|
||||
o, err := c.get(name)
|
||||
o, err := c.find(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ package vfsclientset
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
api "k8s.io/kops/pkg/apis/kops"
|
||||
|
@ -52,12 +54,12 @@ func (c *FederationVFS) Get(name string, options metav1.GetOptions) (*api.Federa
|
|||
if options.ResourceVersion != "" {
|
||||
return nil, fmt.Errorf("ResourceVersion not supported in FederationVFS::Get")
|
||||
}
|
||||
o, err := c.get(name)
|
||||
o, err := c.find(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if o == nil {
|
||||
return nil, nil
|
||||
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "Federation"}, name)
|
||||
}
|
||||
return o.(*api.Federation), nil
|
||||
}
|
||||
|
|
|
@ -20,8 +20,10 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
|
@ -94,14 +96,13 @@ func (c *InstanceGroupVFS) Get(name string, options metav1.GetOptions) (*api.Ins
|
|||
return nil, fmt.Errorf("ResourceVersion not supported in InstanceGroupVFS::Get")
|
||||
}
|
||||
|
||||
o, err := c.get(name)
|
||||
o, err := c.find(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if o == nil {
|
||||
return nil, nil
|
||||
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "InstanceGroup"}, name)
|
||||
}
|
||||
|
||||
ig := o.(*api.InstanceGroup)
|
||||
c.addLabels(ig)
|
||||
|
||||
|
|
Loading…
Reference in New Issue