Skip to content

Commit

Permalink
alias local packagename for pkg/util/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengguoyong committed Oct 18, 2015
1 parent 0338e0e commit f8f9afb
Show file tree
Hide file tree
Showing 29 changed files with 83 additions and 83 deletions.
4 changes: 2 additions & 2 deletions pkg/admission/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package admission
import (
"k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors"
errs "k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

func extractKindName(a Attributes) (name, kind string, err error) {
Expand Down Expand Up @@ -50,7 +50,7 @@ func NewForbidden(a Attributes, internalError error) error {
}
name, kind, err := extractKindName(a)
if err != nil {
return apierrors.NewInternalError(errs.NewAggregate([]error{internalError, err}))
return apierrors.NewInternalError(utilerrors.NewAggregate([]error{internalError, err}))
}
return apierrors.NewForbidden(kind, name, internalError)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/fielderrors"
)

Expand Down Expand Up @@ -179,7 +179,7 @@ func NewInvalid(kind, name string, errs fielderrors.ValidationErrorList) error {
Name: name,
Causes: causes,
},
Message: fmt.Sprintf("%s %q is invalid: %v", kind, name, errors.NewAggregate(errs)),
Message: fmt.Sprintf("%s %q is invalid: %v", kind, name, utilerrors.NewAggregate(errs)),
}}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/api/validation/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/emicklei/go-restful/swagger"
"github.com/golang/glog"
apiutil "k8s.io/kubernetes/pkg/api/util"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
errs "k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/yaml"
)
Expand Down Expand Up @@ -150,14 +150,14 @@ func (s *SwaggerSchema) ValidateBytes(data []byte) error {
return fmt.Errorf("kind isn't string type")
}
if strings.HasSuffix(kind.(string), "List") {
return errors.NewAggregate(s.validateList(fields))
return utilerrors.NewAggregate(s.validateList(fields))
}
version := apiutil.GetVersion(groupVersion.(string))
allErrs := s.ValidateObject(obj, "", version+"."+kind.(string))
if len(allErrs) == 1 {
return allErrs[0]
}
return errors.NewAggregate(allErrs)
return utilerrors.NewAggregate(allErrs)
}

func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName string) errs.ValidationErrorList {
Expand Down
6 changes: 3 additions & 3 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/flushwriter"
"k8s.io/kubernetes/pkg/util/wsstream"
"k8s.io/kubernetes/pkg/version"
Expand Down Expand Up @@ -129,7 +129,7 @@ func (g *APIGroupVersion) InstallREST(container *restful.Container) error {
// TODO: g.Version only contains "version" now, it will contain "group/version" in the near future.
AddSupportedResourcesWebService(ws, g.Version, apiResources)
container.Add(ws)
return errors.NewAggregate(registrationErrors)
return utilerrors.NewAggregate(registrationErrors)
}

// UpdateREST registers the REST handlers for this APIGroupVersion to an existing web service
Expand All @@ -153,7 +153,7 @@ func (g *APIGroupVersion) UpdateREST(container *restful.Container) error {
apiResources, registrationErrors := installer.Install(ws)
// TODO: g.Version only contains "version" now, it will contain "group/version" in the near future.
AddSupportedResourcesWebService(ws, g.Version, apiResources)
return errors.NewAggregate(registrationErrors)
return utilerrors.NewAggregate(registrationErrors)
}

// newInstaller is a helper to create the installer. Used by InstallREST and UpdateREST.
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/authorizer/union/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package union

import (
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

// unionAuthzHandler authorizer against a chain of authorizer.Authorizer
Expand All @@ -41,5 +41,5 @@ func (authzHandler unionAuthzHandler) Authorize(a authorizer.Attributes) error {
return nil
}

return errors.NewAggregate(errlist)
return utilerrors.NewAggregate(errlist)
}
4 changes: 2 additions & 2 deletions pkg/client/unversioned/clientcmd/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
clientcmdlatest "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api/latest"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

const (
Expand Down Expand Up @@ -146,7 +146,7 @@ func (rules *ClientConfigLoadingRules) Load() (*clientcmdapi.Config, error) {
}
}

return config, errors.NewAggregate(errlist)
return config, utilerrors.NewAggregate(errlist)
}

