modules: Add a modules directory for mcl code
Details in the README file.
This commit is contained in:
38
modules/README.md
Normal file
38
modules/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Modules!
|
||||||
|
|
||||||
|
This is a collection of `mcl` modules that may be of general interest.
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
|
||||||
|
In particular while the project is evolving very rapidly, it makes sense to keep
|
||||||
|
these alongside the compiler so that if anything needs refactoring, it happens
|
||||||
|
together in the same commit, and if there are improvements made and new features
|
||||||
|
added, you can see exactly what commit brought in this change!
|
||||||
|
|
||||||
|
## Acceptance criteria
|
||||||
|
|
||||||
|
It's sort of arbitrary at the moment, but I'm putting in what I find to be
|
||||||
|
generally helpful for my needs. Patches are welcome, but expect I might be a bit
|
||||||
|
discerning if it's not what I'm looking for right now.
|
||||||
|
|
||||||
|
## Long-term
|
||||||
|
|
||||||
|
I see `mgmt` and `mcl` as being able to replace a traditional software
|
||||||
|
management daemon, and front-end configuration interface for many projects. As a
|
||||||
|
result, it might end up being the de facto way to interact with certain
|
||||||
|
services. For example, the `dhcpd` project could decide to provide an mcl module
|
||||||
|
as either the primary or secondary interface for managing that service, and in
|
||||||
|
that case, it would make sense for that module to live in that source tree.
|
||||||
|
|
||||||
|
## Importing?
|
||||||
|
|
||||||
|
You can import any of these modules into your `mcl` project with the following
|
||||||
|
example for the `purpleidea` module:
|
||||||
|
|
||||||
|
```mcl
|
||||||
|
import "git://github.com/purpleidea/mgmt/modules/purpleidea/"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Bugs, questions, thanks?
|
||||||
|
|
||||||
|
Reach out and let us know!
|
||||||
78
modules/purpleidea/main.mcl
Normal file
78
modules/purpleidea/main.mcl
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Mgmt
|
||||||
|
# Copyright (C) 2013-2024+ James Shubin and the project contributors
|
||||||
|
# Written by James Shubin <james@shubin.ca> and the project contributors
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Additional permission under GNU GPL version 3 section 7
|
||||||
|
#
|
||||||
|
# If you modify this program, or any covered work, by linking or combining it
|
||||||
|
# with embedded mcl code and modules (and that the embedded mcl code and
|
||||||
|
# modules which link with this program, contain a copy of their source code in
|
||||||
|
# the authoritative form) containing parts covered by the terms of any other
|
||||||
|
# license, the licensors of this program grant you additional permission to
|
||||||
|
# convey the resulting work. Furthermore, the licensors of this program grant
|
||||||
|
# the original author, James Shubin, additional permission to update this
|
||||||
|
# additional permission if he deems it necessary to achieve the goals of this
|
||||||
|
# additional permission.
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
# base contains the personal tweaks and utilities of james (purpleidea)
|
||||||
|
class base() {
|
||||||
|
if os.is_redhat() {
|
||||||
|
pkg [
|
||||||
|
"ack",
|
||||||
|
"bash-completion",
|
||||||
|
"direnv",
|
||||||
|
"fping",
|
||||||
|
"git",
|
||||||
|
"htop",
|
||||||
|
"lshw",
|
||||||
|
"nethogs",
|
||||||
|
"nmap",
|
||||||
|
"screen",
|
||||||
|
"socat",
|
||||||
|
"strace",
|
||||||
|
"telnet",
|
||||||
|
"tree",
|
||||||
|
"vim-enhanced",
|
||||||
|
"wget2-wget",
|
||||||
|
] {
|
||||||
|
state => "installed",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if os.is_debian() {
|
||||||
|
pkg [
|
||||||
|
"ack",
|
||||||
|
"bash-completion",
|
||||||
|
"direnv",
|
||||||
|
"fping",
|
||||||
|
"git",
|
||||||
|
"htop",
|
||||||
|
"lshw",
|
||||||
|
"nethogs",
|
||||||
|
"nmap",
|
||||||
|
"screen",
|
||||||
|
"socat",
|
||||||
|
"strace",
|
||||||
|
"telnet",
|
||||||
|
"tree",
|
||||||
|
"vim",
|
||||||
|
"wget",
|
||||||
|
] {
|
||||||
|
state => "installed",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
0
modules/purpleidea/metadata.yaml
Normal file
0
modules/purpleidea/metadata.yaml
Normal file
33
test/test-modules.sh
Executable file
33
test/test-modules.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# check that our modules still build, even if we don't run them here
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
. test/util.sh
|
||||||
|
|
||||||
|
echo running "$0"
|
||||||
|
|
||||||
|
ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
|
cd "${ROOT}"
|
||||||
|
|
||||||
|
failures=''
|
||||||
|
|
||||||
|
# Test modules/ directory to see if the .mcl files compile correctly.
|
||||||
|
|
||||||
|
find_mcl_modules() {
|
||||||
|
git ls-files | grep '\.mcl$' | grep '^modules/' | grep -v 'examples/lang/'
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: It might be better to only test from the root module entrypoint.
|
||||||
|
for file in $(find_mcl_modules); do
|
||||||
|
#echo "mcl: $file"
|
||||||
|
run-test ./mgmt run --tmp-prefix lang --only-unify "$file" &> /dev/null || fail_test "could not compile: $file"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "$failures" ]]; then
|
||||||
|
echo 'FAIL'
|
||||||
|
echo "The following tests (in: ${linkto}) have failed:"
|
||||||
|
echo -e "$failures"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo 'PASS'
|
||||||
Reference in New Issue
Block a user