1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

docs: add general config parameters to GO docs (#1471)

* extract StepConfiguration generation to separate file

* add general options to parameter and config table

* fix test case

* remove telemetry flag from docs

* Revert "extract StepConfiguration generation to separate file"

This reverts commit df80dab8cd.
This commit is contained in:
Christopher Fenner 2020-04-29 14:40:11 +02:00 committed by GitHub
parent a395cd75be
commit 3a4d4b2de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -42,6 +42,9 @@ func generateStepDocumentation(stepData config.StepData, docuHelperData DocuHelp
tmpl, err := template.New("doc").Funcs(funcMap).Parse(content)
checkError(err)
//add general options like script, verbose, etc.
appendGeneralOptionsToParameters(&stepData)
setDefaultStepParameters(&stepData)
// add secrets, context defaults to the step parameters
handleStepParameters(&stepData)
@ -242,6 +245,18 @@ func handleStepParameters(stepData *config.StepData) {
sortStepParameters(stepData)
}
func appendGeneralOptionsToParameters(stepData *config.StepData) {
script := config.StepParameters{
Name: "script", Type: "Jenkins Script", Mandatory: true,
Description: "The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the `commonPipelineEnvironment` for retrieving, e.g. configuration parameters.",
}
verbose := config.StepParameters{
Name: "verbose", Type: "bool", Mandatory: false, Default: false, Scope: []string{"GENERAL"},
Description: "verbose output",
}
stepData.Spec.Inputs.Parameters = append(stepData.Spec.Inputs.Parameters, script, verbose)
}
func appendSecretsToParameters(stepData *config.StepData) {
secrets := stepData.Spec.Inputs.Secrets
if secrets != nil {

View File

@ -12,7 +12,31 @@ import (
"github.com/stretchr/testify/assert"
)
var expectedResultDocument string = "# testStep\n\n\t## Description\n\nLong Test description\n\n\t\n\t## Prerequisites\n\t\n\tnone\n\n\t\n\t\n\t## Parameters\n\n| name | mandatory | default | possible values |\n| ---- | --------- | ------- | --------------- |\n| `param0` | No | `val0` | |\n| `param1` | No | | |\n| `param2` | Yes | | |\n\n * `param0`: param0 description\n * `param1`: param1 description\n * `param2`: param1 description\n\n\t\n\t## Step Configuration\n\nWe recommend to define values of step parameters via [config.yml file](../configuration.md).\n\nIn following sections of the config.yml the configuration is possible:\n\n| parameter | general | step/stage |\n| --------- | ------- | ---------- |\n| `param0` | X | |\n| `param1` | | |\n| `param2` | | |\n\n\t\n\t## Side effects\n\t\n\tnone\n\t\n\t## Exceptions\n\t\n\tnone\n\t\n\t## Example\n\n\tnone\n"
var expectedResultDocument string = "# testStep\n\n\t## Description\n\nLong Test description\n\n\t\n\t" +
"## Prerequisites\n\t\n\tnone\n\n\t\n\t\n\t" +
"## Parameters\n\n| name | mandatory | default | possible values |\n" +
"| ---- | --------- | ------- | --------------- |\n" +
"| `param0` | No | `val0` | |\n" +
"| `param1` | No | | |\n" +
"| `param2` | Yes | | |\n" +
"| `script` | Yes | | |\n" +
"| `verbose` | No | `false` | |\n\n" +
" * `param0`: param0 description\n" +
" * `param1`: param1 description\n" +
" * `param2`: param1 description\n" +
" * `script`: The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the `commonPipelineEnvironment` for retrieving, e.g. configuration parameters.\n" +
" * `verbose`: verbose output\n\n\t\n\t" +
"## Step Configuration\n\nWe recommend to define values of step parameters via [config.yml file](../configuration.md).\n\n" +
"In following sections of the config.yml the configuration is possible:\n\n" +
"| parameter | general | step/stage |\n" +
"| --------- | ------- | ---------- |\n" +
"| `param0` | X | |\n" +
"| `param1` | | |\n" +
"| `param2` | | |\n" +
"| `verbose` | X | |\n\n\t\n\t" +
"## Side effects\n\t\n\tnone\n\t\n\t" +
"## Exceptions\n\t\n\tnone\n\t\n\t" +
"## Example\n\n\tnone\n"
func configMetaDataMock(name string) (io.ReadCloser, error) {
meta1 := `metadata: