nutanix / calm-dsl

Keep Calm and DSL On!
https://nutanix.github.io/calm-dsl/
Apache License 2.0
33 stars 51 forks source link

Decompile blueprint fails when description includes special chars #212

Open pipoe2h opened 2 years ago

pipoe2h commented 2 years ago

Decompile blueprint fails when description includes special chars, single quote in this case (doesn't)


Traceback (most recent call last):
  File "/root/.local/bin/calm", line 8, in <module>
    sys.exit(main())
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/utils.py", line 125, in invoke
    return super().invoke(ctx)
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/utils.py", line 125, in invoke
    return super().invoke(ctx)
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/bp_commands.py", line 170, in _decompile_bp
    decompile_bp(name, bp_file, with_secrets, prefix, bp_dir)
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/bps.py", line 478, in decompile_bp
    name=name, with_secrets=with_secrets, prefix=prefix, bp_dir=bp_dir
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/bps.py", line 506, in decompile_bp_from_server
    bp_payload=res, with_secrets=with_secrets, prefix=prefix, bp_dir=bp_dir
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/cli/bps.py", line 563, in _decompile_bp
    bp_dir=bp_dir,
  File "/root/.local/lib/python3.7/site-packages/calm/dsl/decompile/decompile_render.py", line 30, in create_bp_dir
    bp_data = format_str(bp_data, mode=FileMode())
  File "/root/.local/lib/python3.7/site-packages/black/__init__.py", line 1065, in format_str
    src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions)
  File "/root/.local/lib/python3.7/site-packages/black/__init__.py", line 1173, in lib2to3_parse
    raise exc from None
black.InvalidInput: Cannot parse: 112:256:         OCP_CLUSTER_NETWORK = CalmVariable.Simple('10.128.0.0/14', label='Kubernetes Pod network', is_mandatory=False, is_hidden=False, runtime=True, description='Internal Kubernetes network for Pod objects (format x.x.x.x/x)\nMake sure this network doesn't overlap with Service network, or networks in your datacenter')