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
044e4854
Commit
044e4854
authored
Aug 31, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13347 from nikhiljindal/expDeployment
Auto commit by PR queue bot
parents
aaeea87e
13ecd8a7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
192 additions
and
2 deletions
+192
-2
resttest.go
pkg/api/rest/resttest/resttest.go
+1
-1
conversion.go
pkg/expapi/v1/conversion.go
+3
-1
master.go
pkg/master/master.go
+3
-0
doc.go
pkg/registry/deployment/doc.go
+17
-0
etcd.go
pkg/registry/deployment/etcd/etcd.go
+71
-0
etcd_test.go
pkg/registry/deployment/etcd/etcd_test.go
+0
-0
strategy.go
pkg/registry/deployment/strategy.go
+97
-0
No files found.
pkg/api/rest/resttest/resttest.go
View file @
044e4854
...
@@ -445,7 +445,7 @@ func (t *Tester) testUpdateInvokesValidation(obj runtime.Object, setFn SetFunc,
...
@@ -445,7 +445,7 @@ func (t *Tester) testUpdateInvokesValidation(obj runtime.Object, setFn SetFunc,
toUpdate
:=
update
(
copyOrDie
(
foo
))
toUpdate
:=
update
(
copyOrDie
(
foo
))
got
,
created
,
err
:=
t
.
storage
.
(
rest
.
Updater
)
.
Update
(
t
.
TestContext
(),
toUpdate
)
got
,
created
,
err
:=
t
.
storage
.
(
rest
.
Updater
)
.
Update
(
t
.
TestContext
(),
toUpdate
)
if
got
!=
nil
||
created
{
if
got
!=
nil
||
created
{
t
.
Errorf
(
"expected nil object and no creation
"
)
t
.
Errorf
(
"expected nil object and no creation
for object: %v"
,
toUpdate
)
}
}
if
!
errors
.
IsInvalid
(
err
)
&&
!
errors
.
IsBadRequest
(
err
)
{
if
!
errors
.
IsInvalid
(
err
)
&&
!
errors
.
IsBadRequest
(
err
)
{
t
.
Errorf
(
"expected invalid or bad request error, got %v"
,
err
)
t
.
Errorf
(
"expected invalid or bad request error, got %v"
,
err
)
...
...
pkg/expapi/v1/conversion.go
View file @
044e4854
...
@@ -212,7 +212,9 @@ func convert_v1_DeploymentSpec_To_expapi_DeploymentSpec(in *DeploymentSpec, out
...
@@ -212,7 +212,9 @@ func convert_v1_DeploymentSpec_To_expapi_DeploymentSpec(in *DeploymentSpec, out
if
defaulting
,
found
:=
s
.
DefaultingInterface
(
reflect
.
TypeOf
(
*
in
));
found
{
if
defaulting
,
found
:=
s
.
DefaultingInterface
(
reflect
.
TypeOf
(
*
in
));
found
{
defaulting
.
(
func
(
*
DeploymentSpec
))(
in
)
defaulting
.
(
func
(
*
DeploymentSpec
))(
in
)
}
}
out
.
Replicas
=
*
in
.
Replicas
if
in
.
Replicas
!=
nil
{
out
.
Replicas
=
*
in
.
Replicas
}
if
in
.
Selector
!=
nil
{
if
in
.
Selector
!=
nil
{
out
.
Selector
=
make
(
map
[
string
]
string
)
out
.
Selector
=
make
(
map
[
string
]
string
)
for
key
,
val
:=
range
in
.
Selector
{
for
key
,
val
:=
range
in
.
Selector
{
...
...
pkg/master/master.go
View file @
044e4854
...
@@ -49,6 +49,7 @@ import (
...
@@ -49,6 +49,7 @@ import (
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/registry/componentstatus"
"k8s.io/kubernetes/pkg/registry/componentstatus"
controlleretcd
"k8s.io/kubernetes/pkg/registry/controller/etcd"
controlleretcd
"k8s.io/kubernetes/pkg/registry/controller/etcd"
deploymentetcd
"k8s.io/kubernetes/pkg/registry/deployment/etcd"
"k8s.io/kubernetes/pkg/registry/endpoint"
"k8s.io/kubernetes/pkg/registry/endpoint"
endpointsetcd
"k8s.io/kubernetes/pkg/registry/endpoint/etcd"
endpointsetcd
"k8s.io/kubernetes/pkg/registry/endpoint/etcd"
eventetcd
"k8s.io/kubernetes/pkg/registry/event/etcd"
eventetcd
"k8s.io/kubernetes/pkg/registry/event/etcd"
...
@@ -770,6 +771,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
...
@@ -770,6 +771,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
autoscalerStorage
:=
horizontalpodautoscaleretcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
autoscalerStorage
:=
horizontalpodautoscaleretcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
thirdPartyResourceStorage
:=
thirdpartyresourceetcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
thirdPartyResourceStorage
:=
thirdpartyresourceetcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
daemonStorage
:=
daemonetcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
daemonStorage
:=
daemonetcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
deploymentStorage
:=
deploymentetcd
.
NewREST
(
c
.
ExpDatabaseStorage
)
storage
:=
map
[
string
]
rest
.
Storage
{
storage
:=
map
[
string
]
rest
.
Storage
{
strings
.
ToLower
(
"replicationControllers"
)
:
controllerStorage
.
ReplicationController
,
strings
.
ToLower
(
"replicationControllers"
)
:
controllerStorage
.
ReplicationController
,
...
@@ -777,6 +779,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
...
@@ -777,6 +779,7 @@ func (m *Master) expapi(c *Config) *apiserver.APIGroupVersion {
strings
.
ToLower
(
"horizontalpodautoscalers"
)
:
autoscalerStorage
,
strings
.
ToLower
(
"horizontalpodautoscalers"
)
:
autoscalerStorage
,
strings
.
ToLower
(
"thirdpartyresources"
)
:
thirdPartyResourceStorage
,
strings
.
ToLower
(
"thirdpartyresources"
)
:
thirdPartyResourceStorage
,
strings
.
ToLower
(
"daemons"
)
:
daemonStorage
,
strings
.
ToLower
(
"daemons"
)
:
daemonStorage
,
strings
.
ToLower
(
"deployments"
)
:
deploymentStorage
,
}
}
return
&
apiserver
.
APIGroupVersion
{
return
&
apiserver
.
APIGroupVersion
{
...
...
pkg/registry/deployment/doc.go
0 → 100644
View file @
044e4854
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
deployment
pkg/registry/deployment/etcd/etcd.go
0 → 100644
View file @
044e4854
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
etcd
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/deployment"
"k8s.io/kubernetes/pkg/registry/generic"
etcdgeneric
"k8s.io/kubernetes/pkg/registry/generic/etcd"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/storage"
)
type
REST
struct
{
*
etcdgeneric
.
Etcd
}
// NewREST returns a RESTStorage object that will work against deployments.
func
NewREST
(
s
storage
.
Interface
)
*
REST
{
prefix
:=
"/deployments"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
expapi
.
Deployment
{}
},
// NewListFunc returns an object capable of storing results of an etcd list.
NewListFunc
:
func
()
runtime
.
Object
{
return
&
expapi
.
DeploymentList
{}
},
// Produces a path that etcd understands, to the root of the resource
// by combining the namespace in the context with the given prefix.
KeyRootFunc
:
func
(
ctx
api
.
Context
)
string
{
return
etcdgeneric
.
NamespaceKeyRootFunc
(
ctx
,
prefix
)
},
// Produces a path that etcd understands, to the resource by combining
// the namespace in the context with the given prefix.
KeyFunc
:
func
(
ctx
api
.
Context
,
name
string
)
(
string
,
error
)
{
return
etcdgeneric
.
NamespaceKeyFunc
(
ctx
,
prefix
,
name
)
},
// Retrieve the name field of a deployment.
ObjectNameFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
return
obj
.
(
*
expapi
.
Deployment
)
.
Name
,
nil
},
// Used to match objects based on labels/fields for list.
PredicateFunc
:
func
(
label
labels
.
Selector
,
field
fields
.
Selector
)
generic
.
Matcher
{
return
deployment
.
MatchDeployment
(
label
,
field
)
},
EndpointName
:
"deployments"
,
// Used to validate deployment creation.
CreateStrategy
:
deployment
.
Strategy
,
// Used to validate deployment updates.
UpdateStrategy
:
deployment
.
Strategy
,
Storage
:
s
,
}
return
&
REST
{
store
}
}
pkg/registry/deployment/etcd/etcd_test.go
0 → 100755
View file @
044e4854
This diff is collapsed.
Click to expand it.
pkg/registry/deployment/strategy.go
0 → 100644
View file @
044e4854
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
deployment
import
(
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/expapi"
"k8s.io/kubernetes/pkg/expapi/validation"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/registry/generic"
"k8s.io/kubernetes/pkg/runtime"
errs
"k8s.io/kubernetes/pkg/util/fielderrors"
)
// deploymentStrategy implements behavior for Deployments.
type
deploymentStrategy
struct
{
runtime
.
ObjectTyper
api
.
NameGenerator
}
// Strategy is the default logic that applies when creating and updating Deployment
// objects via the REST API.
var
Strategy
=
deploymentStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
}
// NamespaceScoped is true for deployment.
func
(
deploymentStrategy
)
NamespaceScoped
()
bool
{
return
true
}
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func
(
deploymentStrategy
)
PrepareForCreate
(
obj
runtime
.
Object
)
{
}
// Validate validates a new deployment.
func
(
deploymentStrategy
)
Validate
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
errs
.
ValidationErrorList
{
deployment
:=
obj
.
(
*
expapi
.
Deployment
)
return
validation
.
ValidateDeployment
(
deployment
)
}
// AllowCreateOnUpdate is false for deployments.
func
(
deploymentStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func
(
deploymentStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
}
// ValidateUpdate is the default update validation for an end user.
func
(
deploymentStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
errs
.
ValidationErrorList
{
return
validation
.
ValidateDeploymentUpdate
(
old
.
(
*
expapi
.
Deployment
),
obj
.
(
*
expapi
.
Deployment
))
}
func
(
deploymentStrategy
)
AllowUnconditionalUpdate
()
bool
{
return
true
}
// DeploymentToSelectableFields returns a field set that represents the object.
func
DeploymentToSelectableFields
(
deployment
*
expapi
.
Deployment
)
fields
.
Set
{
return
fields
.
Set
{
"metadata.name"
:
deployment
.
Name
,
}
}
// MatchDeployment is the filter used by the generic etcd backend to route
// watch events from etcd to clients of the apiserver only interested in specific
// labels/fields.
func
MatchDeployment
(
label
labels
.
Selector
,
field
fields
.
Selector
)
generic
.
Matcher
{
return
&
generic
.
SelectionPredicate
{
Label
:
label
,
Field
:
field
,
GetAttrs
:
func
(
obj
runtime
.
Object
)
(
labels
.
Set
,
fields
.
Set
,
error
)
{
deployment
,
ok
:=
obj
.
(
*
expapi
.
Deployment
)
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"given object is not a deployment."
)
}
return
labels
.
Set
(
deployment
.
ObjectMeta
.
Labels
),
DeploymentToSelectableFields
(
deployment
),
nil
},
}
}
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