Source code for ads.opctl.config.yaml_parsers.base
#!/usr/bin/env python# -*- coding: utf-8; -*-# Copyright (c) 2022, 2023 Oracle and/or its affiliates.# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/fromloggingimportgetLoggerfromcollectionsimportnamedtupleimportfsspecimportyamlimportimportliblogger=getLogger("ads.yaml")
[docs]deftranslate_config(self,config:list):""" Translates config to three element tuple of dictionary- (file, envVars, concatenated args) All elements that are of type `env` goes to envVars All elements that are of type `args` are concatenated as `--key1=value1 --key2=value2 ..` string All elements of type `file` are currently ignored """# TODO parse file typeparsed_config=namedtuple("ClusterConfig",field_names=["files","envVars","cmd_args"])envVars={}files={}cmd_args=""ifconfig:ifconfig.get("env"):foriteminconfig["env"]:envVars[item["name"]]=item["value"]cmd_args=" ".join(config.get("startOptions",[""]))returnparsed_config(files=files,envVars=envVars,cmd_args=cmd_args)