lang: Initial implementation of the mgmt language

This is an initial implementation of the mgmt language. It is a
declarative (immutable) functional, reactive, domain specific
programming language. It is intended to be a language that is:

* safe
* powerful
* easy to reason about

With these properties, we hope this language, and the mgmt engine will
allow you to model the real-time systems that you'd like to automate.

This also includes a number of other associated changes. Sorry for the
large size of this patch.
This commit is contained in:
James Shubin
2018-01-20 08:09:29 -05:00
parent 1c8c0b2915
commit b19583e7d3
237 changed files with 25256 additions and 743 deletions

View File

@@ -155,8 +155,7 @@ func TestMiscEncodeDecode2(t *testing.T) {
func TestStructTagToFieldName0(t *testing.T) {
type TestStruct struct {
// TODO: switch this to TestRes when it is in git master
NoopRes // so that this struct implements `Res`
TestRes // so that this struct implements `Res`
Alpha bool `lang:"alpha" yaml:"nope"`
Beta string `yaml:"beta"`
Gamma string
@@ -182,8 +181,7 @@ func TestStructTagToFieldName0(t *testing.T) {
func TestLowerStructFieldNameToFieldName0(t *testing.T) {
type TestStruct struct {
// TODO: switch this to TestRes when it is in git master
NoopRes // so that this struct implements `Res`
TestRes // so that this struct implements `Res`
Alpha bool
skipMe bool
Beta string
@@ -200,7 +198,7 @@ func TestLowerStructFieldNameToFieldName0(t *testing.T) {
}
expected := map[string]string{
"noopres": "NoopRes", // TODO: switch this to TestRes when it is in git master
"testres": "TestRes", // hide by specifying `lang:""` on it
"alpha": "Alpha",
//"skipme": "skipMe",
"beta": "Beta",
@@ -218,8 +216,7 @@ func TestLowerStructFieldNameToFieldName0(t *testing.T) {
func TestLowerStructFieldNameToFieldName1(t *testing.T) {
type TestStruct struct {
// TODO: switch this to TestRes when it is in git master
NoopRes // so that this struct implements `Res`
TestRes // so that this struct implements `Res`
Alpha bool
skipMe bool
Beta string
@@ -239,6 +236,68 @@ func TestLowerStructFieldNameToFieldName1(t *testing.T) {
}
}
func TestLowerStructFieldNameToFieldName2(t *testing.T) {
mapping, err := LowerStructFieldNameToFieldName(&TestRes{})
if err != nil {
t.Errorf("failed: %+v", err)
return
}
expected := map[string]string{
"baseres": "BaseRes",
"bool": "Bool",
"str": "Str",
"int": "Int",
"int8": "Int8",
"int16": "Int16",
"int32": "Int32",
"int64": "Int64",
"uint": "Uint",
"uint8": "Uint8",
"uint16": "Uint16",
"uint32": "Uint32",
"uint64": "Uint64",
"byte": "Byte",
"rune": "Rune",
"float32": "Float32",
"float64": "Float64",
"complex64": "Complex64",
"complex128": "Complex128",
"boolptr": "BoolPtr",
"stringptr": "StringPtr",
"int64ptr": "Int64Ptr",
"int8ptr": "Int8Ptr",
"uint8ptr": "Uint8Ptr",
"int8ptrptrptr": "Int8PtrPtrPtr",
"slicestring": "SliceString",
"mapintfloat": "MapIntFloat",
"mixedstruct": "MixedStruct",
"interface": "Interface",
"anotherstr": "AnotherStr",
"validatebool": "ValidateBool",
"validateerror": "ValidateError",
"alwaysgroup": "AlwaysGroup",
"comparefail": "CompareFail",
"comment": "Comment",
}
if !reflect.DeepEqual(mapping, expected) {
t.Errorf("expected: %+v", expected)
t.Errorf("received: %+v", mapping)
}
}
func TestUnknownGroup(t *testing.T) {
gid, err := GetGID("unknowngroup")
if err == nil {