From 666923e6511e599b49352393bd53893bae6ac7fb Mon Sep 17 00:00:00 2001
From: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
Date: Thu, 10 Sep 2020 10:33:59 +0200
Subject: [PATCH] docs: change secret docs (#1984)
* change secret docs
* link to credentials in resource reference
* cleanup
* correct type
* add configuration scope
* correct test case
---
pkg/generator/helper/docuHelper.go | 25 +++++++++++++++++++++----
pkg/generator/helper/docuHelper_test.go | 20 ++++++++++----------
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/pkg/generator/helper/docuHelper.go b/pkg/generator/helper/docuHelper.go
index 419e8ff89..740900712 100644
--- a/pkg/generator/helper/docuHelper.go
+++ b/pkg/generator/helper/docuHelper.go
@@ -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(" - `%v`%v
", alias.Name, ifThenElse(alias.Deprecated, " (**Deprecated**)", ""))
}
- resourceDetails += fmt.Sprintf(" id: `%v`
", resource.Name)
+ resourceDetails += fmt.Sprintf(" id: [`%v`](#%v)
", resource.Name, strings.ToLower(resource.Name))
resourceDetails += fmt.Sprintf(" reference to: `%v`
", 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)
diff --git a/pkg/generator/helper/docuHelper_test.go b/pkg/generator/helper/docuHelper_test.go
index ab3bc14f5..090c00688 100644
--- a/pkg/generator/helper/docuHelper_test.go
+++ b/pkg/generator/helper/docuHelper_test.go
@@ -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:
id: `testCredentialId`
reference to: `password`
",
+ expected: "Jenkins credential id:
id: [`testCredentialId`](#testcredentialid)
reference to: `password`
",
},
{
resourceRef: []config.ResourceReference{