// Migrate uses the MigrationRules map. If a destination file is not present, then the source file is checked.
Expand Down
20 changes: 10 additions & 10 deletions pkg/client/unversioned/clientcmd/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"

clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

func TestConfirmUsableBadInfoButOkConfig(t *testing.T) {
Expand Down Expand Up @@ -326,14 +326,14 @@ func (c configValidationTest) testContext(contextName string, t *testing.T) {
t.Errorf("Expected error containing: %v", c.expectedErrorSubstring)
}
for _, curr := range c.expectedErrorSubstring {
if len(errs) != 0 && !strings.Contains(errors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, errors.NewAggregate(errs))
if len(errs) != 0 && !strings.Contains(utilerrors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, utilerrors.NewAggregate(errs))
}
}

} else {
if len(errs) != 0 {
t.Errorf("Unexpected error: %v", errors.NewAggregate(errs))
t.Errorf("Unexpected error: %v", utilerrors.NewAggregate(errs))
}
}
}
Expand Down Expand Up @@ -386,14 +386,14 @@ func (c configValidationTest) testCluster(clusterName string, t *testing.T) {
t.Errorf("Expected error containing: %v", c.expectedErrorSubstring)
}
for _, curr := range c.expectedErrorSubstring {
if len(errs) != 0 && !strings.Contains(errors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, errors.NewAggregate(errs))
if len(errs) != 0 && !strings.Contains(utilerrors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, utilerrors.NewAggregate(errs))
}
}

} else {
if len(errs) != 0 {
t.Errorf("Unexpected error: %v", errors.NewAggregate(errs))
t.Errorf("Unexpected error: %v", utilerrors.NewAggregate(errs))
}
}
}
Expand All @@ -406,14 +406,14 @@ func (c configValidationTest) testAuthInfo(authInfoName string, t *testing.T) {
t.Errorf("Expected error containing: %v", c.expectedErrorSubstring)
}
for _, curr := range c.expectedErrorSubstring {
if len(errs) != 0 && !strings.Contains(errors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, errors.NewAggregate(errs))
if len(errs) != 0 && !strings.Contains(utilerrors.NewAggregate(errs).Error(), curr) {
t.Errorf("Expected error containing: %v, but got %v", c.expectedErrorSubstring, utilerrors.NewAggregate(errs))
}
}

} else {
if len(errs) != 0 {
t.Errorf("Unexpected error: %v", errors.NewAggregate(errs))
t.Errorf("Unexpected error: %v", utilerrors.NewAggregate(errs))
}
}
}
6 changes: 3 additions & 3 deletions pkg/cloudprovider/providers/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"

Expand Down Expand Up @@ -805,7 +805,7 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(name, region string, hosts []string)

// EnsureTCPLoadBalancerDeleted is an implementation of TCPLoadBalancer.EnsureTCPLoadBalancerDeleted.
func (gce *GCECloud) EnsureTCPLoadBalancerDeleted(name, region string) error {
err := errors.AggregateGoroutines(
err := utilerrors.AggregateGoroutines(
func() error { return gce.deleteFirewall(name, region) },
// Even though we don't hold on to static IPs for load balancers, it's
// possible that EnsureTCPLoadBalancer left one around in a failed
Expand All @@ -824,7 +824,7 @@ func (gce *GCECloud) EnsureTCPLoadBalancerDeleted(name, region string) error {
},
)
if err != nil {
return errors.Flatten(err)
return utilerrors.Flatten(err)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

// DescribeOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
Expand Down Expand Up @@ -142,7 +142,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
fmt.Fprintf(out, "%s\n\n", s)
}

return errors.NewAggregate(allErrs)
return utilerrors.NewAggregate(allErrs)
}

func DescribeMatchingResources(mapper meta.RESTMapper, typer runtime.ObjectTyper, f *cmdutil.Factory, namespace, rsrc, prefix string, out io.Writer, originalError error) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/strategicpatch"
"k8s.io/kubernetes/pkg/util/validation"
)
Expand Down Expand Up @@ -106,7 +106,7 @@ func validateNoOverwrites(meta *api.ObjectMeta, labels map[string]string) error
allErrs = append(allErrs, fmt.Errorf("'%s' already has a value (%s), and --overwrite is false", key, value))
}
}
return errors.NewAggregate(allErrs)
return utilerrors.NewAggregate(allErrs)
}

