Closed mattronix closed 9 months ago
you need to define them as inputs in offering. they are passed as capitalized environment variables to the scripts
Amazing Thank you :)
Do i use os.environ to access the keys?
As so far i get none if i use the internal name in Upper case
Dont quite understand how to access this variable ("environment"):
environment = { key.upper(): input_parameters[key] for key in input_parameters.keys() }
ah its passed through as
caught me off guard
When i try to load and display the attributes still get issues :(
import os
import json
import re
def run():
print("Hello World!")
if __name__ == "__main__":
run()
attributes = json.loads(os.environ.get("ATTRIBUTES"))
print(attributes)
Error message
[ErrorDetail(string='Unexpected structure of output', code=["{'name':", "'test',", "'secret':", "'tEAT'}"])]
Error traceback
Traceback (most recent call last): File "/usr/src/waldur/src/waldur_mastermind/marketplace/utils.py", line 104, in process_order processor(order).process_order(user) File "/usr/src/waldur/src/waldur_mastermind/marketplace/processors.py", line 70, in process_order scope = self.send_request(user) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/waldur/src/waldur_mastermind/marketplace_script/processors.py", line 73, in send_request raise serializers.ValidationError( rest_framework.exceptions.ValidationError: [ErrorDetail(string='Unexpected structure of output', code=["{'name':", "'test',", "'secret':", "'tEAT'}"])]
Took that reference from the custom examples in here, i can see its probably the " vs ' but how does this work for you if its not working in my case, probably better that i use ast literal instead.
Got it working in the end:
import os
import json
import re
import ast
def run():
print("Hello World!")
attributes = json.loads(os.environ.get("ATTRIBUTES"))
print(attributes)
print(type(attributes))
print(attributes["secret"])
if __name__ == "__main__":
run()
Hello Team,
How do i get User input variables in a python or bash script, did a scan through the docs and code in here and was not sure if they actually use that functionality.