mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
54ff93233e
* remove docs generator code from step-generator * add docs generator to dedicated package * add test cases * add entry point for docs generation * make output more readable * remove dead code
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package generator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/config"
|
|
)
|
|
|
|
func stepOutputs(stepData *config.StepData) string {
|
|
if len(stepData.Spec.Outputs.Resources) == 0 {
|
|
return ""
|
|
}
|
|
|
|
stepOutput := "\n## Outputs\n\n"
|
|
stepOutput += "| Output type | Details |\n"
|
|
stepOutput += "| ----------- | ------- |\n"
|
|
|
|
for _, res := range stepData.Spec.Outputs.Resources {
|
|
//handle commonPipelineEnvironment output
|
|
if res.Type == "piperEnvironment" {
|
|
stepOutput += fmt.Sprintf("| %v | <ul>", res.Name)
|
|
for _, param := range res.Parameters {
|
|
stepOutput += fmt.Sprintf("<li>%v</li>", param["name"])
|
|
}
|
|
stepOutput += "</ul> |\n"
|
|
}
|
|
|
|
//handle Influx output
|
|
if res.Type == "influx" {
|
|
stepOutput += fmt.Sprintf("| %v | ", res.Name)
|
|
for _, param := range res.Parameters {
|
|
stepOutput += fmt.Sprintf("measurement `%v`<br /><ul>", param["name"])
|
|
fields, _ := param["fields"].([]interface{})
|
|
for _, field := range fields {
|
|
fieldMap, _ := field.(map[string]interface{})
|
|
stepOutput += fmt.Sprintf("<li>%v</li>", fieldMap["name"])
|
|
}
|
|
}
|
|
stepOutput += "</ul> |\n"
|
|
}
|
|
|
|
}
|
|
return stepOutput
|
|
}
|