Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOM variable yaml value parsing issue. #246

Open
vishal-ramani opened this issue Oct 17, 2022 · 0 comments
Open

BOM variable yaml value parsing issue. #246

vishal-ramani opened this issue Oct 17, 2022 · 0 comments
Assignees

Comments

@vishal-ramani
Copy link

Issue: IASCABLE build apply.sh is unable to parse yaml formatted input value.

BOM File: https://github.ibm.com/isv-assets/watson-boms/blob/main/roks-new-nlp/bom.yaml#L22-L24
Module: https://github.com/cloud-native-toolkit/terraform-gitops-ubi
Variable Template: https://github.ibm.com/isv-assets/watson-boms/blob/main/roks-new-nlp/output/cluster-with-watson-nlp/variables-template.yaml#L67-L69

We are using above bom file and module. After running iascable build it'll generate output folder with variable.yaml file.
We are passing below curl command as input parameter.

Plain CURL command:

curl -X POST "http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict" -H "accept: application/json" -H "grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock" -H "content-type: application/json" -d " { \"rawDocument\": { \"text\": \"It is so easy to embed Watson NLP in application. Very cool!\" }}"

Formatted command which works with Helm local install. We have to pass this command as inout value to BOM.

'''curl -X POST "http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict" -H "accept: application/json" -H "grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock" -H "content-type: application/json" -d " { \"rawDocument\": { \"text\": \"It is so easy to embed Watson NLP in application. Very cool\" }}"'''

We are trying to pass command as valid YAML syntax of bom file in below 2 scenario but it's failing after we run appy.sh file. Please find below steps to re-produce this error.

1. Scenario modify the variables.yaml file

  1. Modify existing variable.yaml in the output folder by inserting the following curl command
# ubi
  - name: terraform_gitops_ubi_command
    value: "\'\'\'curl -X POST \"http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict\" -H \"accept: application/json\" -H \"grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock\" -H "content-type: application/json\" -d \" { \"rawDocument\": { \"text\": \"It is so easy to embed Watson NLP in application. Very cool!\" }}\"\'\'\'"
  1. Execute iascable
  2. Start the multipass
  3. Inside the VM: execute apply.sh
  4. You will not be asked for inserting the command variable
  5. Following error appears:
parse error: Invalid numeric literal at line 1, column 68
parse error: Invalid numeric literal at line 1, column 68
parse error: Invalid numeric literal at line 1, column 68
Error: Value for env variable 'NAME' not provided in env()
Error: Value for env variable 'NAME' not provided in env()

2. Scenario not modify the variables.yaml file

  1. Execute iascable
  2. Start the multipass
  3. Inside the VM execute: apply.sh
  4. You will be asked for inserting the command variable we inserting following command:
'''curl -X POST "http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict" -H "accept: application/json" -H "grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock" -H "content-type: application/json" -d " { \"rawDocument\": { \"text\": \"It is so easy to embed Watson NLP in application. Very cool!\" }}"'''
  1. Inspect the newly created variable.yaml file here we find following entry:
    "'''curl -X POST "http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict\" -H "accept: application/json" -H "grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock" -H "content-type: application/json" -d " { "rawDocument": { "text": "It is so easy to embed Watson NLP in application. Very cool!" }}"'''"
  2. Starting terraform init
Passing Value :
- name: terraform_gitops_ubi_command
    value: '''curl -X POST \"http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict\" -H \"accept: application/json\" -H \"grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock\" -H \"content-type: application/json\" -d \" { \"rawDocument\": { \"text\": \"It is so easy to embed Watson NLP in application. Very cool!\" }}\"'''
Result:
╷
│ Error: Missing newline after argument
│
│   on terraform.tfvars line 19:
│   19: terraform_gitops_ubi_command = "'curl -X POST \\"http://watson-nlp-watson-nlp:8080/v1/watson_runtime/NlpService/SyntaxPredict\\" -H \\"accept: application/json\\" -H \\"grpc-metadata-mm-model-id: syntax_izumo_lang_en_stock\\" -H \\"content-type: application/json\\" -d \\" { \\"rawDocument\\": { \\"text\\": \\"It is so easy to embed Watson NLP in application. Very cool!\\" }}\\"'"
│
│ An argument definition must end with a newline.
Error After Terraform Init (edited)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants