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

Fix CodeClimate finding

This commit is contained in:
Sascha Vornheder 2019-11-12 13:55:32 +01:00
parent d87d27325c
commit 85570095c5
3 changed files with 36 additions and 34 deletions

View File

@ -13,26 +13,26 @@ import (
"github.com/ghodss/yaml"
)
// StepData defines the metadata for a step, like step descriptions, parameters, ...
// ContextDefaultData defines the metadata for a step, like step descriptions, parameters, ...
type ContextDefaultData struct {
Metadata ContextDefaultMetadata `json:"metadata"`
Parameters []ContextDefaultParameters `json:"params"`
}
// StepMetadata defines the metadata for a step, like step descriptions, parameters, ...
// ContextDefaultMetadata defines the metadata for a step, like step descriptions, parameters, ...
type ContextDefaultMetadata struct {
Name string `json:"name"`
Description string `json:"description"`
LongDescription string `json:"longDescription,omitempty"`
}
// StepParameters defines the parameters for a step
// ContextDefaultParameters defines the parameters for a step
type ContextDefaultParameters struct {
Name string `json:"name"`
Description string `json:"description"`
}
// ReadPipelineStepData loads step definition in yaml format
// ReadPipelineContextDefaultData loads step definition in yaml format
func (m *ContextDefaultData) readPipelineContextDefaultData(metadata io.ReadCloser) {
defer metadata.Close()
content, err := ioutil.ReadAll(metadata)
@ -41,6 +41,7 @@ func (m *ContextDefaultData) readPipelineContextDefaultData(metadata io.ReadClos
checkError(err)
}
// ReadContextDefaultMap maps the default descriptions into a map
func (c *ContextDefaultData) readContextDefaultMap() map[string]string {
var m map[string]string = make(map[string]string)

View File

@ -1,29 +1,29 @@
package helper
import (
"fmt"
"os"
)
func checkError(err error) {
if err != nil {
fmt.Printf("Error occured: %v\n", err)
os.Exit(1)
}
}
func contains(v []string, s string) bool {
for _, i := range v {
if i == s {
return true
}
}
return false
}
func ifThenElse(condition bool, positive string, negative string) string {
if condition {
return positive
}
return negative
}
package helper
import (
"fmt"
"os"
)
func checkError(err error) {
if err != nil {
fmt.Printf("Error occured: %v\n", err)
os.Exit(1)
}
}
func contains(v []string, s string) bool {
for _, i := range v {
if i == s {
return true
}
}
return false
}
func ifThenElse(condition bool, positive string, negative string) string {
if condition {
return positive
}
return negative
}

View File

@ -35,4 +35,5 @@ params:
- name: sidecarWorkspace
description: as dockerWorkspace for the sidecar container
- name: stashContent
description: Specific stashes that should be considered for the step execution.
description: Specific stashes that should be considered for the step execution.