From 178e27bc7e161ceda7967e194d563bb09e4aa7b1 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 10 Feb 2023 16:54:40 +1100 Subject: [PATCH] functionbuilder --- build/app/models/post_params_body.go | 3 +++ build/app/restapi/embedded_spec.go | 12 ++++++++++-- build/app/restapi/operations/direktiv_post.go | 2 +- readme.md | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build/app/models/post_params_body.go b/build/app/models/post_params_body.go index d0a989b..b126b72 100644 --- a/build/app/models/post_params_body.go +++ b/build/app/models/post_params_body.go @@ -19,6 +19,9 @@ import ( // swagger:model postParamsBody type PostParamsBody struct { + // json input to convert to spreadsheet + InData interface{} `json:"in-data,omitempty"` + // Name of the json input file to utilise Infile string `json:"infile,omitempty"` diff --git a/build/app/restapi/embedded_spec.go b/build/app/restapi/embedded_spec.go index e4b96e6..19cf87b 100644 --- a/build/app/restapi/embedded_spec.go +++ b/build/app/restapi/embedded_spec.go @@ -72,6 +72,10 @@ func init() { "out-filename" ], "properties": { + "in-data": { + "description": "json input to convert to spreadsheet", + "type": "object" + }, "infile": { "description": "Name of the json input file to utilise", "type": "string" @@ -137,7 +141,7 @@ func init() { }, { "action": "exec", - "exec": "ls -la /tmp", + "exec": "/bin/bash -c \"echo '{{ .InData | toJson }}' \u003e /tmp/input.json\"", "print": true, "silent": false }, @@ -320,7 +324,7 @@ func init() { }, { "action": "exec", - "exec": "ls -la /tmp", + "exec": "/bin/bash -c \"echo '{{ .InData | toJson }}' \u003e /tmp/input.json\"", "print": true, "silent": false }, @@ -424,6 +428,10 @@ func init() { "out-filename" ], "properties": { + "in-data": { + "description": "json input to convert to spreadsheet", + "type": "object" + }, "infile": { "description": "Name of the json input file to utilise", "type": "string" diff --git a/build/app/restapi/operations/direktiv_post.go b/build/app/restapi/operations/direktiv_post.go index 0f40d24..7c1eee6 100644 --- a/build/app/restapi/operations/direktiv_post.go +++ b/build/app/restapi/operations/direktiv_post.go @@ -366,7 +366,7 @@ func runCommand2(ctx context.Context, params.DirektivDir, } - cmd, err := templateString(`ls -la /tmp`, at) + cmd, err := templateString(`/bin/bash -c "echo '{{ .InData | toJson }}' > /tmp/input.json"`, at) if err != nil { ri.Logger().Infof("error executing command: %v", err) ir[resultKey] = err.Error() diff --git a/readme.md b/readme.md index 2557f03..7f5971d 100644 --- a/readme.md +++ b/readme.md @@ -101,6 +101,7 @@ functions: | Name | Type | Go type | Required | Default | Description | Example | |------|------|---------|:--------:| ------- |-------------|---------| +| in-data | [interface{}](#interface)| `interface{}` | | | json input to convert to spreadsheet | | | infile | string| `string` | | | Name of the json input file to utilise | | | out-filename | string| `string` | ✓ | `"output.xlsx"`| the filename of the output spreadsheet | | | worksheet-name | string| `string` | ✓ | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |