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

Multiple Outputs Support #15

Open
vz250049 opened this issue Oct 13, 2023 · 1 comment
Open

Multiple Outputs Support #15

vz250049 opened this issue Oct 13, 2023 · 1 comment

Comments

@vz250049
Copy link

vz250049 commented Oct 13, 2023

First off, this is really good stuff here.

Tried code with multiple outputs and it seems to negate both when I do it. 2 places where I call writeOutput hoping to set outputs and I get errors. See below.

outputs:
  result1:
    description: Rendered file content1
 result2:
   description: Rendered file content2

Changed function to:
func writeOutput(name string, output string) error {...}

"Error! {\"statusCode\":200,\"statusMessage\":\"OK\",\"ok\":false,\"result\":\"{\\\"ok\\\":false,\\\"error\\\":\\\"invalid_blocks\\\",\\\"errors\\\":[\\\"failed to match all allowed schemas [json-pointer:/blocks/2/text]\\\",\\\"must be more than 0 characters [json-pointer:/blocks/2/text/text]\\\"],\\\"response_metadata\\\":{\\\"messages\\\":[\\\"[ERROR] failed to match all allowed schemas [json-pointer:/blocks/2/text]\\\",\\\"[ERROR] must be more than 0 characters [json-pointer:/blocks/2/text/text]\\\"]}}\",\"response\":{\"ok\":false,\"error\":\"invalid_blocks\",\"errors\":[\"failed to match all allowed schemas [json-pointer:/blocks/2/text]\",\"must be more than 0 characters [json-pointer:/blocks/2/text/text]\"],\"response_metadata\":{\"messages\":[\"[ERROR] failed to match all allowed schemas [json-pointer:/blocks/2/text]\",\"[ERROR] must be more than 0 characters [json-pointer:/blocks/2/text/text]\"]}}} (response)"Show less
--
build-and-push-to-gcrUnable to process file command 'output' successfully.
build-and-push-to-gcrInvalid value. EOF marker missing new line.

"Error! {\"statusCode\":200,\"statusMessage\":\"OK\",\"ok\":false,\"result\":\"{\\\"ok\\\":false,\\\"error\\\":\\\"invalid_blocks\\\",\\\"errors\\\":[\\\"failed to match all allowed schemas [json-pointer:/blocks/2/text]\\\",\\\"must be more than 0 characters [json-pointer:/blocks/2/text/text]\\\"],\\\"response_metadata\\\":{\\\"messages\\\":[\\\"[ERROR] failed to match all allowed schemas [json-pointer:/blocks/2/text]\\\",\\\"[ERROR] must be more than 0 characters [json-pointer:/blocks/2/text/text]\\\"]}}\",\"response\":{\"ok\":false,\"error\":\"invalid_blocks\",\"errors\":[\"failed to match all allowed schemas [json-pointer:/blocks/2/text]\",\"must be more than 0 characters [json-pointer:/blocks/2/text/text]\"],\"response_metadata\":{\"messages\":[\"[ERROR] failed to match all allowed schemas [json-pointer:/blocks/2/text]\",\"[ERROR] must be more than 0 characters [json-pointer:/blocks/2/text/text]\"]}}} (response)"
[build-and-push-to-gcr](https://github.com/ncr-bsp/docker-java/actions/runs/6513226036/job/17692415054#step:7:28)
Unable to process file command 'output' successfully.
[build-and-push-to-gcr](https://github.com/ncr-bsp/docker-java/actions/runs/6513226036/job/17692415054#step:7:29)
Invalid value. EOF marker missing new line.

can you help?

@chuhlomin
Copy link
Owner

chuhlomin commented Oct 16, 2023

Hey @vz250049,

I'm not sure I understand the problem you're trying to solve in the first place.
I can suggest a few things that might help you:

  1. Run this step multiple times with different inputs. The overhead of this will be small.
  2. Make the template to look like a JSON string, then split it in a different step using jq.
  3. Use a template with some separator (like ---) and then split it using csplit or awk.

If you still want to do it in a single step, writeOutput function signature may look like this to accept a map of outputs:

func writeOutput(outputs map[string]string) error

Then, for each key in the map, call formatOutput with the key and value and join the strings with a newline separator before writing to the file.

Alternative solution is to use list of outputs, depending on how you want to generate them, and generate output names automatically (result, result2, result3, ...):

func writeOutput(outputs []string) error

Also, update action.yml; otherwise some linters will complain about unknown outputs.

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

No branches or pull requests

2 participants