functionbuilder again
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-11-21 14:36:15 +11:00
parent 8a65fcf6ef
commit b50c6993ad
5 changed files with 25 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ type PostParamsBodySheetsItems struct {
InputFile []apps.DirektivFile `json:"input-file"`
// Label for the worksheet created in the spreadsheet
WorksheetName *string `json:"worksheet-name,omitempty"`
Name *string `json:"name,omitempty"`
}
// Validate validates this post params body sheets items

View File

@@ -94,7 +94,7 @@ func init() {
"$ref": "#/definitions/direktivFile"
}
},
"worksheet-name": {
"name": {
"description": "Label for the worksheet created in the spreadsheet",
"type": "string",
"default": "Sheet1"
@@ -141,7 +141,7 @@ func init() {
"cmds": [
{
"action": "foreach",
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
"loop": ".Sheets",
"print": true,
"silent": false
@@ -160,11 +160,11 @@ func init() {
},
"x-direktiv-examples": [
{
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
"title": "Basic"
},
{
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
"title": "Use jq to add a parent key 'input' containing array of objects"
}
],
@@ -305,7 +305,7 @@ func init() {
"cmds": [
{
"action": "foreach",
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
"loop": ".Sheets",
"print": true,
"silent": false
@@ -324,11 +324,11 @@ func init() {
},
"x-direktiv-examples": [
{
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
"title": "Basic"
},
{
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
"title": "Use jq to add a parent key 'input' containing array of objects"
}
],
@@ -431,7 +431,7 @@ func init() {
"$ref": "#/definitions/direktivFile"
}
},
"worksheet-name": {
"name": {
"description": "Label for the worksheet created in the spreadsheet",
"type": "string",
"default": "Sheet1"

View File

@@ -185,7 +185,7 @@ func runCommand0(ctx context.Context,
params.DirektivDir,
}
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, ls)
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'`, ls)
if err != nil {
ir := make(map[string]interface{})
ir[successKey] = false