Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop-cfs-templates' into develop. Close #157.
**Description** The cFS application generation backend has a fixed template that it uses to generate the cFS application. That template does not fit all use cases, so we are finding users heavily modifying the output (which is hard to keep up with when there are changes), and or not using ogma altogether for that reason. Allowing users to pick their own cFS template would make Ogma more versatile. **Type** - Feature: Enable customizing output produced. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** Ogma allows users to pick the custom cFS application template they want to use instead of relying on the one provided by default. The following dockerfile generates the cFS application using the default template and using a copy and the default template and checks that both are the same. It then adds a file to the copy of the template and checks that the file is copied to the target directory when the custom template is used, after which it prints the message "Success". ```Dockerfile FROM ubuntu:trusty ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install --yes software-properties-common RUN add-apt-repository ppa:hvr/ghc RUN apt-get update RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4 RUN apt-get install --yes libz-dev ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH RUN cabal update RUN cabal v1-sandbox init RUN cabal v1-install alex happy RUN apt-get install --yes git CMD git clone $REPO && \ cd $NAME && \ git checkout $COMMIT && \ cd .. && \ cabal v1-install $NAME/$PAT**/ --constraint="aeson>=2.0.3.0" && \ cp -r $NAME/ogma-core/templates/copilot-cfs custom-template-cfs && \ find custom-template-cfs -iname '.gitignore' -delete && \ ./.cabal-sandbox/bin/ogma cfs --variable-file $NAME/ogma-cli/examples/cfs-variables --variable-db $NAME/ogma-cli/examples/cfs-variable-db --app-target-dir original && \ ./.cabal-sandbox/bin/ogma cfs --variable-file $NAME/ogma-cli/examples/cfs-variables --variable-db $NAME/ogma-cli/examples/cfs-variable-db --app-target-dir new --app-template-dir custom-template-cfs && \ diff -rq original new && \ rm -rf new && \ echo "Success" >> custom-template-cfs/test && \ ./.cabal-sandbox/bin/ogma cfs --variable-file $NAME/ogma-cli/examples/cfs-variables --variable-db $NAME/ogma-cli/examples/cfs-variable-db --app-target-dir new --app-template-dir custom-template-cfs && \ cat new/test ``` Command (substitute variables based on new path after merge): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=<HASH>" -it ogma-verify-157 ``` **Solution implemented** Modify `ogma-core` to use variable expansion based on mustache to create the output files. Modify `ogma-core`'s template to use the variables used by the cFS application generation module. Modify `ogma-core` to give users the ability to pick a template directory via an optional input argument. Modify `ogma-cli` to give users the ability to pick a template directory via an optional input argument (exposing the corresponding argument from `ogma-core`). Modify `README` to demonstrate new capability. **Further notes** None.
- Loading branch information