Skip to content
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

Merged
merged 6 commits into from
Sep 12, 2017
Merged

Add basic packages for release #2

merged 6 commits into from
Sep 12, 2017

Conversation

kdada
Copy link
Contributor

@kdada kdada commented Sep 5, 2017

  • Add a rest kube client
    • Implement a rest client pool.
    • Implement a client for resources.
  • Add template render.
    • Implement a render for template and a json config.
  • Add release backend.
    • The backend is used to controll releases. It provides some methods to operate release.
  • Add informer store.
  • Add status umpire.

Usage:

  1. Use render to handle template and config. The render can generate a list of resources.
  2. The pass these resources to client. Client can create/update/delete these resources.

@kdada kdada requested a review from zoumo September 5, 2017 08:46
@kdada kdada changed the title Add basic packages for release [WIP] Add basic packages for release Sep 11, 2017
@kdada kdada changed the title [WIP] Add basic packages for release Add basic packages for release Sep 11, 2017
}
originalInfos := make(map[string]int)
for i, accessor := range originalAccessors {
originalInfos[accessor.GetName()] = i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些 resource 中不同类型的资源重名了,会导致信息丢失

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要有一个 keyFunc,从 GroupVersionKind + Name 生成 key

for _, u := range updates {
origin, err := yaml.YAMLToJSON([]byte(u.origin))
if err != nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nil?

}
target, err := yaml.YAMLToJSON([]byte(u.target))
if err != nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}
obj, accessor, err := c.codec.AccessorForResource(u.origin)
if err != nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// TODO(kdada): Replace with merge patch when obj is TPR or CRD.
patch, err := strategicpatch.CreateTwoWayMergePatch(origin, target, obj)
if err != nil {
return nil
Copy link
Contributor

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 == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样是不是就没办法拿到一个 client 可以查 AllNamespace 的资源了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个在这个函数注释里写明白了。可以允许使用 NamespaceAll,但是不能使用 Get 之类的方法。

Copy link
Contributor

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 == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好把 Group("") 给一个 const 值为 CoreGroup,易于理解

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 没有 Group, 和 CoreGroup 还是有区别的。k8s 也是这么判断的。

@caicloud caicloud deleted a comment from kdada Sep 12, 2017
@zoumo
Copy link
Contributor

zoumo commented Sep 12, 2017

LGTM

@zoumo zoumo merged commit f41af08 into caicloud:master Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants