You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	chore: export config functions (#3631)
* chore: export config functions * add docs
This commit is contained in:
		| @@ -320,7 +320,7 @@ func addConfigTelemetryData(utils cnbutils.BuildUtils, data *cnbBuildTelemetryDa | ||||
|  | ||||
| 	data.Buildpacks.FromConfig = privacy.FilterBuildpacks(config.Buildpacks) | ||||
|  | ||||
| 	dockerImage, err := getDockerImageValue("cnbBuild") | ||||
| 	dockerImage, err := GetDockerImageValue("cnbBuild") | ||||
| 	if err != nil { | ||||
| 		log.Entry().Warnf("Error while preparing telemetry: retrieving docker image failed: '%v'", err) | ||||
| 		data.Builder = "" | ||||
|   | ||||
| @@ -75,7 +75,8 @@ func ConfigCommand() *cobra.Command { | ||||
| 	return createConfigCmd | ||||
| } | ||||
|  | ||||
| func getDockerImageValue(stepName string) (string, error) { | ||||
| // GetDockerImageValue provides Piper commands additional access to configuration of step execution image if required | ||||
| func GetDockerImageValue(stepName string) (string, error) { | ||||
| 	configOptions.contextConfig = true | ||||
| 	configOptions.stepName = stepName | ||||
| 	stepConfig, err := getConfig() | ||||
| @@ -95,7 +96,7 @@ func getDockerImageValue(stepName string) (string, error) { | ||||
| func getBuildToolFromStageConfig(stepName string) (string, error) { | ||||
| 	configOptions.contextConfig = true | ||||
| 	configOptions.stepName = stepName | ||||
| 	stageConfig, err := getStageConfig() | ||||
| 	stageConfig, err := GetStageConfig() | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| @@ -108,7 +109,9 @@ func getBuildToolFromStageConfig(stepName string) (string, error) { | ||||
| 	return buildTool, nil | ||||
| } | ||||
|  | ||||
| func getStageConfig() (config.StepConfig, error) { | ||||
| // GetStageConfig provides Piper commands additional access to stage configuration if required. | ||||
| // This allows steps to refer to configuration parameters which are not part of the step itself. | ||||
| func GetStageConfig() (config.StepConfig, error) { | ||||
| 	myConfig := config.Config{} | ||||
| 	stepConfig := config.StepConfig{} | ||||
| 	projectConfigFile := getProjectConfigFile(GeneralConfig.CustomConfig) | ||||
| @@ -142,7 +145,7 @@ func getConfig() (config.StepConfig, error) { | ||||
| 	var err error | ||||
|  | ||||
| 	if configOptions.stageConfig { | ||||
| 		stepConfig, err = getStageConfig() | ||||
| 		stepConfig, err = GetStageConfig() | ||||
| 		if err != nil { | ||||
| 			return stepConfig, errors.Wrap(err, "getting stage config failed") | ||||
| 		} | ||||
|   | ||||
| @@ -72,7 +72,7 @@ func (g *golangBuildUtilsBundle) DownloadFile(url, filename string, header http. | ||||
| } | ||||
|  | ||||
| func (g *golangBuildUtilsBundle) getDockerImageValue(stepName string) (string, error) { | ||||
| 	return getDockerImageValue(stepName) | ||||
| 	return GetDockerImageValue(stepName) | ||||
| } | ||||
|  | ||||
| func newGolangBuildUtils(config golangBuildOptions) golangBuildUtils { | ||||
|   | ||||
| @@ -89,7 +89,7 @@ func runKanikoExecute(config *kanikoExecuteOptions, telemetryData *telemetry.Cus | ||||
| 	log.Entry().Debugf("preparing build settings information...") | ||||
| 	stepName := "kanikoExecute" | ||||
| 	// ToDo: better testability required. So far retrieval of config is rather non deterministic | ||||
| 	dockerImage, err := getDockerImageValue(stepName) | ||||
| 	dockerImage, err := GetDockerImageValue(stepName) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("failed to retrieve dockerImage configuration: %w", err) | ||||
| 	} | ||||
|   | ||||
| @@ -91,7 +91,7 @@ func runMavenBuild(config *mavenBuildOptions, telemetryData *telemetry.CustomDat | ||||
|  | ||||
| 	log.Entry().Debugf("creating build settings information...") | ||||
| 	stepName := "mavenBuild" | ||||
| 	dockerImage, err := getDockerImageValue(stepName) | ||||
| 	dockerImage, err := GetDockerImageValue(stepName) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -230,7 +230,7 @@ func runMtaBuild(config mtaBuildOptions, | ||||
|  | ||||
| 	log.Entry().Debugf("creating build settings information...") | ||||
| 	stepName := "mtaBuild" | ||||
| 	dockerImage, err := getDockerImageValue(stepName) | ||||
| 	dockerImage, err := GetDockerImageValue(stepName) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -60,7 +60,7 @@ func runNpmExecuteScripts(npmExecutor npm.Executor, config *npmExecuteScriptsOpt | ||||
|  | ||||
| 	log.Entry().Debugf("creating build settings information...") | ||||
| 	stepName := "npmExecuteScripts" | ||||
| 	dockerImage, err := getDockerImageValue(stepName) | ||||
| 	dockerImage, err := GetDockerImageValue(stepName) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user