def add_context_from_string()

in 02_bootstrap-scripts-python/bootstrap/context.py [0:0]


    def add_context_from_string(self, context_str: str):
        #Take string of format <context>:<context primary indicator>:<context config>
        print(context_str)
        context_parts = context_str.split(":")
        context_name = context_parts[0]
        primary = context_parts[1]
        options = {}
        if len(context_parts) > 2:
            opts = context_parts[2].split(",")
            for opt in opts:
                spl = opt.split("=")
                options[spl[0]] = spl[1]
        if EnvironmentVariablesContext.get_context_string() == context_name:
            ctx: HelmValuesContext = EnvironmentVariablesContext(
                primary, options)
        elif RawValueContext.get_context_string() == context_name:
            ctx = RawValueContext(primary, options)
        elif VariableContentContext.get_context_string() == context_name:
            ctx = VariableContentContext(primary, options)
        elif FileContext.get_context_string() == context_name:
            ctx = FileContext(primary, options)
        elif JSONContext.get_context_string() == context_name:
            ctx = FileContext(primary, options)
        self.add_context(ctx)