-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rebase 1.9.0 beta.1 #17576
rebase 1.9.0 beta.1 #17576
Changes from 1 commit
f0bb2b6
c671103
07c6b99
710998e
c8626b7
f3769c7
123246b
534c679
ca1b85f
9ff7f3f
d34b354
df449cc
f046a0b
3c7a135
3f45cdc
ee0f726
de36874
64974bc
bf64f2c
cf235c2
4bc612e
66d94ff
fc9b4e2
5b3859b
d1b5fe8
42a1e2c
d49083e
07e5313
ab033d4
32a0c9a
27ad23a
f490d38
2f11419
b3fa18d
22f0b91
0aedd29
7f86e08
99c59c6
afdcb87
2abedd5
5d40a0f
4383cd7
7ffc267
244afd3
30fe89a
de21f14
80cef2d
a92560d
a1cef1f
8454d7d
9344e48
062ffb1
93bd84a
0089bbb
ad7d2fc
60d3fa9
b15c3b6
1d18e82
31f33b0
2cf15a3
ee8266b
bb2ecf0
2db374f
a4d2794
ebc468c
7256949
6c58566
d4ee63c
9e3ca9a
6b39f30
2fa3a79
d826d91
a783419
5c42201
b80c0d2
088b81d
cdc12ca
b374cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,14 +112,17 @@ func (r *REST) Get(ctx apirequest.Context, id string, options *metav1.GetOptions | |
return newISTag(tag, imageStream, image, false) | ||
} | ||
|
||
func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runtime.Object, error) { | ||
func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, _ bool) (runtime.Object, error) { | ||
istag, ok := obj.(*imageapi.ImageStreamTag) | ||
if !ok { | ||
return nil, kapierrors.NewBadRequest(fmt.Sprintf("obj is not an ImageStreamTag: %#v", obj)) | ||
} | ||
if err := rest.BeforeCreate(Strategy, ctx, obj); err != nil { | ||
return nil, err | ||
} | ||
if err := createValidation(obj.DeepCopyObject()); err != nil { | ||
return nil, err | ||
} | ||
namespace, ok := apirequest.NamespaceFrom(ctx) | ||
if !ok { | ||
return nil, kapierrors.NewBadRequest("a namespace must be specified to import images") | ||
|
@@ -172,7 +175,7 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti | |
return istag, nil | ||
} | ||
|
||
func (r *REST) Update(ctx apirequest.Context, tagName string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { | ||
func (r *REST) Update(ctx apirequest.Context, tagName string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { | ||
name, tag, err := nameAndTag(tagName) | ||
if err != nil { | ||
return nil, false, err | ||
|
@@ -237,10 +240,16 @@ func (r *REST) Update(ctx apirequest.Context, tagName string, objInfo rest.Updat | |
if err := rest.BeforeCreate(Strategy, ctx, obj); err != nil { | ||
return nil, false, err | ||
} | ||
if err := createValidation(obj.DeepCopyObject()); err != nil { | ||
return nil, false, err | ||
} | ||
} else { | ||
if err := rest.BeforeUpdate(Strategy, ctx, obj, old); err != nil { | ||
return nil, false, err | ||
} | ||
if err := updateValidation(obj.DeepCopyObject(), old.DeepCopyObject()); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
An update that allows create if it doesn't exist. imagestreamtags don't do that. Also, nil receivers are allowed and as I recall handled by the generated deep copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nil receivers for struct pointers. For interfaces they panic. |
||
return nil, false, err | ||
} | ||
} | ||
|
||
// update the spec tag | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ func (s *REST) Get(ctx apirequest.Context, name string, options *metav1.GetOptio | |
var _ = rest.Creater(&REST{}) | ||
|
||
// Create registers the given Project. | ||
func (s *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runtime.Object, error) { | ||
func (s *REST) Create(ctx apirequest.Context, obj runtime.Object, creationValidation rest.ValidateObjectFunc, _ bool) (runtime.Object, error) { | ||
project, ok := obj.(*projectapi.Project) | ||
if !ok { | ||
return nil, fmt.Errorf("not a project: %#v", obj) | ||
|
@@ -138,6 +138,10 @@ func (s *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti | |
if errs := s.createStrategy.Validate(ctx, obj); len(errs) > 0 { | ||
return nil, kerrors.NewInvalid(projectapi.Kind("Project"), project.Name, errs) | ||
} | ||
if err := creationValidation(project.DeepCopyObject()); err != nil { | ||
return nil, err | ||
} | ||
|
||
namespace, err := s.client.Create(projectutil.ConvertProject(project)) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -147,7 +151,7 @@ func (s *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti | |
|
||
var _ = rest.Updater(&REST{}) | ||
|
||
func (s *REST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { | ||
func (s *REST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo, creationValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { | ||
oldObj, err := s.Get(ctx, name, &metav1.GetOptions{}) | ||
if err != nil { | ||
return nil, false, err | ||
|
@@ -167,6 +171,9 @@ func (s *REST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedO | |
if errs := s.updateStrategy.ValidateUpdate(ctx, obj, oldObj); len(errs) > 0 { | ||
return nil, false, kerrors.NewInvalid(projectapi.Kind("Project"), project.Name, errs) | ||
} | ||
if err := updateValidation(obj.DeepCopyObject(), oldObj.DeepCopyObject()); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here |
||
return nil, false, err | ||
} | ||
|
||
namespace, err := s.client.Update(projectutil.ConvertProject(project)) | ||
if err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sttts the DeepCopyObject can be nil, right? do we care here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't care here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeepCopyObject is an interface func. If obj is nil, this call panics. But DeepCopyObject will never return nil. Note this is different for DeepCopy() as it is called on a struct pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I agree with @deads2k: here obj is non-nil.