lang: Unnested the core package from the functions dir
The core package could contain non-functions, so we might as well move it upwards.
This commit is contained in:
8
Makefile
8
Makefile
@@ -185,8 +185,8 @@ clean: ## clean things up
|
|||||||
$(MAKE) --quiet -C test clean
|
$(MAKE) --quiet -C test clean
|
||||||
$(MAKE) --quiet -C lang clean
|
$(MAKE) --quiet -C lang clean
|
||||||
$(MAKE) --quiet -C misc/mkosi clean
|
$(MAKE) --quiet -C misc/mkosi clean
|
||||||
rm -f lang/funcs/core/generated_funcs.go || true
|
rm -f lang/core/generated_funcs.go || true
|
||||||
rm -f lang/funcs/core/generated_funcs_test.go || true
|
rm -f lang/core/generated_funcs_test.go || true
|
||||||
[ ! -e $(PROGRAM) ] || rm $(PROGRAM)
|
[ ! -e $(PROGRAM) ] || rm $(PROGRAM)
|
||||||
rm -f *_stringer.go # generated by `go generate`
|
rm -f *_stringer.go # generated by `go generate`
|
||||||
rm -f *_mock.go # generated by `go generate`
|
rm -f *_mock.go # generated by `go generate`
|
||||||
@@ -505,9 +505,9 @@ help: ## show this help screen
|
|||||||
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||||
@echo ''
|
@echo ''
|
||||||
|
|
||||||
funcgen: lang/funcs/core/generated_funcs.go
|
funcgen: lang/core/generated_funcs.go
|
||||||
|
|
||||||
lang/funcs/core/generated_funcs.go: lang/funcs/funcgen/*.go lang/funcs/core/funcgen.yaml lang/funcs/funcgen/templates/generated_funcs.go.tpl
|
lang/core/generated_funcs.go: lang/funcs/funcgen/*.go lang/core/funcgen.yaml lang/funcs/funcgen/templates/generated_funcs.go.tpl
|
||||||
@echo "Generating: funcs..."
|
@echo "Generating: funcs..."
|
||||||
@go run `find lang/funcs/funcgen/ -maxdepth 1 -type f -name '*.go' -not -name '*_test.go'` -templates=lang/funcs/funcgen/templates/generated_funcs.go.tpl >/dev/null
|
@go run `find lang/funcs/funcgen/ -maxdepth 1 -type f -name '*.go' -not -name '*_test.go'` -templates=lang/funcs/funcgen/templates/generated_funcs.go.tpl >/dev/null
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ from looking at example code.
|
|||||||
To implement a function, you'll need to create a file that imports the
|
To implement a function, you'll need to create a file that imports the
|
||||||
[`lang/funcs/simple/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/simple/)
|
[`lang/funcs/simple/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/simple/)
|
||||||
module. It should probably get created in the correct directory inside of:
|
module. It should probably get created in the correct directory inside of:
|
||||||
[`lang/funcs/core/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/core/).
|
[`lang/core/`](https://github.com/purpleidea/mgmt/tree/master/lang/core/). The
|
||||||
The function should be implemented as a `FuncValue` in our type system. It is
|
function should be implemented as a `FuncValue` in our type system. It is then
|
||||||
then registered with the engine during `init()`. An example explains it best:
|
registered with the engine during `init()`. An example explains it best:
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -115,11 +115,11 @@ re-evaluated as needed when their input values change.
|
|||||||
To implement a function, you'll need to create a file that imports the
|
To implement a function, you'll need to create a file that imports the
|
||||||
[`lang/funcs/simplepoly/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/simplepoly/)
|
[`lang/funcs/simplepoly/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/simplepoly/)
|
||||||
module. It should probably get created in the correct directory inside of:
|
module. It should probably get created in the correct directory inside of:
|
||||||
[`lang/funcs/core/`](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/core/).
|
[`lang/core/`](https://github.com/purpleidea/mgmt/tree/master/lang/core/). The
|
||||||
The function should be implemented as a list of `FuncValue`'s in our type
|
function should be implemented as a list of `FuncValue`'s in our type system. It
|
||||||
system. It is then registered with the engine during `init()`. You may also use
|
is then registered with the engine during `init()`. You may also use the
|
||||||
the `variant` type in your type definitions. This special type will never be
|
`variant` type in your type definitions. This special type will never be seen
|
||||||
seen inside a running program, and will get converted to a concrete type if a
|
inside a running program, and will get converted to a concrete type if a
|
||||||
suitable match to this signature can be found. Be warned that signatures which
|
suitable match to this signature can be found. Be warned that signatures which
|
||||||
contain too many variants, or which are very general, might be hard for the
|
contain too many variants, or which are very general, might be hard for the
|
||||||
compiler to match, and ambiguous type graphs make for user compiler errors. The
|
compiler to match, and ambiguous type graphs make for user compiler errors. The
|
||||||
|
|||||||
@@ -763,7 +763,7 @@ one value must be produced.
|
|||||||
|
|
||||||
```golang
|
```golang
|
||||||
Please see the example functions in
|
Please see the example functions in
|
||||||
[lang/funcs/core/](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/core/).
|
[lang/core/](https://github.com/purpleidea/mgmt/tree/master/lang/core/).
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stream
|
### Stream
|
||||||
@@ -785,7 +785,7 @@ context cancels.
|
|||||||
|
|
||||||
```golang
|
```golang
|
||||||
Please see the example functions in
|
Please see the example functions in
|
||||||
[lang/funcs/core/](https://github.com/purpleidea/mgmt/tree/master/lang/funcs/core/).
|
[lang/core/](https://github.com/purpleidea/mgmt/tree/master/lang/core/).
|
||||||
```
|
```
|
||||||
|
|
||||||
### Polymorphic Function API
|
### Polymorphic Function API
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import (
|
|||||||
|
|
||||||
"github.com/purpleidea/mgmt/engine"
|
"github.com/purpleidea/mgmt/engine"
|
||||||
engineUtil "github.com/purpleidea/mgmt/engine/util"
|
engineUtil "github.com/purpleidea/mgmt/engine/util"
|
||||||
|
"github.com/purpleidea/mgmt/lang/core"
|
||||||
"github.com/purpleidea/mgmt/lang/funcs"
|
"github.com/purpleidea/mgmt/lang/funcs"
|
||||||
"github.com/purpleidea/mgmt/lang/funcs/core"
|
|
||||||
"github.com/purpleidea/mgmt/lang/funcs/structs"
|
"github.com/purpleidea/mgmt/lang/funcs/structs"
|
||||||
"github.com/purpleidea/mgmt/lang/inputs"
|
"github.com/purpleidea/mgmt/lang/inputs"
|
||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
|
|||||||
@@ -22,22 +22,22 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
|
|
||||||
// import so the funcs register
|
// import so the funcs register
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/convert"
|
_ "github.com/purpleidea/mgmt/lang/core/convert"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/datetime"
|
_ "github.com/purpleidea/mgmt/lang/core/datetime"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/deploy"
|
_ "github.com/purpleidea/mgmt/lang/core/deploy"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/example"
|
_ "github.com/purpleidea/mgmt/lang/core/example"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/example/nested"
|
_ "github.com/purpleidea/mgmt/lang/core/example/nested"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/fmt"
|
_ "github.com/purpleidea/mgmt/lang/core/fmt"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/iter"
|
_ "github.com/purpleidea/mgmt/lang/core/iter"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/math"
|
_ "github.com/purpleidea/mgmt/lang/core/math"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/net"
|
_ "github.com/purpleidea/mgmt/lang/core/net"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/os"
|
_ "github.com/purpleidea/mgmt/lang/core/os"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/regexp"
|
_ "github.com/purpleidea/mgmt/lang/core/regexp"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/strings"
|
_ "github.com/purpleidea/mgmt/lang/core/strings"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/sys"
|
_ "github.com/purpleidea/mgmt/lang/core/sys"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/test"
|
_ "github.com/purpleidea/mgmt/lang/core/test"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/value"
|
_ "github.com/purpleidea/mgmt/lang/core/value"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core/world"
|
_ "github.com/purpleidea/mgmt/lang/core/world"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Instead of doing this one-level embed, we could give each package an
|
// TODO: Instead of doing this one-level embed, we could give each package an
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
package corenested
|
package corenested
|
||||||
|
|
||||||
import (
|
import (
|
||||||
coreexample "github.com/purpleidea/mgmt/lang/funcs/core/example"
|
coreexample "github.com/purpleidea/mgmt/lang/core/example"
|
||||||
"github.com/purpleidea/mgmt/lang/funcs/simple"
|
"github.com/purpleidea/mgmt/lang/funcs/simple"
|
||||||
"github.com/purpleidea/mgmt/lang/types"
|
"github.com/purpleidea/mgmt/lang/types"
|
||||||
)
|
)
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pkg = flag.String("package", "lang/funcs/core", "path to the package")
|
pkg = flag.String("package", "lang/core", "path to the package")
|
||||||
filename = flag.String("filename", "funcgen.yaml", "path to the config")
|
filename = flag.String("filename", "funcgen.yaml", "path to the config")
|
||||||
templates = flag.String("templates", "lang/funcs/funcgen/templates/*.tpl", "path to the templates")
|
templates = flag.String("templates", "lang/funcs/funcgen/templates/*.tpl", "path to the templates")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
"github.com/purpleidea/mgmt/engine"
|
"github.com/purpleidea/mgmt/engine"
|
||||||
"github.com/purpleidea/mgmt/engine/local"
|
"github.com/purpleidea/mgmt/engine/local"
|
||||||
"github.com/purpleidea/mgmt/lang/ast"
|
"github.com/purpleidea/mgmt/lang/ast"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core" // import so the funcs register
|
_ "github.com/purpleidea/mgmt/lang/core" // import so the funcs register
|
||||||
"github.com/purpleidea/mgmt/lang/funcs/dage"
|
"github.com/purpleidea/mgmt/lang/funcs/dage"
|
||||||
"github.com/purpleidea/mgmt/lang/funcs/vars"
|
"github.com/purpleidea/mgmt/lang/funcs/vars"
|
||||||
"github.com/purpleidea/mgmt/lang/inputs"
|
"github.com/purpleidea/mgmt/lang/inputs"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/purpleidea/mgmt/engine"
|
"github.com/purpleidea/mgmt/engine"
|
||||||
"github.com/purpleidea/mgmt/engine/resources"
|
"github.com/purpleidea/mgmt/engine/resources"
|
||||||
_ "github.com/purpleidea/mgmt/lang/funcs/core" // import so the funcs register
|
_ "github.com/purpleidea/mgmt/lang/core" // import so the funcs register
|
||||||
"github.com/purpleidea/mgmt/lang/inputs"
|
"github.com/purpleidea/mgmt/lang/inputs"
|
||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
"github.com/purpleidea/mgmt/pgraph"
|
"github.com/purpleidea/mgmt/pgraph"
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ function consistent-imports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reflowed-comments() {
|
function reflowed-comments() {
|
||||||
if [ "$1" = './lang/funcs/core/generated_funcs.go' ]; then
|
if [ "$1" = './lang/core/generated_funcs.go' ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user