This commit is contained in:
@@ -17,6 +17,9 @@ import (
|
|||||||
// swagger:model postParamsBody
|
// swagger:model postParamsBody
|
||||||
type PostParamsBody struct {
|
type PostParamsBody struct {
|
||||||
|
|
||||||
|
// Name of the json input file to utilise
|
||||||
|
Infile string `json:"infile,omitempty"`
|
||||||
|
|
||||||
// the filename of the output spreadsheet
|
// the filename of the output spreadsheet
|
||||||
OutFilename *string `json:"out-filename,omitempty"`
|
OutFilename *string `json:"out-filename,omitempty"`
|
||||||
|
|
||||||
|
@@ -68,6 +68,10 @@ func init() {
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"infile": {
|
||||||
|
"description": "Name of the json input file to utilise",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"out-filename": {
|
"out-filename": {
|
||||||
"description": "the filename of the output spreadsheet",
|
"description": "the filename of the output spreadsheet",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -117,7 +121,7 @@ func init() {
|
|||||||
"cmds": [
|
"cmds": [
|
||||||
{
|
{
|
||||||
"action": "exec",
|
"action": "exec",
|
||||||
"exec": "/bin/json2excel -inputJson input.json -worksheetName \"{{ .WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Infile) \"\" }} \"/tmp/input.json\" {{- else }} {{ .Infile }} {{- end }} input.json -worksheetName \"{{ .WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
||||||
"print": true,
|
"print": true,
|
||||||
"silent": false
|
"silent": false
|
||||||
},
|
},
|
||||||
@@ -135,7 +139,7 @@ func init() {
|
|||||||
},
|
},
|
||||||
"x-direktiv-examples": [
|
"x-direktiv-examples": [
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n files:\n - name: input.json\n data: |\n jq(.input) \n worksheet-name: \"TestSpreadsheet\"\n out-filename: example.xlsx",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n files:\n - name: /tmp/input.json\n data: |\n jq(.input) \n worksheet-name: \"TestSpreadsheet\"\n out-filename: example.xlsx",
|
||||||
"title": "Basic"
|
"title": "Basic"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -276,7 +280,7 @@ func init() {
|
|||||||
"cmds": [
|
"cmds": [
|
||||||
{
|
{
|
||||||
"action": "exec",
|
"action": "exec",
|
||||||
"exec": "/bin/json2excel -inputJson input.json -worksheetName \"{{ .WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Infile) \"\" }} \"/tmp/input.json\" {{- else }} {{ .Infile }} {{- end }} input.json -worksheetName \"{{ .WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
||||||
"print": true,
|
"print": true,
|
||||||
"silent": false
|
"silent": false
|
||||||
},
|
},
|
||||||
@@ -294,7 +298,7 @@ func init() {
|
|||||||
},
|
},
|
||||||
"x-direktiv-examples": [
|
"x-direktiv-examples": [
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n files:\n - name: input.json\n data: |\n jq(.input) \n worksheet-name: \"TestSpreadsheet\"\n out-filename: example.xlsx",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n files:\n - name: /tmp/input.json\n data: |\n jq(.input) \n worksheet-name: \"TestSpreadsheet\"\n out-filename: example.xlsx",
|
||||||
"title": "Basic"
|
"title": "Basic"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -364,6 +368,10 @@ func init() {
|
|||||||
"postParamsBody": {
|
"postParamsBody": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"infile": {
|
||||||
|
"description": "Name of the json input file to utilise",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"out-filename": {
|
"out-filename": {
|
||||||
"description": "the filename of the output spreadsheet",
|
"description": "the filename of the output spreadsheet",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@@ -176,7 +176,7 @@ func runCommand0(ctx context.Context,
|
|||||||
params.DirektivDir,
|
params.DirektivDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd, err := templateString(`/bin/json2excel -inputJson input.json -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, at)
|
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "/tmp/input.json" {{- else }} {{ .Infile }} {{- end }} input.json -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, at)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ri.Logger().Infof("error executing command: %v", err)
|
ri.Logger().Infof("error executing command: %v", err)
|
||||||
ir[resultKey] = err.Error()
|
ir[resultKey] = err.Error()
|
||||||
|
@@ -32,7 +32,7 @@ functions:
|
|||||||
function: export-xlsx
|
function: export-xlsx
|
||||||
input:
|
input:
|
||||||
files:
|
files:
|
||||||
- name: input.json
|
- name: /tmp/input.json
|
||||||
data: |
|
data: |
|
||||||
jq(.input)
|
jq(.input)
|
||||||
worksheet-name: "TestSpreadsheet"
|
worksheet-name: "TestSpreadsheet"
|
||||||
@@ -101,6 +101,7 @@ functions:
|
|||||||
|
|
||||||
| Name | Type | Go type | Required | Default | Description | Example |
|
| Name | Type | Go type | Required | Default | Description | Example |
|
||||||
|------|------|---------|:--------:| ------- |-------------|---------|
|
|------|------|---------|:--------:| ------- |-------------|---------|
|
||||||
|
| infile | string| `string` | | | Name of the json input file to utilise | |
|
||||||
| out-filename | string| `string` | | `"output.xlsx"`| the filename of the output spreadsheet | |
|
| 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 | |
|
| worksheet-name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |
|
||||||
|
|
||||||
|
@@ -11,6 +11,6 @@ states:
|
|||||||
input:
|
input:
|
||||||
files:
|
files:
|
||||||
- data: "jq(.input) \n"
|
- data: "jq(.input) \n"
|
||||||
name: input.json
|
name: /tmp/input.json
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
worksheet-name: TestSpreadsheet
|
worksheet-name: TestSpreadsheet
|
||||||
|
Reference in New Issue
Block a user