diff --git a/examples/virtual-machine.yaml b/examples/virtual-machine.yaml index 0a05d43..13e9c38 100644 --- a/examples/virtual-machine.yaml +++ b/examples/virtual-machine.yaml @@ -8,7 +8,7 @@ external: false externalMethod: PortList externalPorts: -- 22 + - 22 ## @param running {bool} if the virtual machine should be running running: true diff --git a/test/basic-types/Makefile b/test/basic-types/Makefile new file mode 100644 index 0000000..32e9003 --- /dev/null +++ b/test/basic-types/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/test/basic-types/README.md b/test/basic-types/README.md new file mode 100644 index 0000000..b0962f7 --- /dev/null +++ b/test/basic-types/README.md @@ -0,0 +1,45 @@ +## Case Description + +Test cases for basic types: + +- `int` +- `bool` +- `string` + +All types are checked in required and nullable variations. + +## Parameters +### Integer parameters + +| Name | Description | Type | Value | +| ------------------------ | --------------------------------------------- | ------ | ------ | +| `testInt` | Integer variable | `int` | `0` | +| `testIntDefault` | Integer variable with default value | `int` | `10` | +| `testIntNullable` | Integer variable, nullable | `*int` | `null` | +| `testIntDefaultNullable` | Integer variable with default value, nullable | `*int` | `10` | + + +### Boolean parameters + +| Name | Description | Type | Value | +| ----------------------- | --------------------------------------------- | ------- | ------- | +| `testBool` | Boolean variable | `bool` | `false` | +| `testBoolFalse` | Boolean variable, defaults to false | `bool` | `false` | +| `testBoolTrue` | Boolean variable, defaults to true | `bool` | `true` | +| `testBoolNullable` | Boolean variable, nullable | `*bool` | `null` | +| `testBoolFalseNullable` | Boolean variable, defaults to false, nullable | `*bool` | `false` | +| `testBoolTrueNullable` | Boolean variable, defaults to true, nullable | `*bool` | `true` | + + +### String parameters + +| Name | Description | Type | Value | +| --------------------------- | -------------------------------------------- | --------- | -------------- | +| `testString` | String variable | `string` | `""` | +| `testStringEmpty` | String variable, empty by default | `string` | `""` | +| `testStringDefault` | String variable with default value | `string` | `string value` | +| `testStringNullable` | String variable, nullable | `*string` | `null` | +| `testStringEmptyNullable` | String variable, empty by default, nullable | `*string` | `""` | +| `testStringDefaultNullable` | String variable with default value, nullable | `*string` | `string value` | + + diff --git a/test/basic-types/values.schema.json b/test/basic-types/values.schema.json new file mode 100644 index 0000000..0d61da0 --- /dev/null +++ b/test/basic-types/values.schema.json @@ -0,0 +1,78 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "testBool": { + "description": "Boolean variable", + "type": "boolean" + }, + "testBoolFalse": { + "description": "Boolean variable, defaults to false", + "type": "boolean", + "default": false + }, + "testBoolFalseNullable": { + "description": "Boolean variable, defaults to false, nullable", + "type": "boolean", + "default": false + }, + "testBoolNullable": { + "description": "Boolean variable, nullable", + "type": "boolean" + }, + "testBoolTrue": { + "description": "Boolean variable, defaults to true", + "type": "boolean", + "default": true + }, + "testBoolTrueNullable": { + "description": "Boolean variable, defaults to true, nullable", + "type": "boolean", + "default": true + }, + "testInt": { + "description": "Integer variable", + "type": "integer" + }, + "testIntDefault": { + "description": "Integer variable with default value", + "type": "integer", + "default": 10 + }, + "testIntDefaultNullable": { + "description": "Integer variable with default value, nullable", + "type": "integer", + "default": 10 + }, + "testIntNullable": { + "description": "Integer variable, nullable", + "type": "integer" + }, + "testString": { + "description": "String variable", + "type": "string" + }, + "testStringDefault": { + "description": "String variable with default value", + "type": "string", + "default": "string value" + }, + "testStringDefaultNullable": { + "description": "String variable with default value, nullable", + "type": "string", + "default": "string value" + }, + "testStringEmpty": { + "description": "String variable, empty by default", + "type": "string" + }, + "testStringEmptyNullable": { + "description": "String variable, empty by default, nullable", + "type": "string" + }, + "testStringNullable": { + "description": "String variable, nullable", + "type": "string" + } + } +} \ No newline at end of file diff --git a/test/basic-types/values.yaml b/test/basic-types/values.yaml new file mode 100644 index 0000000..9bc5906 --- /dev/null +++ b/test/basic-types/values.yaml @@ -0,0 +1,40 @@ +## @section Integer parameters + +## @param testInt {int} Integer variable +testInt: +## @param testIntDefault {int} Integer variable with default value +testIntDefault: 10 +## @param testIntNullable {*int} Integer variable, nullable +testIntNullable: +## @param testIntDefaultNullable {*int} Integer variable with default value, nullable +testIntDefaultNullable: 10 + +## @section Boolean parameters + +## @param testBool {bool} Boolean variable +testBool: +## @param testBoolFalse {bool} Boolean variable, defaults to false +testBoolFalse: false +## @param testBoolTrue {bool} Boolean variable, defaults to true +testBoolTrue: true +## @param testBoolNullable {*bool} Boolean variable, nullable +testBoolNullable: +## @param testBoolFalseNullable {*bool} Boolean variable, defaults to false, nullable +testBoolFalseNullable: false +## @param testBoolTrueNullable {*bool} Boolean variable, defaults to true, nullable +testBoolTrueNullable: true + +## @section String parameters + +## @param testString {string} String variable +testString: +## @param testStringEmpty {string} String variable, empty by default +testStringEmpty: "" +## @param testStringDefault {string} String variable with default value +testStringDefault: "string value" +## @param testStringNullable {*string} String variable, nullable +testStringNullable: +## @param testStringEmptyNullable {*string} String variable, empty by default, nullable +testStringEmptyNullable: "" +## @param testStringDefaultNullable {*string} String variable with default value, nullable +testStringDefaultNullable: "string value" diff --git a/test/complex-types/Makefile b/test/complex-types/Makefile new file mode 100644 index 0000000..32e9003 --- /dev/null +++ b/test/complex-types/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/test/complex-types/README.md b/test/complex-types/README.md new file mode 100644 index 0000000..564f84c --- /dev/null +++ b/test/complex-types/README.md @@ -0,0 +1,41 @@ +## Case Description + +Tests for complex types, extending base ones. + +- `quantity` — measure of CPU cores and memory. + +## Parameters +### Quantity parameters + +| Name | Description | Type | Value | +| ------------------------- | --------------------------------------------------------------- | -------- | -------- | +| `quantityRequired` | A required quantity value (CPU cores or RAM). | `string` | `""` | +| `quantityRequiredEmpty` | A required quantity value with empty string (CPU cores or RAM). | `string` | `""` | +| `quantityDefaultInt` | A quantity default with a bare integer. | `string` | `2` | +| `quantityDefaultStrInt` | A quantity default with a quoted integer. | `string` | `2` | +| `quantityDefaultCpuShare` | A quantity default with vCPU share. | `string` | `100m` | +| `quantityDefaultRam` | A quantity default with RAM size. | `string` | `500MiB` | + + +### Nullable quantity parameters + +| Name | Description | Type | Value | +| --------------------------------- | --------------------------------------------------------------- | --------- | -------- | +| `quantityNullable` | A nullable quantity value. | `*string` | `null` | +| `quantityNullableRequiredEmpty` | A nullable quantity value with empty string (CPU cores or RAM). | `*string` | `""` | +| `quantityNullableDefaultInt` | A nullable quantity with a default bare integer. | `*string` | `2` | +| `quantityNullableDefaultStrInt` | A nullable quantity with a default quoted integer. | `*string` | `2` | +| `quantityNullableDefaultCpuShare` | A nullable quantity with a default CPU share. | `*string` | `100m` | +| `quantityNullableDefaultRam` | A nullable quantity with a default RAM size. | `*string` | `500MiB` | + + +### Enumerated parameters + +| Name | Description | Type | Value | +| ---------------------------------- | ------------------------------------ | -------- | ------- | +| `enumWithDefault` | Enum variable, defaults to "micro" | `string` | `{}` | +| `enumWithoutDefault` | Enum variable with no default value. | `string` | `{}` | +| `nested` | Element with nested enum fields | `object` | `{}` | +| `nested.enumWithCustomTypeDefault` | Enum variable, defaults to "micro" | `string` | `micro` | + + diff --git a/test/complex-types/values.schema.json b/test/complex-types/values.schema.json new file mode 100644 index 0000000..c34349a --- /dev/null +++ b/test/complex-types/values.schema.json @@ -0,0 +1,120 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "enumWithDefault": { + "description": "Enum variable, defaults to \"micro\"", + "type": "string", + "default": "micro", + "enum": [ + "nano", + "micro", + "small", + "medium", + "large", + "xlarge", + "2xlarge" + ] + }, + "enumWithoutDefault": { + "description": "Enum variable with no default value.", + "type": "string", + "enum": [ + "nano", + "micro", + "small", + "medium", + "large", + "xlarge", + "2xlarge" + ] + }, + "nested": { + "description": "Element with nested enum fields", + "type": "object", + "default": { + "enumWithCustomTypeDefault": "micro" + } + }, + "quantityDefaultCpuShare": { + "description": "A quantity default with vCPU share.", + "type": "string", + "default": "100m", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityDefaultInt": { + "description": "A quantity default with a bare integer.", + "type": "string", + "default": "2", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityDefaultRam": { + "description": "A quantity default with RAM size.", + "type": "string", + "default": "500MiB", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityDefaultStrInt": { + "description": "A quantity default with a quoted integer.", + "type": "string", + "default": "2", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullable": { + "description": "A nullable quantity value.", + "type": "string", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullableDefaultCpuShare": { + "description": "A nullable quantity with a default CPU share.", + "type": "string", + "default": "100m", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullableDefaultInt": { + "description": "A nullable quantity with a default bare integer.", + "type": "string", + "default": "2", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullableDefaultRam": { + "description": "A nullable quantity with a default RAM size.", + "type": "string", + "default": "500MiB", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullableDefaultStrInt": { + "description": "A nullable quantity with a default quoted integer.", + "type": "string", + "default": "2", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityNullableRequiredEmpty": { + "description": "A nullable quantity value with empty string (CPU cores or RAM).", + "type": "string", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityRequired": { + "description": "A required quantity value (CPU cores or RAM).", + "type": "string", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + }, + "quantityRequiredEmpty": { + "description": "A required quantity value with empty string (CPU cores or RAM).", + "type": "string", + "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + "x-kubernetes-int-or-string": true + } + } +} \ No newline at end of file diff --git a/test/complex-types/values.yaml b/test/complex-types/values.yaml new file mode 100644 index 0000000..e3ab911 --- /dev/null +++ b/test/complex-types/values.yaml @@ -0,0 +1,58 @@ +## @section Quantity parameters + +## @param quantityRequired {quantity} A required quantity value (CPU cores or RAM). +quantityRequired: + +## @param quantityRequiredEmpty {quantity} A required quantity value with empty string (CPU cores or RAM). +quantityRequiredEmpty: "" + +## @param quantityDefaultInt {quantity} A quantity default with a bare integer. +quantityDefaultInt: 2 + +## @param quantityDefaultStrInt {quantity} A quantity default with a quoted integer. +quantityDefaultStrInt: "2" + +## @param quantityDefaultCpuShare {quantity} A quantity default with vCPU share. +quantityDefaultCpuShare: "100m" + +## @param quantityDefaultRam {quantity} A quantity default with RAM size. +quantityDefaultRam: "500MiB" + + +## @section Nullable quantity parameters + +## @param quantityNullable {*quantity} A nullable quantity value. +quantityNullable: + +## @param quantityNullableRequiredEmpty {*quantity} A nullable quantity value with empty string (CPU cores or RAM). +quantityNullableRequiredEmpty: "" + +## @param quantityNullableDefaultInt {*quantity} A nullable quantity with a default bare integer. +quantityNullableDefaultInt: 2 + +## @param quantityNullableDefaultStrInt {*quantity} A nullable quantity with a default quoted integer. +quantityNullableDefaultStrInt: "2" + +## @param quantityNullableDefaultCpuShare {*quantity} A nullable quantity with a default CPU share. +quantityNullableDefaultCpuShare: "100m" + +## @param quantityNullableDefaultRam {*quantity} A nullable quantity with a default RAM size. +quantityNullableDefaultRam: "500MiB" + + +## @section Enumerated parameters + +## @param enumWithDefault {string enum:"nano,micro,small,medium,large,xlarge,2xlarge"} Enum variable, defaults to "micro" +enumWithDefault: "micro" + +## @param enumWithoutDefault {string enum:"nano,micro,small,medium,large,xlarge,2xlarge"} Enum variable with no default value. +enumWithoutDefault: + + +## @param nested {nested} Element with nested enum fields +nested: + ## @param nested.enumWithDefault {string enum:"nano,micro,small,medium,large,xlarge,2xlarge"} Enum variable, defaults to "micro" + enumWithDefault: "micro" + + ## @param nested.enumWithoutDefault {string enum:"nano,micro,small,medium,large,xlarge,2xlarge"} Enum variable with no default value. + enumWithoutDefault: diff --git a/test/lists/Makefile b/test/lists/Makefile new file mode 100644 index 0000000..32e9003 --- /dev/null +++ b/test/lists/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/test/lists/README.md b/test/lists/README.md new file mode 100644 index 0000000..2ffe3c8 --- /dev/null +++ b/test/lists/README.md @@ -0,0 +1,53 @@ +## Case Description + +Cases for lists of `int`, `string`, and `object`. + +## Parameters +### Integer lists + +| Name | Description | Type | Value | +| ------------------------- | ------------------------------------------------- | -------- | ------------ | +| `intList` | A required list of integers, empty. | `[]int` | `[]` | +| `intListSingle` | A list of integers with one value. | `[]int` | `[80]` | +| `intListMultiple` | A list of integers with multiple values. | `[]int` | `[80, 8080]` | +| `intListNullable` | A nullable list of integers, empty. | `[]*int` | `[]` | +| `intListNullableSingle` | A nullable list of integers with one value. | `[]*int` | `[80]` | +| `intListNullableMultiple` | A nullable list of integers with multiple values. | `[]*int` | `[80, 8080]` | + + +### String lists + +| Name | Description | Type | Value | +| ----------------------------- | ------------------------------------------------ | ----------- | ---------------- | +| `stringList` | A required list of strings, empty. | `[]string` | `[]` | +| `stringListSingle` | A required list of strings with one value. | `[]string` | `[user1]` | +| `stringListMultiple` | A required list of strings with multiple values. | `[]string` | `[user1, user2]` | +| `stringListNullable` | A nullable list of strings, empty. | `*[]string` | `null` | +| `stringListNullableSingle` | A nullable list of strings with one value. | `*[]string` | `[user1]` | +| `stringListNullableMultiple` | A nullable list of strings with multiple values. | `*[]string` | `[user1, user2]` | +| `stringListNullable2` | A nullable list of strings, empty. | `[]*string` | `[]` | +| `stringListNullableSingle2` | A nullable list of strings with one value. | `[]*string` | `[user1]` | +| `stringListNullableMultiple2` | A nullable list of strings with multiple values. | `[]*string` | `[user1, user2]` | + + +### Object lists + +| Name | Description | Type | Value | +| ------------------------ | -------------------------------------------- | ---------------- | -------------------------------------------------- | +| `objectList` | List of nested objects | `[]nestedObject` | `[]` | +| `objectList[0].name` | String field | `string` | `example` | +| `objectList[0].foo` | Object field with custom declared type | `object` | `{}` | +| `objectList[0].foo.fizz` | Nested int field | `int` | `10` | +| `objectList[0].foo.buzz` | Nested quantity field, nullable | `*string` | `1GiB` | +| `objectList[0].bar` | Another object field of custom declared type | `object` | `{}` | +| `objectList[0].bar.fizz` | Nested int field | `int` | `20` | +| `objectList[0].bar.buzz` | Nested quantity field, nullable | `*string` | `2GiB` | +| `objectList[1].name` | String field | `string` | `example 2 - not expected to appear in the README` | +| `objectList[1].foo` | Object field with custom declared type | `object` | `{}` | +| `objectList[1].foo.fizz` | Nested int field | `int` | `10` | +| `objectList[1].foo.buzz` | Nested quantity field, nullable | `*string` | `1GiB` | +| `objectList[1].bar` | Another object field of custom declared type | `object` | `{}` | +| `objectList[1].bar.fizz` | Nested int field | `int` | `20` | +| `objectList[1].bar.buzz` | Nested quantity field, nullable | `*string` | `2GiB` | + + diff --git a/test/lists/values.schema.json b/test/lists/values.schema.json new file mode 100644 index 0000000..37016e2 --- /dev/null +++ b/test/lists/values.schema.json @@ -0,0 +1,175 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "intList": { + "description": "A required list of integers, empty.", + "type": "array", + "items": { + "type": "integer" + } + }, + "intListMultiple": { + "description": "A list of integers with multiple values.", + "type": "array", + "default": [ + 80, + 8080 + ], + "items": { + "type": "integer" + } + }, + "intListNullable": { + "description": "A nullable list of integers, empty.", + "type": "array", + "items": { + "type": "integer" + } + }, + "intListNullableMultiple": { + "description": "A nullable list of integers with multiple values.", + "type": "array", + "default": [ + 80, + 8080 + ], + "items": { + "type": "integer" + } + }, + "intListNullableSingle": { + "description": "A nullable list of integers with one value.", + "type": "array", + "default": [ + 80 + ], + "items": { + "type": "integer" + } + }, + "intListSingle": { + "description": "A list of integers with one value.", + "type": "array", + "default": [ + 80 + ], + "items": { + "type": "integer" + } + }, + "objectList": { + "description": "List of nested objects", + "type": "array", + "default": [ + { + "bar": { + "buzz": "2GiB", + "fizz": 20 + }, + "foo": { + "buzz": "1GiB", + "fizz": 10 + }, + "name": "example" + }, + { + "bar": { + "buzz": "2GiB", + "fizz": 20 + }, + "foo": { + "buzz": "1GiB", + "fizz": 10 + }, + "name": "example 2 - not expected to appear in the README" + } + ], + "items": {} + }, + "stringList": { + "description": "A required list of strings, empty.", + "type": "array", + "items": { + "type": "string" + } + }, + "stringListMultiple": { + "description": "A required list of strings with multiple values.", + "type": "array", + "default": [ + "user1", + "user2" + ], + "items": { + "type": "string" + } + }, + "stringListNullable": { + "description": "A nullable list of strings, empty.", + "type": "array", + "items": { + "type": "string" + } + }, + "stringListNullable2": { + "description": "A nullable list of strings, empty.", + "type": "array", + "items": { + "type": "string" + } + }, + "stringListNullableMultiple": { + "description": "A nullable list of strings with multiple values.", + "type": "array", + "default": [ + "user1", + "user2" + ], + "items": { + "type": "string" + } + }, + "stringListNullableMultiple2": { + "description": "A nullable list of strings with multiple values.", + "type": "array", + "default": [ + "user1", + "user2" + ], + "items": { + "type": "string" + } + }, + "stringListNullableSingle": { + "description": "A nullable list of strings with one value.", + "type": "array", + "default": [ + "user1" + ], + "items": { + "type": "string" + } + }, + "stringListNullableSingle2": { + "description": "A nullable list of strings with one value.", + "type": "array", + "default": [ + "user1" + ], + "items": { + "type": "string" + } + }, + "stringListSingle": { + "description": "A required list of strings with one value.", + "type": "array", + "default": [ + "user1" + ], + "items": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/test/lists/values.yaml b/test/lists/values.yaml new file mode 100644 index 0000000..d98c551 --- /dev/null +++ b/test/lists/values.yaml @@ -0,0 +1,91 @@ +## @section Integer lists + +## @param intList {[]int} A required list of integers, empty. +intList: + +## @param intListSingle {[]int} A list of integers with one value. +intListSingle: + - 80 + +## @param intListMultiple {[]int} A list of integers with multiple values. +intListMultiple: + - 80 + - 8080 + +## @param intListNullable {[]*int} A nullable list of integers, empty. +intListNullable: + +## @param intListNullableSingle {[]*int} A nullable list of integers with one value. +intListNullableSingle: + - 80 + +## @param intListNullableMultiple {[]*int} A nullable list of integers with multiple values. +intListNullableMultiple: + - 80 + - 8080 + +## @section String lists + +## @param stringList {[]string} A required list of strings, empty. +stringList: + +## @param stringListSingle {[]string} A required list of strings with one value. +stringListSingle: + - "user1" + +## @param stringListMultiple {[]string} A required list of strings with multiple values. +stringListMultiple: + - "user1" + - "user2" + +## @param stringListNullable {*[]string} A nullable list of strings, empty. +stringListNullable: + +## @param stringListNullableSingle {*[]string} A nullable list of strings with one value. +stringListNullableSingle: + - "user1" + +## @param stringListNullableMultiple {*[]string} A nullable list of strings with multiple values. +stringListNullableMultiple: + - "user1" + - "user2" + +## @param stringListNullable2 {[]*string} A nullable list of strings, empty. +stringListNullable2: + +## @param stringListNullableSingle2 {[]*string} A nullable list of strings with one value. +stringListNullableSingle2: + - "user1" + +## @param stringListNullableMultiple2 {[]*string} A nullable list of strings with multiple values. +stringListNullableMultiple2: + - "user1" + - "user2" + + +## @section Object lists +## +## For example, see metricsStorages in extra/monitoring +## @param objectList {[]nestedObject} List of nested objects +## @field nestedObject Nested object +## @field nestedObject.name {string} String field +## @field nestedObject.foo {fooType} Object field with custom declared type +## @field fooType.fizz {int} Nested int field +## @field fooType.buzz {*quantity} Nested quantity field, nullable +## @field nestedObject.bar {fooType} Another object field of custom declared type + +objectList: + - name: "example" + foo: + fizz: 10 + buzz: 1GiB + bar: + fizz: 20 + buzz: 2GiB + - name: "example 2 - not expected to appear in the README" + foo: + fizz: 10 + buzz: 1GiB + bar: + fizz: 20 + buzz: 2GiB \ No newline at end of file diff --git a/test/objects/Makefile b/test/objects/Makefile new file mode 100644 index 0000000..32e9003 --- /dev/null +++ b/test/objects/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/test/objects/README.md b/test/objects/README.md new file mode 100644 index 0000000..30f6ac2 --- /dev/null +++ b/test/objects/README.md @@ -0,0 +1,22 @@ +## Case Description + +Test case for complex object with `field`s declared inside them. + +## Parameters +### Declaration through custom type + +| Name | Description | Type | Value | +| ----- | --------------------- | -------- | ----- | +| `foo` | Configuration for foo | `object` | `{}` | + + +### Declaration with direct path + +| Name | Description | Type | Value | +| --------------- | --------------------------------------- | -------- | ----- | +| `bar` | Configuration for bar | `object` | `{}` | +| `bar.db` | Field with custom type declared locally | `object` | `{}` | +| `bar.db.size` | Sub-field declared with absolute path | `string` | `""` | +| `bar.db.volume` | Sub-field declared with absolute path | `string` | `""` | + + diff --git a/test/objects/values.schema.json b/test/objects/values.schema.json new file mode 100644 index 0000000..e74721b --- /dev/null +++ b/test/objects/values.schema.json @@ -0,0 +1,84 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "bar": { + "description": "Configuration for bar", + "type": "object", + "default": { + "db": { + "size": "10Gi", + "volume": "10Gi" + } + }, + "required": [ + "db" + ], + "properties": { + "db": { + "description": "Field with custom type declared locally", + "type": "object", + "default": { + "size": "10Gi", + "volume": "10Gi" + }, + "required": [ + "size", + "volume" + ], + "properties": { + "size": { + "description": "Sub-field declared with path relative to custom type", + "type": "string", + "default": "10Gi" + }, + "volume": { + "description": "Sub-field declared with path relative to custom type", + "type": "string", + "default": "10Gi" + } + } + } + } + }, + "foo": { + "description": "Configuration for foo", + "type": "object", + "default": { + "db": { + "size": "10Gi", + "volume": "10Gi" + } + }, + "required": [ + "db" + ], + "properties": { + "db": { + "description": "Field with custom type declared locally", + "type": "object", + "default": { + "size": "10Gi", + "volume": "10Gi" + }, + "required": [ + "size", + "volume" + ], + "properties": { + "size": { + "description": "Sub-field declared with path relative to custom type", + "type": "string", + "default": "10Gi" + }, + "volume": { + "description": "Sub-field declared with path relative to custom type", + "type": "string", + "default": "10Gi" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/objects/values.yaml b/test/objects/values.yaml new file mode 100644 index 0000000..7dac4f4 --- /dev/null +++ b/test/objects/values.yaml @@ -0,0 +1,23 @@ +## @section Declaration through custom type + +## @param foo {foo} Configuration for foo +## @field foo.db {fooDB} Field with custom type declared locally +## @field fooDB.size {string} Sub-field declared with path relative to custom type +## @field fooDB.volume {string} Sub-field declared with path relative to custom type + +foo: + db: + size: 10Gi + volume: 10Gi + +## @section Declaration with direct path + +## @param bar {bar} Configuration for bar +## @field bar.db {fooDB} Field with custom type declared locally +## @field bar.db.size {string} Sub-field declared with absolute path +## @field bar.db.volume {string} Sub-field declared with absolute path +bar: + db: + size: 10Gi + volume: 10Gi + diff --git a/test/template/Makefile b/test/template/Makefile new file mode 100644 index 0000000..32e9003 --- /dev/null +++ b/test/template/Makefile @@ -0,0 +1 @@ +include ../test.mk diff --git a/test/template/README.md b/test/template/README.md new file mode 100644 index 0000000..ebbcbd7 --- /dev/null +++ b/test/template/README.md @@ -0,0 +1,11 @@ +## Case Description + + +## Parameters +### Test configuration + +| Name | Description | Type | Value | +| ------ | ------------- | -------- | ----- | +| `test` | Test variable | `object` | `{}` | + + diff --git a/test/template/values.schema.json b/test/template/values.schema.json new file mode 100644 index 0000000..6931ef1 --- /dev/null +++ b/test/template/values.schema.json @@ -0,0 +1,10 @@ +{ + "title": "Chart Values", + "type": "object", + "properties": { + "test": { + "description": "Test variable", + "type": "object" + } + } +} \ No newline at end of file diff --git a/test/template/values.yaml b/test/template/values.yaml new file mode 100644 index 0000000..cf2c326 --- /dev/null +++ b/test/template/values.yaml @@ -0,0 +1,4 @@ +## @section Test configuration + +## @param test {test} Test variable +test: \ No newline at end of file diff --git a/test/test.mk b/test/test.mk new file mode 100644 index 0000000..74fae43 --- /dev/null +++ b/test/test.mk @@ -0,0 +1,9 @@ +GENERATOR ?= cozyvalues-gen + +generate: + $(GENERATOR) -v values.yaml -s values.schema.json -r README.md + +test: generate + # check git diff, if empty, exit 0 + # if not empty, print outputs and exit 1 + @git diff --quiet || { git --no-pager diff; exit 1; } \ No newline at end of file