Ejemplo n.º 1
0
    def _process_range_begin2(self, content):
        """
        {{- range .Values.autoscalingGroups }}
        """
        m = re.search(r'{{-[ ]+range[ ]+([\$\.\w]+)[ ]*}}', content)
        if not m:
            return content, False

        self.stack.append(" endfor ")
        self.range_matched += 1
        data = m.group(1)
        data = keyword_replace(data)
        data = data.replace('$', '')

        return content.find('{{') * " " + "{%-" + " for item in %s " % (
            data) + "%}\n", True
Ejemplo n.º 2
0
    def _process_range_begin3(self, content):
        """
        {{- range $key, $value := .Values.ingress.annotations }}
        """
        m = re.search(r'{{-[ ]+range[ ]+\$([\.\w]+)[ ]*:=[ ]*([\.\w]+)[ ]*}}',
                      content)
        if not m:
            return content

        self.stack.append(" endfor ")
        self.range_matched += 1
        key = m.group(1)
        data = m.group(2)
        data = keyword_replace(data)

        return content.find('{{') * " " + "{%-" + " for %s in %s " % (
            key, data) + "%}\n"
Ejemplo n.º 3
0
    def _process_with_begin(self, content):
        """
        {{ with .Values.resizer }}
        """
        m = re.search(r'(.*){{[-]{0,1}[ ]*with[ ]+([\.\w]+)[ ]*[-]{0,1}}}(.*)',
                      content)
        if not m:
            return content

        self.stack.append("endWith")
        self.with_matched += 1
        prefix = m.group(1)
        data = m.group(2)
        postfix = m.group(3)
        data = keyword_replace(data)

        return "%s{%s- set item = %s " % (
            prefix, "%", data) + "%}" + postfix.replace("$", "") + "\n"
Ejemplo n.º 4
0
    def _process_range_begin(self, content):
        """
        {{- range $key, $value := .Values.ingress.annotations }}
        """
        m = re.search(
            r'(.*){{[-]{0,1}[ ]*range[ ]+\$([\.\w]+)[ ]*,[ ]*\$([\.\w]+)[ ]*:=[ ]*([\.\w]+)[ ]*[-]{0,1}}}(.*)',
            content)
        if not m:
            return content, False

        self.stack.append(" endfor ")
        self.range_matched += 1
        prefix = m.group(1)
        key = m.group(2)
        value = m.group(3)
        data = m.group(4)
        postfix = m.group(5)
        data = keyword_replace(data)

        return "%s{%s- for %s, %s in %s.iteritems() " % (
            prefix, "%", key, value, data) + "%}" + postfix.replace(
                "$", "") + "\n", True
Ejemplo n.º 5
0
 def replace(match):
     tmpStr = match.group()
     tmpStr = keyword_replace(tmpStr)
     return tmpStr.replace(' .', ' item.')