Valor is a tool that can be used to validate and evaluate resource.
Clone this repository into the local by running the following command:
git clone github.com/gojek/optimus-extension-valor
Copy the recipe example valor.example.yaml
to valor.yaml
. The resource that will be validated and evaluated from the recipe is like the following:
resources:
- name: user_account
type: dir
path: ./example/resource
format: json
framework_names:
- user_account_evaluation
...
As stated in the recipe, the resource is available under directory ./example/resource
. One example of the resource is like the following:
{
"email": "[email protected]",
"membership_id": 1,
"is_active": true
}
Note that the membership_id
is in numeric.
To execute the pipeline, one can either:
- download the latest binary from here and put it in this project directory, or
- try building it by following this guide
After the preparation is done, try executing Valor from the CLI like the following:
./out/valor execute
And done. Based on the recipe, the output will be printed to the std out, or in other words in the CLI. The output should contain one of the modified input, like the following:
...
---------------------------
example/resource/valor.json
---------------------------
email: [email protected]
is_active: true
membership: premium
...
What Valor does is actually stated in the recipe file valor.yaml
. Behind the scene, the process is like the following:
- read the first resource
- execute framework pointed by field
framework_names
- in the framework, run validation based on
schemas
- if no error is found, load the required definition under
definitions
- if no error is found, execute procedures stated under
procedures
- if no error is found, write the result based on
output
The explanation here is quite brief. For further explanation, try checkout the documentation here.
The complete documentation is available like the following:
- recipe, which explains more about recipe and how to set it up for execution
- command, which explains more about the available commands to be run
Community contribution is very welcome. Though, because of diverse background, one might not be able to easily understand the reasoning behind every decision or approach. So, the following is the general guideline to contribute:
- create a dedicated branch
- after all changes are done, create a PR
- in that PR, please describes the issue or reasining or even approach for such changes
- if no issue is found, merge will be done shortly
In order to follow the above steps, one might need to setup the local environment. The following is the general information to set it up.
The GO programming language version go1.17.1
need to be installed
in the system. Go to this link and follow
the instruction to install. To check GO version on the environment, run the following command:
go version
example output:
go version go1.17.1 darwin/amd64
In this project root directory, run the following command to test:
make test
To show a more complete coverage and uncovered lines:
make coverage
You can check into coverage.html
file in root project directory.
This command also will open interactive coverage tool in the browser.
To build the binary executable, in this project root directory, run the following command:
make bin
There will be a new directory named out
with an executable file valor
as the result of the built project.
Alternatively, distribution could also be made by running the following command:
make dist
There will be a new directory named dist
with few executable files.
In order to run this project, after building the binary executable, run the following command in this project root directory:
./out/valor