-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add basic packages for release #2
Conversation
pkg/kube/client.go
Outdated
} | ||
originalInfos := make(map[string]int) | ||
for i, accessor := range originalAccessors { | ||
originalInfos[accessor.GetName()] = i |
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.
这些 resource 中不同类型的资源重名了,会导致信息丢失
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.
需要有一个 keyFunc,从 GroupVersionKind + Name 生成 key
pkg/kube/client.go
Outdated
for _, u := range updates { | ||
origin, err := yaml.YAMLToJSON([]byte(u.origin)) | ||
if err != nil { | ||
return 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.
return nil?
pkg/kube/client.go
Outdated
} | ||
target, err := yaml.YAMLToJSON([]byte(u.target)) | ||
if err != nil { | ||
return 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.
ditto
pkg/kube/client.go
Outdated
} | ||
obj, accessor, err := c.codec.AccessorForResource(u.origin) | ||
if err != nil { | ||
return 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.
ditto
pkg/kube/client.go
Outdated
// TODO(kdada): Replace with merge patch when obj is TPR or CRD. | ||
patch, err := strategicpatch.CreateTwoWayMergePatch(origin, target, obj) | ||
if err != nil { | ||
return 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.
ditto
} | ||
if !resource.Namespaced { | ||
namespace = "" | ||
} else if namespace == "" { |
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.
这样是不是就没办法拿到一个 client 可以查 AllNamespace 的资源了
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.
这个在这个函数注释里写明白了。可以允许使用 NamespaceAll,但是不能使用 Get 之类的方法。
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.
LGTM
pkg/kube/rest.go
Outdated
client, ok := cp.clients[gvk] | ||
if !ok { | ||
conf := *cp.config | ||
if gvk.Group == "" { |
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.
最好把 Group("") 给一个 const 值为 CoreGroup,易于理解
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.
v1 没有 Group, 和 CoreGroup 还是有区别的。k8s 也是这么判断的。
LGTM |
Usage: