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
91d9a90e
Commit
91d9a90e
authored
Oct 22, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace use of "id" in strings with "name"
parent
bb77a5d1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
28 additions
and
25 deletions
+28
-25
validation.go
pkg/api/validation/validation.go
+6
-6
validation_test.go
pkg/api/validation/validation_test.go
+1
-1
resource_printer.go
pkg/kubecfg/resource_printer.go
+3
-3
delete.go
pkg/kubectl/cmd/delete.go
+1
-1
modify.go
pkg/kubectl/modify.go
+6
-3
resource_printer.go
pkg/kubectl/resource_printer.go
+4
-4
etcd.go
pkg/registry/etcd/etcd.go
+3
-3
etcd_test.go
pkg/registry/etcd/etcd_test.go
+2
-2
rest.go
pkg/registry/pod/rest.go
+1
-1
rest_test.go
pkg/registry/pod/rest_test.go
+1
-1
No files found.
pkg/api/validation/validation.go
View file @
91d9a90e
...
...
@@ -333,7 +333,7 @@ func ValidatePodState(podState *api.PodState) errs.ErrorList {
func
ValidatePod
(
pod
*
api
.
Pod
)
errs
.
ErrorList
{
allErrs
:=
errs
.
ErrorList
{}
if
len
(
pod
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
id
"
,
pod
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
name
"
,
pod
.
Name
))
}
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
))
...
...
@@ -347,7 +347,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
allErrs
:=
errs
.
ErrorList
{}
if
newPod
.
Name
!=
oldPod
.
Name
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"
ID
"
,
newPod
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"
name
"
,
newPod
.
Name
))
}
if
len
(
newPod
.
DesiredState
.
Manifest
.
Containers
)
!=
len
(
oldPod
.
DesiredState
.
Manifest
.
Containers
)
{
...
...
@@ -374,9 +374,9 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
func
ValidateService
(
service
*
api
.
Service
)
errs
.
ErrorList
{
allErrs
:=
errs
.
ErrorList
{}
if
len
(
service
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
id
"
,
service
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
name
"
,
service
.
Name
))
}
else
if
!
util
.
IsDNS952Label
(
service
.
Name
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"
id
"
,
service
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"
name
"
,
service
.
Name
))
}
if
!
util
.
IsDNSSubdomain
(
service
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
service
.
Namespace
))
...
...
@@ -399,7 +399,7 @@ func ValidateService(service *api.Service) errs.ErrorList {
func
ValidateReplicationController
(
controller
*
api
.
ReplicationController
)
errs
.
ErrorList
{
allErrs
:=
errs
.
ErrorList
{}
if
len
(
controller
.
Name
)
==
0
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
id
"
,
controller
.
Name
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"
name
"
,
controller
.
Name
))
}
if
!
util
.
IsDNSSubdomain
(
controller
.
Namespace
)
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
controller
.
Namespace
))
...
...
@@ -441,7 +441,7 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ErrorList {
// ValidateBoundPod tests if required fields on a bound pod are set.
func
ValidateBoundPod
(
pod
*
api
.
BoundPod
)
(
errors
[]
error
)
{
if
!
util
.
IsDNSSubdomain
(
pod
.
Name
)
{
errors
=
append
(
errors
,
errs
.
NewFieldInvalid
(
"
id
"
,
pod
.
Name
))
errors
=
append
(
errors
,
errs
.
NewFieldInvalid
(
"
name
"
,
pod
.
Name
))
}
if
!
util
.
IsDNSSubdomain
(
pod
.
Namespace
)
{
errors
=
append
(
errors
,
errs
.
NewFieldInvalid
(
"namespace"
,
pod
.
Namespace
))
...
...
pkg/api/validation/validation_test.go
View file @
91d9a90e
...
...
@@ -813,7 +813,7 @@ func TestValidateReplicationController(t *testing.T) {
for
i
:=
range
errs
{
field
:=
errs
[
i
]
.
(
errors
.
ValidationError
)
.
Field
if
!
strings
.
HasPrefix
(
field
,
"desiredState.podTemplate."
)
&&
field
!=
"
id
"
&&
field
!=
"
name
"
&&
field
!=
"namespace"
&&
field
!=
"desiredState.replicaSelector"
&&
field
!=
"GCEPersistentDisk.ReadOnly"
&&
...
...
pkg/kubecfg/resource_printer.go
View file @
91d9a90e
...
...
@@ -138,9 +138,9 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
return
nil
}
var
podColumns
=
[]
string
{
"
ID
"
,
"Image(s)"
,
"Host"
,
"Labels"
,
"Status"
}
var
replicationControllerColumns
=
[]
string
{
"
ID
"
,
"Image(s)"
,
"Selector"
,
"Replicas"
}
var
serviceColumns
=
[]
string
{
"
ID
"
,
"Labels"
,
"Selector"
,
"IP"
,
"Port"
}
var
podColumns
=
[]
string
{
"
Name
"
,
"Image(s)"
,
"Host"
,
"Labels"
,
"Status"
}
var
replicationControllerColumns
=
[]
string
{
"
Name
"
,
"Image(s)"
,
"Selector"
,
"Replicas"
}
var
serviceColumns
=
[]
string
{
"
Name
"
,
"Labels"
,
"Selector"
,
"IP"
,
"Port"
}
var
minionColumns
=
[]
string
{
"Minion identifier"
}
var
statusColumns
=
[]
string
{
"Status"
}
var
eventColumns
=
[]
string
{
"Name"
,
"Kind"
,
"Status"
,
"Reason"
,
"Message"
}
...
...
pkg/kubectl/cmd/delete.go
View file @
91d9a90e
...
...
@@ -50,7 +50,7 @@ Examples:
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
// If command line args are passed in, use those preferentially.
if
len
(
args
)
>
0
&&
len
(
args
)
!=
2
{
usageError
(
cmd
,
"If passing in command line parameters, must be resource and
id
"
)
usageError
(
cmd
,
"If passing in command line parameters, must be resource and
name
"
)
}
var
data
[]
byte
...
...
pkg/kubectl/modify.go
View file @
91d9a90e
...
...
@@ -93,14 +93,14 @@ func doUpdate(c *client.RESTClient, resource string, obj runtime.Object) (string
// object.
id
,
err
:=
getIDFromObj
(
obj
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"
ID
not retrievable from object for update: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"
Name
not retrievable from object for update: %v"
,
err
)
}
// Get the object from the server to find out its current resource
// version to prevent race conditions in updating the object.
serverObj
,
err
:=
c
.
Get
()
.
Path
(
resource
)
.
Path
(
id
)
.
Do
()
.
Get
()
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Item
ID
%s does not exist for update: %v"
,
id
,
err
)
return
""
,
fmt
.
Errorf
(
"Item
Name
%s does not exist for update: %v"
,
id
,
err
)
}
version
,
err
:=
getResourceVersionFromObj
(
serverObj
)
if
err
!=
nil
{
...
...
@@ -134,7 +134,10 @@ func doUpdate(c *client.RESTClient, resource string, obj runtime.Object) (string
func
doDelete
(
c
*
client
.
RESTClient
,
resource
string
,
obj
runtime
.
Object
)
(
string
,
error
)
{
id
,
err
:=
getIDFromObj
(
obj
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"ID not retrievable from object for update: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"Name not retrievable from object for delete: %v"
,
err
)
}
if
id
==
""
{
return
""
,
fmt
.
Errorf
(
"The supplied resource has no Name and cannot be deleted"
)
}
err
=
c
.
Delete
()
.
Path
(
resource
)
.
Path
(
id
)
.
Do
()
.
Error
()
...
...
pkg/kubectl/resource_printer.go
View file @
91d9a90e
...
...
@@ -154,10 +154,10 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
return
nil
}
var
podColumns
=
[]
string
{
"
ID
"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
replicationControllerColumns
=
[]
string
{
"
ID
"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
serviceColumns
=
[]
string
{
"
ID
"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
minionColumns
=
[]
string
{
"
ID
"
}
var
podColumns
=
[]
string
{
"
NAME
"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
replicationControllerColumns
=
[]
string
{
"
NAME
"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
serviceColumns
=
[]
string
{
"
NAME
"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
minionColumns
=
[]
string
{
"
NAME
"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
// addDefaultHandlers adds print handlers for default Kubernetes types.
...
...
pkg/registry/etcd/etcd.go
View file @
91d9a90e
...
...
@@ -522,7 +522,7 @@ func (r *Registry) WatchServices(ctx api.Context, label, field labels.Selector,
if
!
label
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"label selectors are not supported on services"
)
}
if
value
,
found
:=
field
.
RequiresExactMatch
(
"
ID
"
);
found
{
if
value
,
found
:=
field
.
RequiresExactMatch
(
"
name
"
);
found
{
key
,
err
:=
makeServiceKey
(
ctx
,
value
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -532,7 +532,7 @@ func (r *Registry) WatchServices(ctx api.Context, label, field labels.Selector,
if
field
.
Empty
()
{
return
r
.
WatchList
(
makeServiceListKey
(
ctx
),
version
,
tools
.
Everything
)
}
return
nil
,
fmt
.
Errorf
(
"only the '
ID
' and default (everything) field selectors are supported"
)
return
nil
,
fmt
.
Errorf
(
"only the '
name
' and default (everything) field selectors are supported"
)
}
// ListEndpoints obtains a list of Services.
...
...
@@ -567,7 +567,7 @@ func (r *Registry) WatchEndpoints(ctx api.Context, label, field labels.Selector,
if
!
label
.
Empty
()
{
return
nil
,
fmt
.
Errorf
(
"label selectors are not supported on endpoints"
)
}
if
value
,
found
:=
field
.
RequiresExactMatch
(
"
ID
"
);
found
{
if
value
,
found
:=
field
.
RequiresExactMatch
(
"
name
"
);
found
{
key
,
err
:=
makeServiceEndpointsKey
(
ctx
,
value
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/registry/etcd/etcd_test.go
View file @
91d9a90e
...
...
@@ -1252,7 +1252,7 @@ func TestEtcdWatchServices(t *testing.T) {
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
watching
,
err
:=
registry
.
WatchServices
(
ctx
,
labels
.
Everything
(),
labels
.
SelectorFromSet
(
labels
.
Set
{
"
ID
"
:
"foo"
}),
labels
.
SelectorFromSet
(
labels
.
Set
{
"
name
"
:
"foo"
}),
"1"
,
)
if
err
!=
nil
{
...
...
@@ -1306,7 +1306,7 @@ func TestEtcdWatchEndpoints(t *testing.T) {
watching
,
err
:=
registry
.
WatchEndpoints
(
ctx
,
labels
.
Everything
(),
labels
.
SelectorFromSet
(
labels
.
Set
{
"
ID
"
:
"foo"
}),
labels
.
SelectorFromSet
(
labels
.
Set
{
"
name
"
:
"foo"
}),
"1"
,
)
if
err
!=
nil
{
...
...
pkg/registry/pod/rest.go
View file @
91d9a90e
...
...
@@ -141,7 +141,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
func
(
rs
*
REST
)
podToSelectableFields
(
pod
*
api
.
Pod
)
labels
.
Set
{
return
labels
.
Set
{
"
ID"
:
pod
.
Name
,
"
name"
:
pod
.
Name
,
"DesiredState.Status"
:
string
(
pod
.
DesiredState
.
Status
),
"DesiredState.Host"
:
pod
.
DesiredState
.
Host
,
}
...
...
pkg/registry/pod/rest_test.go
View file @
91d9a90e
...
...
@@ -243,7 +243,7 @@ func TestListPodListSelection(t *testing.T) {
{
expectedIDs
:
util
.
NewStringSet
(
"foo"
,
"bar"
,
"baz"
,
"qux"
,
"zot"
),
},
{
field
:
"
ID
=zot"
,
field
:
"
name
=zot"
,
expectedIDs
:
util
.
NewStringSet
(
"zot"
),
},
{
label
:
"label=qux"
,
...
...
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