Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
680ce72c
Commit
680ce72c
authored
Jan 13, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move api/errors to apimachinery
parent
eb9f9534
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
67 deletions
+40
-67
BUILD
pkg/api/errors/BUILD
+0
-54
doc.go
pkg/api/errors/doc.go
+6
-3
OWNERS
staging/src/k8s.io/apimachinery/pkg/api/errors/OWNERS
+0
-0
doc.go
staging/src/k8s.io/apimachinery/pkg/api/errors/doc.go
+18
-0
errors.go
staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go
+0
-0
errors_test.go
...ing/src/k8s.io/apimachinery/pkg/api/errors/errors_test.go
+16
-10
No files found.
pkg/api/errors/BUILD
deleted
100644 → 0
View file @
eb9f9534
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"errors.go",
],
tags = ["automanaged"],
deps = [
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/util/validation/field",
],
)
go_test(
name = "go_default_test",
srcs = ["errors_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/util/validation/field",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//pkg/api/errors/storage:all-srcs",
],
tags = ["automanaged"],
)
pkg/api/errors/doc.go
View file @
680ce72c
/*
/*
Copyright 201
4
The Kubernetes Authors.
Copyright 201
6
The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
...
@@ -14,5 +14,8 @@ See the License for the specific language governing permissions and
...
@@ -14,5 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// Package errors provides detailed error types for api field validation.
// Package errors is for verify-godeps.sh and is temporary
package
errors
// import "k8s.io/kubernetes/pkg/api/errors"
// TODO apimachinery remove this empty package. Godep fails without this because heapster relies
// on this package. This will allow us to start splitting packages, but will force
// heapster to update on their next kube rebase.
package
errors
pkg/api/errors/OWNERS
→
staging/src/k8s.io/apimachinery/
pkg/api/errors/OWNERS
View file @
680ce72c
File moved
staging/src/k8s.io/apimachinery/pkg/api/errors/doc.go
0 → 100644
View file @
680ce72c
/*
Copyright 2014 The Kubernetes Authors.
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 errors provides detailed error types for api field validation.
package
errors
// import "k8s.io/kubernetes/pkg/api/errors"
pkg/api/errors/errors.go
→
staging/src/k8s.io/apimachinery/
pkg/api/errors/errors.go
View file @
680ce72c
File moved
pkg/api/errors/errors_test.go
→
staging/src/k8s.io/apimachinery/
pkg/api/errors/errors_test.go
View file @
680ce72c
...
@@ -26,11 +26,17 @@ import (
...
@@ -26,11 +26,17 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
)
)
func
resource
(
resource
string
)
schema
.
GroupResource
{
return
schema
.
GroupResource
{
Group
:
""
,
Resource
:
resource
}
}
func
kind
(
kind
string
)
schema
.
GroupKind
{
return
schema
.
GroupKind
{
Group
:
""
,
Kind
:
kind
}
}
func
TestErrorNew
(
t
*
testing
.
T
)
{
func
TestErrorNew
(
t
*
testing
.
T
)
{
err
:=
NewAlreadyExists
(
api
.
R
esource
(
"tests"
),
"1"
)
err
:=
NewAlreadyExists
(
r
esource
(
"tests"
),
"1"
)
if
!
IsAlreadyExists
(
err
)
{
if
!
IsAlreadyExists
(
err
)
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonAlreadyExists
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonAlreadyExists
)
}
}
...
@@ -56,34 +62,34 @@ func TestErrorNew(t *testing.T) {
...
@@ -56,34 +62,34 @@ func TestErrorNew(t *testing.T) {
t
.
Errorf
(
"expected to not be %s"
,
metav1
.
StatusReasonMethodNotAllowed
)
t
.
Errorf
(
"expected to not be %s"
,
metav1
.
StatusReasonMethodNotAllowed
)
}
}
if
!
IsConflict
(
NewConflict
(
api
.
R
esource
(
"tests"
),
"2"
,
errors
.
New
(
"message"
)))
{
if
!
IsConflict
(
NewConflict
(
r
esource
(
"tests"
),
"2"
,
errors
.
New
(
"message"
)))
{
t
.
Errorf
(
"expected to be conflict"
)
t
.
Errorf
(
"expected to be conflict"
)
}
}
if
!
IsNotFound
(
NewNotFound
(
api
.
R
esource
(
"tests"
),
"3"
))
{
if
!
IsNotFound
(
NewNotFound
(
r
esource
(
"tests"
),
"3"
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonNotFound
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonNotFound
)
}
}
if
!
IsInvalid
(
NewInvalid
(
api
.
K
ind
(
"Test"
),
"2"
,
nil
))
{
if
!
IsInvalid
(
NewInvalid
(
k
ind
(
"Test"
),
"2"
,
nil
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonInvalid
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonInvalid
)
}
}
if
!
IsBadRequest
(
NewBadRequest
(
"reason"
))
{
if
!
IsBadRequest
(
NewBadRequest
(
"reason"
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonBadRequest
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonBadRequest
)
}
}
if
!
IsForbidden
(
NewForbidden
(
api
.
R
esource
(
"tests"
),
"2"
,
errors
.
New
(
"reason"
)))
{
if
!
IsForbidden
(
NewForbidden
(
r
esource
(
"tests"
),
"2"
,
errors
.
New
(
"reason"
)))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonForbidden
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonForbidden
)
}
}
if
!
IsUnauthorized
(
NewUnauthorized
(
"reason"
))
{
if
!
IsUnauthorized
(
NewUnauthorized
(
"reason"
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonUnauthorized
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonUnauthorized
)
}
}
if
!
IsServerTimeout
(
NewServerTimeout
(
api
.
R
esource
(
"tests"
),
"reason"
,
0
))
{
if
!
IsServerTimeout
(
NewServerTimeout
(
r
esource
(
"tests"
),
"reason"
,
0
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonServerTimeout
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonServerTimeout
)
}
}
if
time
,
ok
:=
SuggestsClientDelay
(
NewServerTimeout
(
api
.
R
esource
(
"tests"
),
"doing something"
,
10
));
time
!=
10
||
!
ok
{
if
time
,
ok
:=
SuggestsClientDelay
(
NewServerTimeout
(
r
esource
(
"tests"
),
"doing something"
,
10
));
time
!=
10
||
!
ok
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonServerTimeout
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonServerTimeout
)
}
}
if
time
,
ok
:=
SuggestsClientDelay
(
NewTimeoutError
(
"test reason"
,
10
));
time
!=
10
||
!
ok
{
if
time
,
ok
:=
SuggestsClientDelay
(
NewTimeoutError
(
"test reason"
,
10
));
time
!=
10
||
!
ok
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonTimeout
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonTimeout
)
}
}
if
!
IsMethodNotSupported
(
NewMethodNotSupported
(
api
.
R
esource
(
"foos"
),
"delete"
))
{
if
!
IsMethodNotSupported
(
NewMethodNotSupported
(
r
esource
(
"foos"
),
"delete"
))
{
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonMethodNotAllowed
)
t
.
Errorf
(
"expected to be %s"
,
metav1
.
StatusReasonMethodNotAllowed
)
}
}
}
}
...
@@ -152,7 +158,7 @@ func TestNewInvalid(t *testing.T) {
...
@@ -152,7 +158,7 @@ func TestNewInvalid(t *testing.T) {
for
i
,
testCase
:=
range
testCases
{
for
i
,
testCase
:=
range
testCases
{
vErr
,
expected
:=
testCase
.
Err
,
testCase
.
Details
vErr
,
expected
:=
testCase
.
Err
,
testCase
.
Details
expected
.
Causes
[
0
]
.
Message
=
vErr
.
ErrorBody
()
expected
.
Causes
[
0
]
.
Message
=
vErr
.
ErrorBody
()
err
:=
NewInvalid
(
api
.
K
ind
(
"Kind"
),
"name"
,
field
.
ErrorList
{
vErr
})
err
:=
NewInvalid
(
k
ind
(
"Kind"
),
"name"
,
field
.
ErrorList
{
vErr
})
status
:=
err
.
ErrStatus
status
:=
err
.
ErrStatus
if
status
.
Code
!=
422
||
status
.
Reason
!=
metav1
.
StatusReasonInvalid
{
if
status
.
Code
!=
422
||
status
.
Reason
!=
metav1
.
StatusReasonInvalid
{
t
.
Errorf
(
"%d: unexpected status: %#v"
,
i
,
status
)
t
.
Errorf
(
"%d: unexpected status: %#v"
,
i
,
status
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment