mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
add missing alias of api errors under test
This commit is contained in:
@@ -32,7 +32,7 @@ import (
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@@ -207,7 +207,7 @@ func TestServiceAccountTokenAutoMount(t *testing.T) {
|
||||
|
||||
// Create "my" namespace
|
||||
_, err = c.CoreV1().Namespaces().Create(&v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}})
|
||||
if err != nil && !errors.IsAlreadyExists(err) {
|
||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
t.Fatalf("could not create namespace: %v", err)
|
||||
}
|
||||
|
||||
@@ -290,13 +290,13 @@ func TestServiceAccountTokenAuthentication(t *testing.T) {
|
||||
|
||||
// Create "my" namespace
|
||||
_, err = c.CoreV1().Namespaces().Create(&v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: myns}})
|
||||
if err != nil && !errors.IsAlreadyExists(err) {
|
||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
t.Fatalf("could not create namespace: %v", err)
|
||||
}
|
||||
|
||||
// Create "other" namespace
|
||||
_, err = c.CoreV1().Namespaces().Create(&v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: otherns}})
|
||||
if err != nil && !errors.IsAlreadyExists(err) {
|
||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
t.Fatalf("could not create namespace: %v", err)
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ func getServiceAccount(c *clientset.Clientset, ns string, name string, shouldWai
|
||||
var err error
|
||||
err = wait.Poll(time.Second, 10*time.Second, func() (bool, error) {
|
||||
user, err = c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
@@ -513,7 +513,7 @@ func getReferencedServiceAccountToken(c *clientset.Clientset, ns string, name st
|
||||
|
||||
findToken := func() (bool, error) {
|
||||
user, err := c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
@@ -522,7 +522,7 @@ func getReferencedServiceAccountToken(c *clientset.Clientset, ns string, name st
|
||||
|
||||
for _, ref := range user.Secrets {
|
||||
secret, err := c.CoreV1().Secrets(ns).Get(ref.Name, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
@@ -586,8 +586,8 @@ func doServiceAccountAPIRequests(t *testing.T, c *clientset.Clientset, ns string
|
||||
|
||||
for _, op := range readOps {
|
||||
err := op()
|
||||
unauthorizedError := errors.IsUnauthorized(err)
|
||||
forbiddenError := errors.IsForbidden(err)
|
||||
unauthorizedError := apierrors.IsUnauthorized(err)
|
||||
forbiddenError := apierrors.IsForbidden(err)
|
||||
|
||||
switch {
|
||||
case !authenticated && !unauthorizedError:
|
||||
@@ -603,8 +603,8 @@ func doServiceAccountAPIRequests(t *testing.T, c *clientset.Clientset, ns string
|
||||
|
||||
for _, op := range writeOps {
|
||||
err := op()
|
||||
unauthorizedError := errors.IsUnauthorized(err)
|
||||
forbiddenError := errors.IsForbidden(err)
|
||||
unauthorizedError := apierrors.IsUnauthorized(err)
|
||||
forbiddenError := apierrors.IsForbidden(err)
|
||||
|
||||
switch {
|
||||
case !authenticated && !unauthorizedError:
|
||||
|
||||
Reference in New Issue
Block a user