-
Notifications
You must be signed in to change notification settings - Fork 84
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
Adds function for parsing list #103
Adds function for parsing list #103
Conversation
Hi @somtochiama. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @justinsb |
@@ -403,3 +411,30 @@ func (r *Reconciler) IsKustomizeOptionUsed() bool { | |||
func (r *Reconciler) SetSink(sink Sink) { | |||
r.options.sink = sink | |||
} | |||
|
|||
func parseListKind(infos *manifest.Objects) error{ | |||
for i, item := range infos.Items{ |
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.
Nit: gofmt needed, I think
|
||
func parseListKind(infos *manifest.Objects) error{ | ||
for i, item := range infos.Items{ | ||
if item.Kind == "List" { |
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.
Nit: we should check the group also. The easy way is to check the APIGroup (which sadly includes the version, but I think that's OK)
func parseListKind(infos *manifest.Objects) error{ | ||
for i, item := range infos.Items{ | ||
if item.Kind == "List" { | ||
fmt.Println("haaa!") |
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.
Nit: please remove debug code :-)
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.
😅 Will do
fmt.Println("haaa!") | ||
obj := item.UnstructuredObject() | ||
|
||
err := obj.EachListItem(func(obj runtime.Object) error{ |
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.
Nice find on EachListItem
👍
obj := item.UnstructuredObject() | ||
|
||
err := obj.EachListItem(func(obj runtime.Object) error{ | ||
castItem := obj.(*unstructured.Unstructured) |
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.
Nit: renaming castItem to itemUnstructured
may be clearer (similarly, you might rename obj
to itemObject
). (I do like rust's ability to redefine variables with the same name but with a different type, avoids these problems)
return err | ||
} | ||
|
||
infos.Items = append(infos.Items[:i], infos.Items[i+1:]...) |
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.
I think leigh was suggesting that it might be easier to just keep a second list:
var out []*manifest.Object
if IsList(obj) {
out = append(out, extract(obj))
} else {
out = append(out, obj)
}
return manifest.NewManifest(out)
}
I'm not sure what happens to the iteration when you concurrently modify infos
!
Looks great - thanks @somtochiama /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb, SomtochiAma The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adds function for parsing list
No description provided.