<commit_before>{{ with $upstreams := ls "<%= @rpaas_service_name %>/<%= @rpaas_instance_name %>/upstream" }}
  {{ range $upstreams}}
upstream {{ .Key }} { 
    {{- range $server :=  .Value | split "," }}
    server {{ $server }};
    {{- end }}
    keepalive <%= @nginx_upstream_keepalive %>;
}

  {{ end }}
{{ end }}<commit_msg>rpaas: check for upstream valid block or use stale conf<commit_after>{{- $fail := false }}
{{ with $upstreams := ls "<%= @rpaas_service_name %>/<%= @rpaas_instance_name %>/upstream" }}
  {{ range $upstreams}}
    {{ if .Value | regexMatch "(?ms)## Begin custom RpaaS .+ block ##\n## End custom RpaaS .+ block ##" }}
    {{ else }}
      {{ if .Value | regexMatch "(?ms)## Begin custom RpaaS .+ block ##.+## End custom RpaaS .+ block ##" }}
upstream {{ .Key }} {
    {{- range $server :=  .Value | regexReplaceAll "(?ms)## Begin custom RpaaS .+ block ##(.+)## End custom RpaaS .+ block ##" "$1" | split "," }}
    server {{ $server }};
    {{- end }}
    keepalive <%= @nginx_upstream_keepalive %>;
}
      {{ else }}
        {{- $fail := true }}
      {{ end }}
    {{ end }}
  {{ end }}
{{ else }}
  {{- $fail := true }}
{{ end }}
{{- if $fail }}
{{ plugin "check_file.sh" "/etc/nginx/sites-enabled/consul/upstreams.conf" }}
{{- end }}
{'fraction_non_alphanumeric': 0.23715415019762845, 'fraction_numerical': 0.0007905138339920949, 'mean_word_length': 3.0063291139240507, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7650670', 'n_tokens_mistral': 474, 'n_tokens_neox': 453, 'n_words': 106}