engine: Resources package rewrite

This giant patch makes some much needed improvements to the code base.

* The engine has been rewritten and lives within engine/graph/
* All of the common interfaces and code now live in engine/
* All of the resources are in one package called engine/resources/
* The Res API can use different "traits" from engine/traits/
* The Res API has been simplified to hide many of the old internals
* The Watch & Process loops were previously inverted, but is now fixed
* The likelihood of package cycles has been reduced drastically
* And much, much more...

Unfortunately, some code had to be temporarily removed. The remote code
had to be taken out, as did the prometheus code. We hope to have these
back in new forms as soon as possible.
This commit is contained in:
James Shubin
2018-03-13 12:02:44 -04:00
parent ef49aa7e08
commit 9969286224
140 changed files with 9130 additions and 8764 deletions

View File

@@ -20,7 +20,7 @@ package gapi
import (
"io/ioutil"
"github.com/purpleidea/mgmt/resources"
"github.com/purpleidea/mgmt/engine"
"github.com/purpleidea/mgmt/util"
errwrap "github.com/pkg/errors"
@@ -31,7 +31,7 @@ import (
const Umask = 0666
// CopyFileToFs copies a file from src path on the local fs to a dst path on fs.
func CopyFileToFs(fs resources.Fs, src, dst string) error {
func CopyFileToFs(fs engine.Fs, src, dst string) error {
data, err := ioutil.ReadFile(src)
if err != nil {
return errwrap.Wrapf(err, "can't read from file `%s`", src)
@@ -44,7 +44,7 @@ func CopyFileToFs(fs resources.Fs, src, dst string) error {
// CopyStringToFs copies a file from src path on the local fs to a dst path on
// fs.
func CopyStringToFs(fs resources.Fs, str, dst string) error {
func CopyStringToFs(fs engine.Fs, str, dst string) error {
if err := fs.WriteFile(dst, []byte(str), Umask); err != nil {
return errwrap.Wrapf(err, "can't write to file `%s`", dst)
}
@@ -52,6 +52,6 @@ func CopyStringToFs(fs resources.Fs, str, dst string) error {
}
// CopyDirToFs copies a dir from src path on the local fs to a dst path on fs.
func CopyDirToFs(fs resources.Fs, src, dst string) error {
func CopyDirToFs(fs engine.Fs, src, dst string) error {
return util.CopyDiskToFs(fs, src, dst, false)
}