Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils_xslt: display xsltproc stderr when it fails #1002

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexandre-janniaux
Copy link

It's easy to have xsltproc failing to process the XML from a libvirt terraform configuration. Indeed, syntax error will trigger such failure, and a bad terraform configuration where xslt= property is confused as file path instead of content would likely generate syntax errors:

resource "libvirt_domain" "example" {
  # ...
  xml {
    xslt = "${path.module}/transform.xslt"
  }
}

Currently, when xsltproc fails, with TF_LOG=1, the following is displayed:

2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Failed to run xsltproc (is it installed?): timestamp=2023-02-21T14:00:35.620+0100

Which is confusing when xsltproc is available. With this patch and TF_LOG=1, the following would be displayed:

2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Failed to run xsltproc (is it installed?): timestamp=2023-02-21T14:00:35.620+0100
2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Error: {/tmp/terraform-provider-libvirt-xslt1179436507:1: parser error : Start tag expected, '<' not found
transform.xslt
^

Refs #999

Please make sure you read the contributor documentation before opening a Pull Request.

It's easy to have xsltproc failing to process the XML from a libvirt
terraform configuration. Indeed, syntax error will trigger such failure,
and a bad terraform configuration where xslt= property is confused as
file path instead of content would likely generate syntax errors:

    resource "libvirt_domain" "example" {
      # ...
      xml {
        xslt = "${path.module}/transform.xslt"
      }
    }

Currently, when xsltproc fails, with TF_LOG=1, the following is
displayed:

    2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Failed to run xsltproc (is it installed?): timestamp=2023-02-21T14:00:35.620+0100

Which is confusing when xsltproc is available. With this patch and
TF_LOG=1, the following would be displayed:

    2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Failed to run xsltproc (is it installed?): timestamp=2023-02-21T14:00:35.620+0100
    2023-02-21T14:00:35.620+0100 [INFO]  provider.terraform-provider-libvirt: 2023/02/21 14:00:35 [ERROR] Error: {/tmp/terraform-provider-libvirt-xslt1179436507:1: parser error : Start tag expected, '<' not found
    transform.xslt
    ^

Refs dmacvicar#999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant