jeudi 4 mars 2021

Executing method by yaml

My yaml file is

myYaml.yaml
myVal1:  "println(\"Hello Yaml\")"
myVal: "if (1 == 1) println(\"First statement!\") else println(\"Second statement\")"

both executing successfully by my code in scala

So far I have a executed condition in yaml that runs successfully This variable 'myval' is in yaml file.

'''myVal: "if (1 == 1) println(\"First statement!\") else println(\"Second statement\")"'''

and This variable 'myval1' is in yaml file too.

'''myVal1: "println(\"Hello Yaml\")"'''
using
'''

import scala.reflect.runtime.universe
import scala.tools.reflect.ToolBox
'''

and in class i have

'''val myStringExecTest: ToolBox[universe.type] = universe.runtimeMirror(getClass.getClassLoader).mkToolBox()
   myStringExecTest.eval(myStringExecTest.parse(confVar2.getString("myVal1")))
'''

Now, I want to execute my function from yaml as

if abc//some variable from my class where yaml will be called
= true
do this
else if
xyz //some variable from my class where yaml will be called
do that
else 
this

I am unable to get values based on some variables from the class. How can I achieve this?





Aucun commentaire:

Enregistrer un commentaire