Skip to content
Permalink
Browse files

switch error packages

  • Loading branch information...
BenTheElder committed Sep 11, 2019
1 parent d8a233d commit 1b6e537ffccec009fa5725b5c3955261aad2f743
Showing with 67 additions and 85 deletions.
  1. +1 −1 cmd/kind/build/baseimage/baseimage.go
  2. +1 −1 cmd/kind/build/nodeimage/nodeimage.go
  3. +3 −4 cmd/kind/create/cluster/createcluster.go
  4. +1 −1 cmd/kind/delete/cluster/deletecluster.go
  5. +1 −1 cmd/kind/get/kubeconfig/kubeconfig.go
  6. +1 −1 cmd/kind/load/docker-image/docker-image.go
  7. +1 −1 cmd/kind/load/image-archive/image-archive.go
  8. +1 −2 pkg/build/base/base.go
  9. +1 −1 pkg/build/node/node.go
  10. +1 −2 pkg/cluster/clusters.go
  11. +1 −1 pkg/cluster/nodes/create.go
  12. +1 −3 pkg/cluster/nodes/node.go
  13. +1 −2 pkg/cluster/nodes/nodes.go
  14. +1 −2 pkg/cluster/nodes/roles.go
  15. +2 −2 pkg/cluster/nodes/util.go
  16. +1 −1 pkg/container/docker/archive.go
  17. +1 −1 pkg/container/docker/image.go
  18. +0 −1 pkg/errors/aggregate.go
  19. +1 −2 pkg/exec/local.go
  20. +2 −2 pkg/internal/apis/config/encoding/scheme.go
  21. +3 −5 pkg/internal/apis/config/validate.go
  22. +13 −15 pkg/internal/apis/config/validate_test.go
  23. +1 −1 pkg/internal/build/kube/bazelbuildbits.go
  24. +1 −1 pkg/internal/build/kube/bits.go
  25. +1 −2 pkg/internal/build/kube/dockerbuildbits.go
  26. +1 −1 pkg/internal/build/kube/source.go
  27. +1 −2 pkg/internal/build/kube/version.go
  28. +1 −2 pkg/internal/cluster/context/context.go
  29. +1 −2 pkg/internal/cluster/create/actions/config/config.go
  30. +2 −2 pkg/internal/cluster/create/actions/installcni/cni.go
  31. +2 −2 pkg/internal/cluster/create/actions/installstorage/storage.go
  32. +2 −2 pkg/internal/cluster/create/actions/kubeadminit/init.go
  33. +3 −3 pkg/internal/cluster/create/actions/kubeadmjoin/join.go
  34. +2 −2 pkg/internal/cluster/create/actions/loadbalancer/loadbalancer.go
  35. +3 −3 pkg/internal/cluster/create/nodes.go
  36. +2 −2 pkg/internal/cluster/delete/delete.go
  37. +1 −1 pkg/internal/cluster/kubeadm/config.go
  38. +1 −1 pkg/internal/cluster/loadbalancer/config.go
  39. +1 −2 pkg/internal/cluster/logs/logs.go
  40. +2 −2 pkg/util/concurrent/concurrent.go
@@ -17,10 +17,10 @@ limitations under the License.
package baseimage

import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/kind/pkg/build/base"
"sigs.k8s.io/kind/pkg/errors"
)

type flagpole struct {
@@ -17,10 +17,10 @@ limitations under the License.
package nodeimage

import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/kind/pkg/build/node"
"sigs.k8s.io/kind/pkg/errors"
)

type flagpole struct {
@@ -21,13 +21,12 @@ import (
"fmt"
"time"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"sigs.k8s.io/kind/pkg/cluster"
"sigs.k8s.io/kind/pkg/cluster/create"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/globals"
"sigs.k8s.io/kind/pkg/util"
)

type flagpole struct {
@@ -77,8 +76,8 @@ func runE(flags *flagpole) error {
create.Retain(flags.Retain),
create.WaitForReady(flags.Wait),
); err != nil {
if utilErrors, ok := err.(util.Errors); ok {
for _, problem := range utilErrors.Errors() {
if errs := errors.Errors(err); errs != nil {
for _, problem := range errs {
globals.GetLogger().Errorf("%v", problem)
}
return errors.New("aborting due to invalid configuration")
@@ -20,8 +20,8 @@ package cluster
import (
"fmt"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster"
)
@@ -22,8 +22,8 @@ import (
"io"
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster"
clusternodes "sigs.k8s.io/kind/pkg/cluster/nodes"
@@ -22,8 +22,8 @@ import (
"os"
"path/filepath"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster"
clusternodes "sigs.k8s.io/kind/pkg/cluster/nodes"
@@ -21,8 +21,8 @@ import (
"fmt"
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster"
clusternodes "sigs.k8s.io/kind/pkg/cluster/nodes"
@@ -22,8 +22,7 @@ import (
"os"
"path/filepath"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/fs"
"sigs.k8s.io/kind/pkg/globals"
@@ -26,12 +26,12 @@ import (
"time"

"github.com/google/uuid"
"github.com/pkg/errors"

"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/version"

"sigs.k8s.io/kind/pkg/container/docker"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/fs"
"sigs.k8s.io/kind/pkg/globals"
@@ -17,9 +17,8 @@ limitations under the License.
package cluster

import (
"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster/nodes"
"sigs.k8s.io/kind/pkg/errors"
)

// List returns a list of clusters for which node containers exist
@@ -20,10 +20,10 @@ import (
"fmt"
"net"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/cluster/constants"
"sigs.k8s.io/kind/pkg/container/cri"
"sigs.k8s.io/kind/pkg/container/docker"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/internal/cluster/kubeadm"
"sigs.k8s.io/kind/pkg/internal/cluster/loadbalancer"
)
@@ -27,11 +27,9 @@ import (
"strings"
"sync"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster/constants"

"sigs.k8s.io/kind/pkg/container/docker"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
)

@@ -21,9 +21,8 @@ import (
"strings"
"time"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/cluster/constants"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
)

@@ -20,9 +20,8 @@ import (
"sort"
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster/constants"
"sigs.k8s.io/kind/pkg/errors"
)

// SelectNodesByRole returns a list of nodes with the matching role
@@ -19,9 +19,9 @@ package nodes
import (
"fmt"

"sigs.k8s.io/kind/pkg/internal/cluster/kubeadm"
"sigs.k8s.io/kind/pkg/errors"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/internal/cluster/kubeadm"
"sigs.k8s.io/kind/pkg/internal/cluster/loadbalancer"
)

@@ -27,7 +27,7 @@ import (
"os"
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/errors"
)

// GetArchiveTags obtains a list of "repo:tag" docker image tags from a
@@ -20,7 +20,7 @@ import (
"fmt"
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
)

@@ -26,7 +26,6 @@ func NewAggregate(errlist []error) error {
return WithStack(k8serrors.NewAggregate(errlist))
}


// Errors returns the deepest Aggregate.Errors() in a Cause chain
// https://github.com/pkg/errors/issues/173
func Errors(err error) []error {
@@ -21,8 +21,7 @@ import (
"io"
osexec "os/exec"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/globals"
)

@@ -20,13 +20,13 @@ import (
"io/ioutil"
"os"

"github.com/pkg/errors"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

"sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
"sigs.k8s.io/kind/pkg/errors"

"sigs.k8s.io/kind/pkg/internal/apis/config"

// import conversions
@@ -19,9 +19,7 @@ package config
import (
"net"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/util"
"sigs.k8s.io/kind/pkg/errors"
)

// Validate returns a ConfigErrors with an entry for each problem
@@ -70,7 +68,7 @@ func (c *Cluster) Validate() error {
}

if len(errs) > 0 {
return util.NewErrors(errs)
return errors.NewAggregate(errs)
}
return nil
}
@@ -104,7 +102,7 @@ func (n *Node) Validate() error {
}

if len(errs) > 0 {
return util.NewErrors(errs)
return errors.NewAggregate(errs)
}

return nil
@@ -19,7 +19,7 @@ package config
import (
"testing"

"sigs.k8s.io/kind/pkg/util"
"sigs.k8s.io/kind/pkg/errors"
)

func TestClusterValidate(t *testing.T) {
@@ -85,16 +85,15 @@ func TestClusterValidate(t *testing.T) {
}
return
}
// - not castable to *Errors, in which case we have the wrong error type ...
configErrors, ok := err.(util.Errors)
if !ok {
// - doesn't container errors, in which case we have the wrong error type ...
errs := errors.Errors(err)
if errs == nil {
t.Errorf("config.Validate should only return nil or ConfigErrors{...}, got: %v", err)
return
}
// - ConfigErrors, in which case expect a certain number of errors
errors := configErrors.Errors()
if len(errors) != tc.ExpectErrors {
t.Errorf("expected %d errors but got len(%v) = %d", tc.ExpectErrors, errors, len(errors))
// - errors, in which case expect a certain number of errors
if len(errs) != tc.ExpectErrors {
t.Errorf("expected %d errors but got len(%v) = %d", tc.ExpectErrors, errs, len(errs))
}
})
}
@@ -167,16 +166,15 @@ func TestNodeValidate(t *testing.T) {
}
return
}
// - not castable to *Errors, in which case we have the wrong error type ...
configErrors, ok := err.(util.Errors)
if !ok {
// - doesn't container errors, in which case we have the wrong error type ...
errs := errors.Errors(err)
if errs == nil {
t.Errorf("config.Validate should only return nil or ConfigErrors{...}, got: %v", err)
return
}
// - ConfigErrors, in which case expect a certain number of errors
errors := configErrors.Errors()
if len(errors) != tc.ExpectErrors {
t.Errorf("expected %d errors but got len(%v) = %d", tc.ExpectErrors, errors, len(errors))
// - errors, in which case expect a certain number of errors
if len(errs) != tc.ExpectErrors {
t.Errorf("expected %d errors but got len(%v) = %d", tc.ExpectErrors, errs, len(errs))
}
})
}
@@ -22,7 +22,7 @@ import (
"path"
"path/filepath"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/internal/util/env"
)
@@ -17,7 +17,7 @@ limitations under the License.
package kube

import (
"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/errors"
)

// Bits provides the locations of Kubernetes Binaries / Images
@@ -23,8 +23,7 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/internal/util/env"
)
@@ -19,7 +19,7 @@ package kube
import (
"go/build"

"github.com/pkg/errors"
"sigs.k8s.io/kind/pkg/errors"
)

// ImportPath is the canonical import path for the kubernetes root package
@@ -22,8 +22,7 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/globals"
)
@@ -23,10 +23,9 @@ import (
"path/filepath"
"regexp"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster/constants"
"sigs.k8s.io/kind/pkg/cluster/nodes"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/internal/util/env"
)

@@ -21,10 +21,9 @@ import (
"fmt"
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kind/pkg/cluster/constants"
"sigs.k8s.io/kind/pkg/cluster/nodes"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/globals"
"sigs.k8s.io/kind/pkg/internal/apis/config"
"sigs.k8s.io/kind/pkg/internal/cluster/create/actions"

0 comments on commit 1b6e537

Please sign in to comment.
You can’t perform that action at this time.