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
81894608
Commit
81894608
authored
Sep 14, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13844 from tummychow/label-deps-2
Auto commit by PR queue bot
parents
653e5def
a21c52a7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
22 additions
and
21 deletions
+22
-21
events.go
pkg/api/validation/events.go
+2
-2
validation.go
pkg/api/validation/validation.go
+0
-0
validation.go
pkg/apis/experimental/validation/validation.go
+3
-2
validation.go
pkg/client/unversioned/clientcmd/validation.go
+2
-2
label.go
pkg/kubectl/cmd/label.go
+3
-3
run.go
pkg/kubectl/run.go
+2
-2
plugins.go
pkg/kubelet/network/plugins.go
+2
-2
selector.go
pkg/labels/selector.go
+4
-4
validation.go
pkg/util/validation/validation.go
+1
-1
validation_test.go
pkg/util/validation/validation_test.go
+1
-1
plugins.go
pkg/volume/plugins.go
+2
-2
No files found.
pkg/api/validation/events.go
View file @
81894608
...
...
@@ -18,8 +18,8 @@ package validation
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/validation"
)
// ValidateEvent makes sure that the event makes sense.
...
...
@@ -30,7 +30,7 @@ func ValidateEvent(event *api.Event) errs.ValidationErrorList {
event
.
Namespace
!=
event
.
InvolvedObject
.
Namespace
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"involvedObject.namespace"
,
event
.
InvolvedObject
.
Namespace
,
"namespace does not match involvedObject"
))
}
if
!
util
.
IsDNS1123Subdomain
(
event
.
Namespace
)
{
if
!
validation
.
IsDNS1123Subdomain
(
event
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
event
.
Namespace
,
""
))
}
return
allErrs
...
...
pkg/api/validation/validation.go
View file @
81894608
This diff is collapsed.
Click to expand it.
pkg/apis/experimental/validation/validation.go
View file @
81894608
...
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/util"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/validation"
)
const
isNegativeErrorMsg
string
=
`must be non-negative`
...
...
@@ -170,7 +171,7 @@ func ValidateDeploymentName(name string, prefix bool) (bool, string) {
func
ValidatePositiveIntOrPercent
(
intOrPercent
util
.
IntOrString
,
fieldName
string
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
if
intOrPercent
.
Kind
==
util
.
IntstrString
{
if
!
util
.
IsValidPercent
(
intOrPercent
.
StrVal
)
{
if
!
validation
.
IsValidPercent
(
intOrPercent
.
StrVal
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
fieldName
,
intOrPercent
,
"value should be int(5) or percentage(5%)"
))
}
...
...
@@ -181,7 +182,7 @@ func ValidatePositiveIntOrPercent(intOrPercent util.IntOrString, fieldName strin
}
func
getPercentValue
(
intOrStringValue
util
.
IntOrString
)
(
int
,
bool
)
{
if
intOrStringValue
.
Kind
!=
util
.
IntstrString
||
!
util
.
IsValidPercent
(
intOrStringValue
.
StrVal
)
{
if
intOrStringValue
.
Kind
!=
util
.
IntstrString
||
!
validation
.
IsValidPercent
(
intOrStringValue
.
StrVal
)
{
return
0
,
false
}
value
,
_
:=
strconv
.
Atoi
(
intOrStringValue
.
StrVal
[
:
len
(
intOrStringValue
.
StrVal
)
-
1
])
...
...
pkg/client/unversioned/clientcmd/validation.go
View file @
81894608
...
...
@@ -23,8 +23,8 @@ import (
"strings"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/util"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/validation"
)
var
ErrNoContext
=
errors
.
New
(
"no context chosen"
)
...
...
@@ -232,7 +232,7 @@ func validateContext(contextName string, context clientcmdapi.Context, config cl
validationErrors
=
append
(
validationErrors
,
fmt
.
Errorf
(
"cluster %q was not found for context %q"
,
context
.
Cluster
,
contextName
))
}
if
(
len
(
context
.
Namespace
)
!=
0
)
&&
!
util
.
IsDNS952Label
(
context
.
Namespace
)
{
if
(
len
(
context
.
Namespace
)
!=
0
)
&&
!
validation
.
IsDNS952Label
(
context
.
Namespace
)
{
validationErrors
=
append
(
validationErrors
,
fmt
.
Errorf
(
"namespace %q for context %q does not conform to the kubernetes DNS952 rules"
,
context
.
Namespace
,
contextName
))
}
...
...
pkg/kubectl/cmd/label.go
View file @
81894608
...
...
@@ -27,8 +27,8 @@ 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"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/validation"
)
// LabelOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
...
...
@@ -77,7 +77,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd
:=
&
cobra
.
Command
{
Use
:
"label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]"
,
Short
:
"Update the labels on a resource"
,
Long
:
fmt
.
Sprintf
(
label_long
,
util
.
LabelValueMaxLength
),
Long
:
fmt
.
Sprintf
(
label_long
,
validation
.
LabelValueMaxLength
),
Example
:
label_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
err
:=
RunLabel
(
f
,
out
,
cmd
,
args
,
options
)
...
...
@@ -113,7 +113,7 @@ func parseLabels(spec []string) (map[string]string, []string, error) {
for
_
,
labelSpec
:=
range
spec
{
if
strings
.
Index
(
labelSpec
,
"="
)
!=
-
1
{
parts
:=
strings
.
Split
(
labelSpec
,
"="
)
if
len
(
parts
)
!=
2
||
len
(
parts
[
1
])
==
0
||
!
util
.
IsValidLabelValue
(
parts
[
1
])
{
if
len
(
parts
)
!=
2
||
len
(
parts
[
1
])
==
0
||
!
validation
.
IsValidLabelValue
(
parts
[
1
])
{
return
nil
,
nil
,
fmt
.
Errorf
(
"invalid label spec: %v"
,
labelSpec
)
}
labels
[
parts
[
0
]]
=
parts
[
1
]
...
...
pkg/kubectl/run.go
View file @
81894608
...
...
@@ -24,7 +24,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util
/validation
"
)
type
BasicReplicationController
struct
{}
...
...
@@ -394,7 +394,7 @@ func parseEnvs(envArray []string) ([]api.EnvVar, error) {
envs
:=
[]
api
.
EnvVar
{}
for
_
,
env
:=
range
envArray
{
parts
:=
strings
.
Split
(
env
,
"="
)
if
len
(
parts
)
!=
2
||
!
util
.
IsCIdentifier
(
parts
[
0
])
||
len
(
parts
[
1
])
==
0
{
if
len
(
parts
)
!=
2
||
!
validation
.
IsCIdentifier
(
parts
[
0
])
||
len
(
parts
[
1
])
==
0
{
return
nil
,
fmt
.
Errorf
(
"invalid env: %v"
,
env
)
}
envVar
:=
api
.
EnvVar
{
Name
:
parts
[
0
],
Value
:
parts
[
1
]}
...
...
pkg/kubelet/network/plugins.go
View file @
81894608
...
...
@@ -25,8 +25,8 @@ import (
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
kubeletTypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/validation"
)
const
DefaultPluginName
=
"kubernetes.io/no-op"
...
...
@@ -87,7 +87,7 @@ func InitNetworkPlugin(plugins []NetworkPlugin, networkPluginName string, host H
allErrs
:=
[]
error
{}
for
_
,
plugin
:=
range
plugins
{
name
:=
plugin
.
Name
()
if
!
util
.
IsQualifiedName
(
name
)
{
if
!
validation
.
IsQualifiedName
(
name
)
{
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"network plugin has invalid name: %#v"
,
plugin
))
continue
}
...
...
pkg/labels/selector.go
View file @
81894608
...
...
@@ -22,9 +22,9 @@ import (
"sort"
"strings"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/fielderrors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/validation"
)
// Selector represents a label selector.
...
...
@@ -647,17 +647,17 @@ func Parse(selector string) (Selector, error) {
return
nil
,
error
}
const
qualifiedNameErrorMsg
string
=
"must match regex ["
+
util
.
DNS1123SubdomainFmt
+
" / ] "
+
util
.
DNS1123LabelFmt
const
qualifiedNameErrorMsg
string
=
"must match regex ["
+
validation
.
DNS1123SubdomainFmt
+
" / ] "
+
validation
.
DNS1123LabelFmt
func
validateLabelKey
(
k
string
)
error
{
if
!
util
.
IsQualifiedName
(
k
)
{
if
!
validation
.
IsQualifiedName
(
k
)
{
return
fielderrors
.
NewFieldInvalid
(
"label key"
,
k
,
qualifiedNameErrorMsg
)
}
return
nil
}
func
validateLabelValue
(
v
string
)
error
{
if
!
util
.
IsValidLabelValue
(
v
)
{
if
!
validation
.
IsValidLabelValue
(
v
)
{
return
fielderrors
.
NewFieldInvalid
(
"label value"
,
v
,
qualifiedNameErrorMsg
)
}
return
nil
...
...
pkg/util/validation.go
→
pkg/util/validation
/validation
.go
View file @
81894608
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
util
package
validation
import
(
"net"
...
...
pkg/util/validation_test.go
→
pkg/util/validation
/validation
_test.go
View file @
81894608
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
util
package
validation
import
(
"strings"
...
...
pkg/volume/plugins.go
View file @
81894608
...
...
@@ -26,9 +26,9 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/validation"
)
// VolumeOptions contains option information about a volume.
...
...
@@ -203,7 +203,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, host VolumeHost)
allErrs
:=
[]
error
{}
for
_
,
plugin
:=
range
plugins
{
name
:=
plugin
.
Name
()
if
!
util
.
IsQualifiedName
(
name
)
{
if
!
validation
.
IsQualifiedName
(
name
)
{
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"volume plugin has invalid name: %#v"
,
plugin
))
continue
}
...
...
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