mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-16 11:09:33 +02:00
cd243ee542
* Upload reports to Google Cloud Storage bucket * Added tests. Made fixes * Update step generation. GCS client was moved to GeneralConfig * Code was refactored * Fixed issues * Fixed issues * Code correction due to PR comments * Improved gcs client and integration tests * Integrated gcp config. Updated step metadata * Fixed issues. Added tests * Added cpe, vault, aliases resolving for reporting parameters * Added tests * Uncommented DeferExitHandler. Removed useless comments * fixed cloning of config * Added comments for exported functions. Removed unused mock * minor fix * Implemented setting of report name via paramRef * some refactoring. Writing tests * Update pkg/config/reporting.go * Update cmd/sonarExecuteScan_generated.go * Apply suggestions from code review * Update pkg/config/reporting.go * Update pkg/config/reporting.go * fixed removing valut secret files * Update pkg/config/reporting.go * restore order * restore order * Apply suggestions from code review * go generate * fixed tests * Update resources/metadata/sonarExecuteScan.yaml * Update resources.go * Fixed tests. Code was regenerated * changed somewhere gcp to gcs. Fixed one test * move gcsSubFolder to input parameters * fixed removing valut secret files * minor fix in integration tests * fix integration tests Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
package config
|
|
|
|
// ReportingParams holds reporting parameters
|
|
type ReportingParams struct {
|
|
Parameters []StepParameters
|
|
}
|
|
|
|
// ReportingParameters is a global variable with values of reporting parameters
|
|
var ReportingParameters = ReportingParams{
|
|
Parameters: []StepParameters{
|
|
{
|
|
Name: "gcpJsonKeyFilePath",
|
|
Aliases: []Alias{{Name: "jsonKeyFilePath"}},
|
|
ResourceRef: []ResourceReference{
|
|
{
|
|
Name: "gcpFileVaultSecretName",
|
|
Type: "vaultSecretFile",
|
|
Default: "gcp",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "gcsFolderPath",
|
|
ResourceRef: []ResourceReference{
|
|
{
|
|
Name: "commonPipelineEnvironment",
|
|
Param: "custom/gcsFolderPath",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "gcsBucketId",
|
|
Aliases: []Alias{{Name: "pipelineId"}},
|
|
},
|
|
{
|
|
Name: "gcsSubFolder",
|
|
},
|
|
},
|
|
}
|
|
|
|
// GetResourceParameters retrieves reporting parameters from a named pipeline resource with a defined path
|
|
func (r ReportingParams) GetResourceParameters(path, name string) map[string]interface{} {
|
|
resourceParams := map[string]interface{}{}
|
|
|
|
for _, param := range r.Parameters {
|
|
for _, res := range param.ResourceRef {
|
|
if res.Name == name {
|
|
if val := getParameterValue(path, res, param); val != nil {
|
|
resourceParams[param.Name] = val
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return resourceParams
|
|
}
|
|
|
|
func (r ReportingParams) getStepFilters() StepFilters {
|
|
var filters StepFilters
|
|
reportingFilter := r.getReportingFilter()
|
|
filters.All = append(filters.All, reportingFilter...)
|
|
filters.General = append(filters.General, reportingFilter...)
|
|
filters.Steps = append(filters.Steps, reportingFilter...)
|
|
filters.Stages = append(filters.Stages, reportingFilter...)
|
|
return filters
|
|
}
|
|
|
|
func (r ReportingParams) getReportingFilter() []string {
|
|
var reportingFilter []string
|
|
for _, param := range r.Parameters {
|
|
reportingFilter = append(reportingFilter, param.Name)
|
|
}
|
|
reportingFilter = append(reportingFilter, getFilterForResourceReferences(r.Parameters)...)
|
|
return reportingFilter
|
|
}
|
|
|
|
func (s *StepConfig) mixinReportingConfig(configs ...map[string]interface{}) {
|
|
reportingFilter := ReportingParameters.getReportingFilter()
|
|
for _, config := range configs {
|
|
s.mixIn(config, reportingFilter)
|
|
}
|
|
}
|