engine, yamlgraph: Disable the old exported resources stuff

These were really just stubs so that I could prove out the reactive
model very early, and I don't think they're really used anywhere.

I'm also not really using the yamlgraph frontend. If someone wants any
of that code, step up, or it will rot even more.
This commit is contained in:
James Shubin
2025-03-24 19:17:26 -04:00
parent 3dfca97f86
commit 30aca74089
4 changed files with 30 additions and 42 deletions

View File

@@ -376,14 +376,6 @@ type CompatibleRes interface {
Merge(CompatibleRes) (CompatibleRes, error) Merge(CompatibleRes) (CompatibleRes, error)
} }
// CollectableRes is an interface for resources that support collection. It is
// currently temporary until a proper API for all resources is invented.
type CollectableRes interface {
Res
CollectPattern(string) // XXX: temporary until Res collection is more advanced
}
// YAMLRes is a resource that supports creation by unmarshalling. // YAMLRes is a resource that supports creation by unmarshalling.
type YAMLRes interface { type YAMLRes interface {
Res Res

View File

@@ -1501,12 +1501,6 @@ func (obj *FileRes) UIDs() []engine.ResUID {
// return fmt.Errorf("not possible at the moment") // return fmt.Errorf("not possible at the moment")
//} //}
// CollectPattern applies the pattern for collection resources.
func (obj *FileRes) CollectPattern(pattern string) {
// XXX: currently the pattern for files can only override the Dirname variable :P
obj.Dirname = pattern // XXX: simplistic for now
}
// UnmarshalYAML is the custom unmarshal handler for this struct. It is // UnmarshalYAML is the custom unmarshal handler for this struct. It is
// primarily useful for setting the defaults. // primarily useful for setting the defaults.
func (obj *FileRes) UnmarshalYAML(unmarshal func(interface{}) error) error { func (obj *FileRes) UnmarshalYAML(unmarshal func(interface{}) error) error {

View File

@@ -30,7 +30,6 @@
package yamlgraph package yamlgraph
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
@@ -170,8 +169,8 @@ func (obj *GAPI) Next() chan gapi.Next {
return return
} }
// FIXME: add timeout to context // FIXME: add timeout to context
ctx, cancel := context.WithCancel(context.Background()) //ctx, cancel := context.WithCancel(context.Background())
defer cancel() //defer cancel()
startChan := make(chan struct{}) // start signal startChan := make(chan struct{}) // start signal
close(startChan) // kick it off! close(startChan) // kick it off!
@@ -180,16 +179,17 @@ func (obj *GAPI) Next() chan gapi.Next {
if obj.data.NoStreamWatch { if obj.data.NoStreamWatch {
watchChan = nil watchChan = nil
} else { } else {
var err error // XXX: disabled for now until someone ports to new API.
watchChan, err = obj.data.World.ResWatch(ctx) //var err error
if err != nil { //watchChan, err = obj.data.World.ResWatch(ctx)
next := gapi.Next{ //if err != nil {
Err: errwrap.Wrapf(err, "%s: could not start watch", Name), // next := gapi.Next{
Exit: true, // exit, b/c programming error? // Err: errwrap.Wrapf(err, "%s: could not start watch", Name),
} // Exit: true, // exit, b/c programming error?
ch <- next // }
return // ch <- next
} // return
//}
} }
for { for {

View File

@@ -32,7 +32,6 @@
package yamlgraph package yamlgraph
import ( import (
"context"
"fmt" "fmt"
"strings" "strings"
@@ -239,12 +238,13 @@ func (obj *GraphConfig) NewGraphFromConfig(hostname string, world engine.World,
} }
// store in backend (usually etcd) // store in backend (usually etcd)
if err := world.ResExport(context.TODO(), resourceList); err != nil { // XXX: disabled for now until someone ports to new API.
return nil, fmt.Errorf("config: could not export resources: %v", err) //if err := world.ResExport(context.TODO(), resourceList); err != nil {
} // return nil, fmt.Errorf("config: could not export resources: %v", err)
//}
// lookup from backend (usually etcd) // lookup from backend (usually etcd)
var hostnameFilter []string // empty to get from everyone //var hostnameFilter []string // empty to get from everyone
kindFilter := []string{} kindFilter := []string{}
for _, t := range obj.Collector { for _, t := range obj.Collector {
kind := strings.ToLower(t.Kind) kind := strings.ToLower(t.Kind)
@@ -253,11 +253,12 @@ func (obj *GraphConfig) NewGraphFromConfig(hostname string, world engine.World,
// do all the graph look ups in one single step, so that if the backend // do all the graph look ups in one single step, so that if the backend
// database changes, we don't have a partial state of affairs... // database changes, we don't have a partial state of affairs...
if len(kindFilter) > 0 { // if kindFilter is empty, don't need to do lookups! if len(kindFilter) > 0 { // if kindFilter is empty, don't need to do lookups!
var err error // XXX: disabled for now until someone ports to new API.
resourceList, err = world.ResCollect(context.TODO(), hostnameFilter, kindFilter) //var err error
if err != nil { //resourceList, err = world.ResCollect(context.TODO(), hostnameFilter, kindFilter)
return nil, fmt.Errorf("config: could not collect resources: %v", err) //if err != nil {
} // return nil, fmt.Errorf("config: could not collect resources: %v", err)
//}
} }
for _, res := range resourceList { for _, res := range resourceList {
matched := false matched := false
@@ -283,11 +284,12 @@ func (obj *GraphConfig) NewGraphFromConfig(hostname string, world engine.World,
// res.MetaParams().Noop = noop // res.MetaParams().Noop = noop
//} //}
if t.Pattern != "" { // XXX: simplistic for now // XXX: disabled for now until someone ports to new API.
if xres, ok := res.(engine.CollectableRes); ok { //if t.Pattern != "" { // XXX: simplistic for now
xres.CollectPattern(t.Pattern) // res.Dirname = t.Pattern // if xres, ok := res.(engine.CollectableRes); ok {
} // xres.CollectPattern(t.Pattern) // res.Dirname = t.Pattern
} // }
//}
obj.Logf("collected: %s", res) obj.Logf("collected: %s", res)