func parseLabels(spec []string) (map[string]string, []string, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

// ScaleOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
Expand Down Expand Up @@ -149,5 +149,5 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "scaled")
}

return errors.NewAggregate(errs)
return utilerrors.NewAggregate(errs)
}
4 changes: 2 additions & 2 deletions pkg/kubectl/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
)

// GeneratorParam is a parameter for a generator
Expand Down Expand Up @@ -60,7 +60,7 @@ func ValidateParams(paramSpec []GeneratorParam, params map[string]interface{}) e
}
}
}
return errors.NewAggregate(allErrs)
return utilerrors.NewAggregate(allErrs)
}

// MakeParams is a utility that creates generator parameters from a command line
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/resource/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
)

Expand Down Expand Up @@ -520,7 +520,7 @@ func (b *Builder) resourceTupleMappings() (map[string]*meta.RESTMapping, error)

func (b *Builder) visitorResult() *Result {
if len(b.errs) > 0 {
return &Result{err: errors.NewAggregate(b.errs)}
return &Result{err: utilerrors.NewAggregate(b.errs)}
}

if b.selectAll {
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubectl/resource/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/watch"
watchjson "k8s.io/kubernetes/pkg/watch/json"
)
Expand Down Expand Up @@ -829,7 +829,7 @@ func TestContinueOnErrorVisitor(t *testing.T) {
if count != 3 {
t.Fatalf("did not visit all infos: %d", count)
}
agg, ok := err.(errors.Aggregate)
agg, ok := err.(utilerrors.Aggregate)
if !ok {
t.Fatalf("unexpected error: %v", err)
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@ func TestReceiveMultipleErrors(t *testing.T) {
t.Fatalf("unexpected response: %v %t %#v", err, singular, test.Infos)
}

errs, ok := err.(errors.Aggregate)
errs, ok := err.(utilerrors.Aggregate)
if !ok {
t.Fatalf("unexpected error: %v", reflect.TypeOf(err))
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/kubectl/resource/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/errors"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/watch"
)
Expand All @@ -41,7 +41,7 @@ type Result struct {
sources []Visitor
singular bool

ignoreErrors []errors.Matcher
ignoreErrors []utilerrors.Matcher

// populated by a call to Infos
info []*Info
Expand All @@ -56,7 +56,7 @@ type Result struct {
// err.
func (r *Result) IgnoreErrors(fns ...ErrMatchFunc) *Result {
for _, fn := range fns {
r.ignoreErrors = append(r.ignoreErrors, errors.Matcher(fn))
r.ignoreErrors = append(r.ignoreErrors, utilerrors.Matcher(fn))
}
return r
}
Expand All @@ -77,7 +77,7 @@ func (r *Result) Visit(fn VisitorFunc) error {
return r.err
}
err := r.visitor.Visit(fn)
return errors.FilterOut(err, r.ignoreErrors...)
return utilerrors.FilterOut(err, r.ignoreErrors...)
}

// IntoSingular sets the provided boolean pointer to true if the Builder input
Expand Down Expand Up @@ -106,7 +106,7 @@ func (r *Result) Infos() ([]*Info, error) {
infos = append(infos, info)
return nil
})
err = errors.FilterOut(err, r.ignoreErrors...)
err = utilerrors.FilterOut(err, r.ignoreErrors...)

r.info, r.err = infos, err
return infos, err
Expand Down
Loading

0 comments on commit f8f9afb

Please sign in to comment.