Skip to content

Escaping a regex #1117

Answered by zerok
strowi asked this question in Q&A
Aug 1, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote
import subprocess
import tempfile
import shutil
import pathlib
import yaml

dir = tempfile.mkdtemp()
try:
    subprocess.check_call('tk init', cwd=dir, shell=True)
    (pathlib.Path(dir) / 'environments' / 'default' / 'main.jsonnet').write_text('''
local k = import 'github.com/grafana/jsonnet-libs/ksonnet-util/kausal.libsonnet';
local configMap = k.core.v1.configMap;

{
  configMap:
    configMap.new(
      'config', std.manifestYamlDoc({
        'config.yaml': {
          topic_pattern: '^sl1\\\\.([a-z0-9_-]+)\\\\.([a-z0-9_-]+)\\\\.(data)+$',
        },
      }),
    ),
}
    ''')
    subprocess.check_call('tk export output environments/default', shell=True, cwd=dir)

    config_map_path =

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@zerok
Comment options

zerok Aug 2, 2024
Maintainer

Answer selected by strowi
@strowi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants