resources: Make resource kind and baseuid fields public

This is required if we're going to have out of package resources. In
particular for third party packages, and also for if we decide to split
out each resource into a separate sub package.
This commit is contained in:
James Shubin
2017-04-11 01:30:05 -04:00
parent a4858be967
commit 9b9ff2622d
25 changed files with 207 additions and 207 deletions

View File

@@ -2147,10 +2147,10 @@ func SetResources(obj *EmbdEtcd, hostname string, resourceList []resources.Res)
ifs := []etcd.Cmp{} // list matching the desired state
ops := []etcd.Op{} // list of ops in this transaction
for _, res := range resourceList {
if res.Kind() == "" {
if res.GetKind() == "" {
log.Fatalf("Etcd: SetResources: Error: Empty kind: %v", res.GetName())
}
uid := fmt.Sprintf("%s/%s", res.Kind(), res.GetName())
uid := fmt.Sprintf("%s/%s", res.GetKind(), res.GetName())
path := fmt.Sprintf("/%s/exported/%s/resources/%s", NS, hostname, uid)
if data, err := resources.ResToB64(res); err == nil {
ifs = append(ifs, etcd.Compare(etcd.Value(path), "=", data)) // desired state
@@ -2162,7 +2162,7 @@ func SetResources(obj *EmbdEtcd, hostname string, resourceList []resources.Res)
match := func(res resources.Res, resourceList []resources.Res) bool { // helper lambda
for _, x := range resourceList {
if res.Kind() == x.Kind() && res.GetName() == x.GetName() {
if res.GetKind() == x.GetKind() && res.GetName() == x.GetName() {
return true
}
}
@@ -2172,10 +2172,10 @@ func SetResources(obj *EmbdEtcd, hostname string, resourceList []resources.Res)
hasDeletes := false
// delete old, now unused resources here...
for _, res := range originals {
if res.Kind() == "" {
if res.GetKind() == "" {
log.Fatalf("Etcd: SetResources: Error: Empty kind: %v", res.GetName())
}
uid := fmt.Sprintf("%s/%s", res.Kind(), res.GetName())
uid := fmt.Sprintf("%s/%s", res.GetKind(), res.GetName())
path := fmt.Sprintf("/%s/exported/%s/resources/%s", NS, hostname, uid)
if match(res, resourceList) { // if we match, no need to delete!