capactio / capact

Simple way to manage applications and infrastructure.
https://capact.io
Apache License 2.0
79 stars 19 forks source link

Improve errors messages in creating Action mode #702

Closed mkuziemko closed 2 years ago

mkuziemko commented 2 years ago

Description

Changes proposed in this pull request:

Testing

  1. Create cluster with DISABLE_MONITORING_INSTALLATION=true make dev-cluster
  2. Build cli make build-tool-cli
  3. Create a policy file
    cat > /tmp/policy.yaml << ENDOFFILE
    ;;badsyntax
    ENDOFFILE
  4. Create empty parameters file
    cat >/tmp/params.yaml << ENDOFFILE
    ENDOFFILE
  5. Try to create a Capact action:
    capact act create cap.interface.automation.concourse.install --name cc  --parameters-from-file /tmp/params.yaml --action-policy-from-file /tmp/policy.yaml

    it will fail with an error:

    Error: while unmarshaling action policy file: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type graphql.PolicyInput
  6. Create an empty policy file
    cat > /tmp/policy.yaml << ENDOFFILE
    ENDOFFILE
  7. Create empty parameters file
    cat >/tmp/params.yaml << ENDOFFILE
    {{}badyntax
    ENDOFFILE
  8. capact act create cap.interface.automation.concourse.install --name cc  --parameters-from-file /tmp/params.yaml --action-policy-from-file /tmp/policy.yaml

expected error:

Error: while converting YAML action input parameters to JSON: yaml: did not find expected ',' or '}'

I thought about adding UT for this issue but perhaps it is not needed now.

Related issue(s)