Skip to content

Commit

Permalink
fix(docs): remove dead links (#5051)
Browse files Browse the repository at this point in the history
* fix(docs): remove dead links

* Update parameters_test.go
  • Loading branch information
CCFenner authored Sep 20, 2024
1 parent 528a72e commit a242bca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions pkg/documentation/generator/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
)

const (
vaultBadge = "[Vault](https://img.shields.io/badge/-Vault-lightgrey)"
jenkinsOnlyBadge = "[Jenkins only](https://img.shields.io/badge/-Jenkins%20only-yellowgreen)"
secretBadge = "[Secret](https://img.shields.io/badge/-Secret-yellowgreen)"
trustengineBadge = "[Trust Engine](https://img.shields.io/badge/-Trust Engine-lightblue)"
deprecatedBadge = "[deprecated](https://img.shields.io/badge/-deprecated-red)"
vaultBadge = "![Vault](https://img.shields.io/badge/-Vault-lightgrey)"
jenkinsOnlyBadge = "![Jenkins only](https://img.shields.io/badge/-Jenkins%20only-yellowgreen)"
secretBadge = "![Secret](https://img.shields.io/badge/-Secret-yellowgreen)"
trustengineBadge = "![Trust Engine](https://img.shields.io/badge/-Trust%20Engine-lightblue)"
deprecatedBadge = "![deprecated](https://img.shields.io/badge/-deprecated-red)"
)

// Replaces the Parameters placeholder with the content from the yaml
Expand Down Expand Up @@ -93,19 +93,19 @@ func parameterFurtherInfo(paramName string, stepData *config.StepData, execution
}

if paramName == "script" {
return checkParameterInfo(fmt.Sprintf("[!%s](#) reference to Jenkins main pipeline script", jenkinsOnlyBadge), true, executionEnvironment)
return checkParameterInfo(fmt.Sprintf("%s reference to Jenkins main pipeline script", jenkinsOnlyBadge), true, executionEnvironment)
}

// handle non-step parameters (e.g. Jenkins-specific parameters as well as execution environment parameters)
jenkinsParams := []string{"containerCommand", "containerName", "containerShell", "dockerVolumeBind", "dockerWorkspace", "sidecarReadyCommand", "sidecarWorkspace", "stashContent"}
if !contains(stepParameterNames, paramName) {
for _, secret := range stepData.Spec.Inputs.Secrets {
if paramName == secret.Name && secret.Type == "jenkins" {
return checkParameterInfo(fmt.Sprintf("[!%s](#) id of credentials ([using credentials](https://www.jenkins.io/doc/book/using/using-credentials/))", jenkinsOnlyBadge), true, executionEnvironment)
return checkParameterInfo(fmt.Sprintf("%s id of credentials ([using credentials](https://www.jenkins.io/doc/book/using/using-credentials/))", jenkinsOnlyBadge), true, executionEnvironment)
}
}
if contains(jenkinsParams, paramName) {
return checkParameterInfo(fmt.Sprintf("[!%s](#)", jenkinsOnlyBadge), false, executionEnvironment)
return checkParameterInfo(fmt.Sprintf("%s", jenkinsOnlyBadge), false, executionEnvironment)
}
return checkParameterInfo("", false, executionEnvironment)
}
Expand All @@ -115,17 +115,17 @@ func parameterFurtherInfo(paramName string, stepData *config.StepData, execution
if paramName == param.Name {
furtherInfo := ""
if param.DeprecationMessage != "" {
furtherInfo += fmt.Sprintf("!%s", deprecatedBadge)
furtherInfo += fmt.Sprintf("%s", deprecatedBadge)
}
if param.Secret {
secretInfo := fmt.Sprintf("[!%s](#) pass via ENV or Jenkins credentials", secretBadge)
secretInfo := fmt.Sprintf("%s pass via ENV or Jenkins credentials", secretBadge)

isVaultSecret := param.GetReference("vaultSecret") != nil || param.GetReference("vaultSecretFile") != nil
isTrustengineSecret := param.GetReference(config.RefTypeTrustengineSecret) != nil
if isVaultSecret && isTrustengineSecret {
secretInfo = fmt.Sprintf(" [!%s](#) [!%s](#) [!%s](/) pass via ENV, Vault, Trust Engine or Jenkins credentials", vaultBadge, trustengineBadge, secretBadge)
secretInfo = fmt.Sprintf(" %s %s %s pass via ENV, Vault, Trust Engine or Jenkins credentials", vaultBadge, trustengineBadge, secretBadge)
} else if isVaultSecret {
secretInfo = fmt.Sprintf(" [!%s](#) [!%s](/) pass via ENV, Vault or Jenkins credentials", vaultBadge, secretBadge)
secretInfo = fmt.Sprintf(" %s %s pass via ENV, Vault or Jenkins credentials", vaultBadge, secretBadge)
}

for _, res := range param.ResourceRef {
Expand Down
4 changes: 2 additions & 2 deletions pkg/documentation/generator/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestCreateParameterOverview(t *testing.T) {
expected := `| Name | Mandatory | Additional information |
| ---- | --------- | ---------------------- |
| [dockerImage](#dockerimage) | no | |
| [stashContent](#stashcontent) | no | [![Jenkins only](https://img.shields.io/badge/-Jenkins%20only-yellowgreen)](#) |
| [stashContent](#stashcontent) | no | ![Jenkins only](https://img.shields.io/badge/-Jenkins%20only-yellowgreen) |
`
assert.Equal(t, expected, createParameterOverview(&stepData, true))
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestParameterFurtherInfo(t *testing.T) {
},
},
},
contains: "![deprecated](https://img.shields.io/badge/-deprecated-red)[![Secret](https://img.shields.io/badge/-Secret-yellowgreen)](#)",
contains: "![deprecated](https://img.shields.io/badge/-deprecated-red)![Secret](https://img.shields.io/badge/-Secret-yellowgreen)",
},
{
paramName: "testSecret2",
Expand Down

0 comments on commit a242bca

Please sign in to comment.