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
47a94fd0
Commit
47a94fd0
authored
Feb 09, 2016
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
registry: reject new labels on deployment status updates
parent
10b6074a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
strategy.go
pkg/registry/deployment/strategy.go
+1
-0
strategy_test.go
pkg/registry/deployment/strategy_test.go
+55
-1
No files found.
pkg/registry/deployment/strategy.go
View file @
47a94fd0
...
...
@@ -92,6 +92,7 @@ func (deploymentStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
newDeployment
:=
obj
.
(
*
extensions
.
Deployment
)
oldDeployment
:=
old
.
(
*
extensions
.
Deployment
)
newDeployment
.
Spec
=
oldDeployment
.
Spec
newDeployment
.
Labels
=
oldDeployment
.
Labels
}
// ValidateUpdate is the default update validation for an end user updating status
...
...
pkg/registry/deployment/strategy_test.go
View file @
47a94fd0
...
...
@@ -17,13 +17,15 @@ limitations under the License.
package
deployment
import
(
"reflect"
"testing"
_
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
apitesting
"k8s.io/kubernetes/pkg/api/testing"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
)
func
TestSelectableFieldLabelConversions
(
t
*
testing
.
T
)
{
...
...
@@ -34,3 +36,55 @@ func TestSelectableFieldLabelConversions(t *testing.T) {
nil
,
)
}
func
TestStatusUpdates
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
old
runtime
.
Object
obj
runtime
.
Object
expected
runtime
.
Object
}{
{
old
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
}),
obj
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
,
"sneaky"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
}),
expected
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
}),
},
{
old
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
}),
obj
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
,
"sneaky"
:
"annotation"
}),
expected
:
newDeployment
(
map
[
string
]
string
{
"test"
:
"label"
},
map
[
string
]
string
{
"test"
:
"annotation"
,
"sneaky"
:
"annotation"
}),
},
}
for
_
,
test
:=
range
tests
{
deploymentStatusStrategy
{}
.
PrepareForUpdate
(
test
.
obj
,
test
.
old
)
if
!
reflect
.
DeepEqual
(
test
.
expected
,
test
.
obj
)
{
t
.
Errorf
(
"Unexpected object mismatch! Expected:
\n
%#v
\n
got:
\n
%#v"
,
test
.
expected
,
test
.
obj
)
}
}
}
func
newDeployment
(
labels
,
annotations
map
[
string
]
string
)
*
extensions
.
Deployment
{
return
&
extensions
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test"
,
Labels
:
labels
,
Annotations
:
annotations
,
},
Spec
:
extensions
.
DeploymentSpec
{
Replicas
:
1
,
Strategy
:
extensions
.
DeploymentStrategy
{
Type
:
extensions
.
RecreateDeploymentStrategyType
,
},
Template
:
api
.
PodTemplateSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"test"
,
Image
:
"test"
,
},
},
},
},
},
}
}
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