1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

docs: change secret docs (#1984)

* change secret docs

* link to credentials in resource reference

* cleanup

* correct type

* add configuration scope

* correct test case
This commit is contained in:
Christopher Fenner 2020-09-10 10:33:59 +02:00 committed by GitHub
parent dc9a6d7b2b
commit 666923e651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 14 deletions

View File

@ -252,6 +252,26 @@ func createParameterDetails(stepData *config.StepData) string {
details += "\n\n"
}
for _, secret := range stepData.Spec.Inputs.Secrets {
details += fmt.Sprintf("#### %v\n\n", secret.Name)
if !contains(stepParameterNames, secret.Name) {
details += "**Jenkins-specific:** Used for proper environment setup.\n\n"
}
details += secret.Description + "\n\n"
details += "[back to overview](#parameters)\n\n"
details += "| Scope | Details |\n"
details += "| ---- | --------- |\n"
details += fmt.Sprintf("| Aliases | %v |\n", aliasList(secret.Aliases))
details += fmt.Sprintf("| Type | `%v` |\n", "string")
details += fmt.Sprintf("| Configuration scope | %v |\n", scopeDetails([]string{"PARAMETERS", "GENERAL", "STEPS", "STAGES"}))
details += "\n\n"
}
return details
}
@ -365,7 +385,7 @@ func resourceReferenceDetails(resourceRef []config.ResourceReference) string {
}
resourceDetails += fmt.Sprintf("&nbsp;&nbsp;- `%v`%v<br />", alias.Name, ifThenElse(alias.Deprecated, " (**Deprecated**)", ""))
}
resourceDetails += fmt.Sprintf("&nbsp;&nbsp;id: `%v`<br />", resource.Name)
resourceDetails += fmt.Sprintf("&nbsp;&nbsp;id: [`%v`](#%v)<br />", resource.Name, strings.ToLower(resource.Name))
resourceDetails += fmt.Sprintf("&nbsp;&nbsp;reference to: `%v`<br />", resource.Param)
continue
}
@ -382,9 +402,6 @@ func handleStepParameters(stepData *config.StepData) {
//ToDo: add to context.yaml
appendGeneralOptionsToParameters(stepData)
//add secrets to step parameters
appendSecretsToParameters(stepData)
//consolidate conditional parameters:
//- remove duplicate parameter entries
//- combine defaults (consider conditions)

View File

@ -42,25 +42,25 @@ func configOpenDocTemplateFileMock(docTemplateFilePath string) (io.ReadCloser, e
meta1 := `# ${docGenStepName}
## ${docGenDescription}
## Prerequisites
none
## ${docJenkinsPluginDependencies}
## ${docGenParameters}
## ${docGenConfiguration}
## Side effects
none
## Exceptions
none
## Example
none
@ -365,7 +365,7 @@ func TestResourceReferenceDetails(t *testing.T) {
resourceRef: []config.ResourceReference{
{Name: "testCredentialId", Aliases: []config.Alias{}, Type: "secret", Param: "password"},
},
expected: "Jenkins credential id:<br />&nbsp;&nbsp;id: `testCredentialId`<br />&nbsp;&nbsp;reference to: `password`<br />",
expected: "Jenkins credential id:<br />&nbsp;&nbsp;id: [`testCredentialId`](#testcredentialid)<br />&nbsp;&nbsp;reference to: `password`<br />",
},
{
resourceRef: []config.ResourceReference{