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 
			
		
		
		
	Add telemetry for abapEnvironment steps (#3016)
* Remove explicit telemetry from signature * Set log level * ATC set error category
This commit is contained in:
		| @@ -16,7 +16,7 @@ import ( | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
| func abapEnvironmentCheckoutBranch(options abapEnvironmentCheckoutBranchOptions, telemetryData *telemetry.CustomData) { | ||||
| func abapEnvironmentCheckoutBranch(options abapEnvironmentCheckoutBranchOptions, _ *telemetry.CustomData) { | ||||
|  | ||||
| 	// for command execution use Command | ||||
| 	c := command.Command{} | ||||
| @@ -31,13 +31,13 @@ func abapEnvironmentCheckoutBranch(options abapEnvironmentCheckoutBranchOptions, | ||||
| 	client := piperhttp.Client{} | ||||
|  | ||||
| 	// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end | ||||
| 	err := runAbapEnvironmentCheckoutBranch(&options, telemetryData, &autils, &client) | ||||
| 	err := runAbapEnvironmentCheckoutBranch(&options, &autils, &client) | ||||
| 	if err != nil { | ||||
| 		log.Entry().WithError(err).Fatal("step execution failed") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func runAbapEnvironmentCheckoutBranch(options *abapEnvironmentCheckoutBranchOptions, telemetryData *telemetry.CustomData, com abaputils.Communication, client piperhttp.Sender) (err error) { | ||||
| func runAbapEnvironmentCheckoutBranch(options *abapEnvironmentCheckoutBranchOptions, com abaputils.Communication, client piperhttp.Sender) (err error) { | ||||
|  | ||||
| 	// Mapping for options | ||||
| 	subOptions := convertCheckoutConfig(options) | ||||
| @@ -108,9 +108,6 @@ func triggerCheckout(repositoryName string, branchName string, checkoutConnectio | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	// workaround until golang version 1.16 is used | ||||
| 	time.Sleep(100 * time.Millisecond) | ||||
|  | ||||
| 	log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", checkoutConnectionDetails.URL).Debug("Authentication on the ABAP system was successful") | ||||
| 	uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token") | ||||
| 	checkoutConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken | ||||
|   | ||||
| @@ -42,7 +42,7 @@ func TestCheckoutBranchStep(t *testing.T) { | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.NoError(t, err, "Did not expect error") | ||||
| 	}) | ||||
| 	t.Run("Run Step Failure - empty config", func(t *testing.T) { | ||||
| @@ -67,7 +67,7 @@ func TestCheckoutBranchStep(t *testing.T) { | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
| 	t.Run("Run Step Failure - wrong status", func(t *testing.T) { | ||||
| @@ -102,7 +102,7 @@ func TestCheckoutBranchStep(t *testing.T) { | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
| 	t.Run("Success case: checkout Branches from file config", func(t *testing.T) { | ||||
| @@ -154,7 +154,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.NoError(t, err) | ||||
| 	}) | ||||
| 	t.Run("Failure case: checkout Branches from empty file config", func(t *testing.T) { | ||||
| @@ -201,7 +201,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
| 	t.Run("Failure case: checkout Branches from wrong file config", func(t *testing.T) { | ||||
| @@ -253,7 +253,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentCheckoutBranch(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
| } | ||||
|   | ||||
| @@ -16,7 +16,7 @@ import ( | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
| func abapEnvironmentCloneGitRepo(config abapEnvironmentCloneGitRepoOptions, telemetryData *telemetry.CustomData) { | ||||
| func abapEnvironmentCloneGitRepo(config abapEnvironmentCloneGitRepoOptions, _ *telemetry.CustomData) { | ||||
|  | ||||
| 	c := command.Command{} | ||||
|  | ||||
| @@ -30,13 +30,13 @@ func abapEnvironmentCloneGitRepo(config abapEnvironmentCloneGitRepoOptions, tele | ||||
| 	client := piperhttp.Client{} | ||||
|  | ||||
| 	// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end | ||||
| 	err := runAbapEnvironmentCloneGitRepo(&config, telemetryData, &autils, &client) | ||||
| 	err := runAbapEnvironmentCloneGitRepo(&config, &autils, &client) | ||||
| 	if err != nil { | ||||
| 		log.Entry().WithError(err).Fatal("step execution failed") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, telemetryData *telemetry.CustomData, com abaputils.Communication, client piperhttp.Sender) error { | ||||
| func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, com abaputils.Communication, client piperhttp.Sender) error { | ||||
| 	// Mapping for options | ||||
| 	subOptions := convertCloneConfig(config) | ||||
|  | ||||
| @@ -113,9 +113,6 @@ func triggerClone(repo abaputils.Repository, cloneConnectionDetails abaputils.Co | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	// workaround until golang version 1.16 is used | ||||
| 	time.Sleep(100 * time.Millisecond) | ||||
|  | ||||
| 	log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", cloneConnectionDetails.URL).Debug("Authentication on the ABAP system successful") | ||||
| 	uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token") | ||||
| 	cloneConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken | ||||
|   | ||||
| @@ -76,7 +76,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		assert.NoError(t, err, "Did not expect error") | ||||
| 		assert.Equal(t, 0, len(client.BodyList), "Not all requests were done") | ||||
| 	}) | ||||
| @@ -110,7 +110,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Clone of '"+config.RepositoryName+"', branch '"+config.BranchName+"' failed on the ABAP System: Request to ABAP System not successful", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -171,7 +171,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Clone of '/DMO/REPO_A', branch 'branchA', commit 'ABCD1234' failed on the ABAP System", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -207,7 +207,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Clone of '"+config.RepositoryName+"', branch '"+config.BranchName+"' failed on the ABAP System: Request to ABAP System not successful", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -242,7 +242,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Clone of '"+config.RepositoryName+"', branch '"+config.BranchName+"' failed on the ABAP System: Request to ABAP System not successful", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -278,7 +278,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentCloneGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Something failed during the clone: Could not find filename.yaml", err.Error(), "Expected different error message") | ||||
| 		} | ||||
|   | ||||
| @@ -50,6 +50,7 @@ func runAbapEnvironmentCreateSystem(config *abapEnvironmentCreateSystemOptions, | ||||
| 	log.Entry().Debugf("Path: %s", path) | ||||
| 	err = ioutil.WriteFile(path, manifestYAML, 0644) | ||||
| 	if err != nil { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return fmt.Errorf("%s: %w", "Could not generate manifest file for the cloud foundry cli", err) | ||||
| 	} | ||||
|  | ||||
| @@ -74,6 +75,7 @@ func generateManifestYAML(config *abapEnvironmentCreateSystemOptions) ([]byte, e | ||||
| 	if config.AddonDescriptorFileName != "" && config.IncludeAddon { | ||||
| 		descriptor, err := abaputils.ReadAddonDescriptor(config.AddonDescriptorFileName) | ||||
| 		if err != nil { | ||||
| 			log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 			return nil, fmt.Errorf("Cloud not read addonProduct and addonVersion from %s: %w", config.AddonDescriptorFileName, err) | ||||
| 		} | ||||
| 		addonProduct = descriptor.AddonProduct | ||||
| @@ -97,6 +99,7 @@ func generateManifestYAML(config *abapEnvironmentCreateSystemOptions) ([]byte, e | ||||
| 	serviceParametersString := string(serviceParameters) | ||||
| 	log.Entry().Debugf("Service Parameters: %s", serviceParametersString) | ||||
| 	if err != nil { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return nil, fmt.Errorf("Could not generate parameter string for the cloud foundry cli: %w", err) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,7 @@ import ( | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
| func abapEnvironmentPullGitRepo(options abapEnvironmentPullGitRepoOptions, telemetryData *telemetry.CustomData) { | ||||
| func abapEnvironmentPullGitRepo(options abapEnvironmentPullGitRepoOptions, _ *telemetry.CustomData) { | ||||
|  | ||||
| 	// for command execution use Command | ||||
| 	c := command.Command{} | ||||
| @@ -31,13 +31,13 @@ func abapEnvironmentPullGitRepo(options abapEnvironmentPullGitRepoOptions, telem | ||||
| 	client := piperhttp.Client{} | ||||
|  | ||||
| 	// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end | ||||
| 	err := runAbapEnvironmentPullGitRepo(&options, telemetryData, &autils, &client) | ||||
| 	err := runAbapEnvironmentPullGitRepo(&options, &autils, &client) | ||||
| 	if err != nil { | ||||
| 		log.Entry().WithError(err).Fatal("step execution failed") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func runAbapEnvironmentPullGitRepo(options *abapEnvironmentPullGitRepoOptions, telemetryData *telemetry.CustomData, com abaputils.Communication, client piperhttp.Sender) (err error) { | ||||
| func runAbapEnvironmentPullGitRepo(options *abapEnvironmentPullGitRepoOptions, com abaputils.Communication, client piperhttp.Sender) (err error) { | ||||
|  | ||||
| 	subOptions := convertPullConfig(options) | ||||
|  | ||||
| @@ -130,9 +130,6 @@ func triggerPull(repo abaputils.Repository, pullConnectionDetails abaputils.Conn | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	// workaround until golang version 1.16 is used | ||||
| 	time.Sleep(100 * time.Millisecond) | ||||
|  | ||||
| 	log.Entry().WithField("StatusCode", resp.Status).WithField("ABAP Endpoint", pullConnectionDetails.URL).Debug("Authentication on the ABAP system successful") | ||||
| 	uriConnectionDetails.XCsrfToken = resp.Header.Get("X-Csrf-Token") | ||||
| 	pullConnectionDetails.XCsrfToken = uriConnectionDetails.XCsrfToken | ||||
|   | ||||
| @@ -43,7 +43,7 @@ func TestPullStep(t *testing.T) { | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		assert.NoError(t, err, "Did not expect error") | ||||
| 	}) | ||||
|  | ||||
| @@ -67,7 +67,7 @@ func TestPullStep(t *testing.T) { | ||||
| 		} | ||||
|  | ||||
| 		config := abapEnvironmentPullGitRepoOptions{} | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		assert.Equal(t, expectedErrorMessage, err.Error(), "Different error message expected") | ||||
| 	}) | ||||
|  | ||||
| @@ -121,7 +121,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		assert.NoError(t, err) | ||||
| 	}) | ||||
|  | ||||
| @@ -177,7 +177,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Something failed during the pull of the repositories: Pull of '/DMO/REPO_A', commit 'ABCD1234' failed on the ABAP System", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -236,7 +236,7 @@ repositories: | ||||
| 			StatusCode: 200, | ||||
| 		} | ||||
|  | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err := runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		if assert.Error(t, err, "Expected error") { | ||||
| 			assert.Equal(t, "Something failed during the pull of the repositories: Pull of '/DMO/REPO_A' failed on the ABAP System", err.Error(), "Expected different error message") | ||||
| 		} | ||||
| @@ -286,7 +286,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
|  | ||||
| @@ -339,7 +339,7 @@ repositories: | ||||
| 			Password:          "testPassword", | ||||
| 			Repositories:      "repositoriesTest.yml", | ||||
| 		} | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, nil, &autils, client) | ||||
| 		err = runAbapEnvironmentPullGitRepo(&config, &autils, client) | ||||
| 		assert.EqualError(t, err, expectedErrorMessage) | ||||
| 	}) | ||||
| } | ||||
|   | ||||
| @@ -138,6 +138,7 @@ func triggerATCrun(config abapEnvironmentRunATCCheckOptions, details abaputils.C | ||||
|  | ||||
| func buildATCCheckBody(ATCConfig ATCconfig) (checkVariantString string, packageString string, softwareComponentString string, err error) { | ||||
| 	if len(ATCConfig.Objects.Package) == 0 && len(ATCConfig.Objects.SoftwareComponent) == 0 { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return "", "", "", fmt.Errorf("Error while parsing ATC run config. Please provide the packages and/or the software components to be checked! %w", errors.New("No Package or Software Component specified. Please provide either one or both of them")) | ||||
| 	} | ||||
|  | ||||
| @@ -229,6 +230,7 @@ func runATC(requestType string, details abaputils.ConnectionDetailsHTTP, body [] | ||||
|  | ||||
| 	req, err := client.SendRequest(requestType, details.URL, bytes.NewBuffer(body), header, nil) | ||||
| 	if err != nil { | ||||
| 		log.SetErrorCategory(log.ErrorService) | ||||
| 		return req, fmt.Errorf("Triggering ATC run failed: %w", err) | ||||
| 	} | ||||
| 	defer req.Body.Close() | ||||
| @@ -246,6 +248,7 @@ func fetchXcsrfToken(requestType string, details abaputils.ConnectionDetailsHTTP | ||||
| 	header["Accept"] = []string{"application/vnd.sap.atc.run.v1+xml"} | ||||
| 	req, err := client.SendRequest(requestType, details.URL, bytes.NewBuffer(body), header, nil) | ||||
| 	if err != nil { | ||||
| 		log.SetErrorCategory(log.ErrorInfrastructure) | ||||
| 		return "", fmt.Errorf("Fetching Xcsrf-Token failed: %w", err) | ||||
| 	} | ||||
| 	defer req.Body.Close() | ||||
|   | ||||
| @@ -43,6 +43,7 @@ func (abaputils *AbapUtils) GetAbapCommunicationArrangementInfo(options AbapEnvi | ||||
| 		// Host, User and Password are directly provided -> check for host schema (double https) | ||||
| 		match, err := regexp.MatchString(`^(https|HTTPS):\/\/.*`, options.Host) | ||||
| 		if err != nil { | ||||
| 			log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 			return connectionDetails, errors.Wrap(err, "Schema validation for host parameter failed. Check for https.") | ||||
| 		} | ||||
| 		var hostOdataURL = options.Host + oDataURL | ||||
| @@ -56,6 +57,7 @@ func (abaputils *AbapUtils) GetAbapCommunicationArrangementInfo(options AbapEnvi | ||||
| 	} else { | ||||
| 		if options.CfAPIEndpoint == "" || options.CfOrg == "" || options.CfSpace == "" || options.CfServiceInstance == "" || options.CfServiceKeyName == "" { | ||||
| 			var err = errors.New("Parameters missing. Please provide EITHER the Host of the ABAP server OR the Cloud Foundry ApiEndpoint, Organization, Space, Service Instance and a corresponding Service Key for the Communication Scenario SAP_COM_0510") | ||||
| 			log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 			return connectionDetails, err | ||||
| 		} | ||||
| 		// Url, User and Password should be read from a cf service key | ||||
| @@ -99,6 +101,7 @@ func ReadServiceKeyAbapEnvironment(options AbapEnvironmentOptions, c command.Exe | ||||
| 	// parse | ||||
| 	json.Unmarshal([]byte(serviceKeyJSON), &abapServiceKey) | ||||
| 	if abapServiceKey == (AbapServiceKey{}) { | ||||
| 		log.SetErrorCategory(log.ErrorInfrastructure) | ||||
| 		return abapServiceKey, errors.New("Parsing the service key failed. Service key is empty") | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -22,6 +22,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP, | ||||
| 	for { | ||||
| 		var resp, err = GetHTTPResponse("GET", connectionDetails, nil, client) | ||||
| 		if err != nil { | ||||
| 			log.SetErrorCategory(log.ErrorInfrastructure) | ||||
| 			err = HandleHTTPError(resp, err, "Could not pull the Repository / Software Component "+repositoryName, connectionDetails) | ||||
| 			return "", err | ||||
| 		} | ||||
| @@ -37,6 +38,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP, | ||||
|  | ||||
| 		if reflect.DeepEqual(PullEntity{}, body) { | ||||
| 			log.Entry().WithField("StatusCode", resp.Status).WithField("repositoryName", repositoryName).Error("Could not pull the Repository / Software Component") | ||||
| 			log.SetErrorCategory(log.ErrorInfrastructure) | ||||
| 			var err = errors.New("Request to ABAP System not successful") | ||||
| 			return "", err | ||||
| 		} | ||||
| @@ -45,6 +47,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP, | ||||
| 		log.Entry().WithField("StatusCode", resp.Status).Info("Pull Status: " + body.StatusDescription) | ||||
| 		if body.Status != "R" { | ||||
| 			if body.Status == "E" { | ||||
| 				log.SetErrorCategory(log.ErrorUndefined) | ||||
| 				PrintLogs(body, true) | ||||
| 			} else { | ||||
| 				PrintLogs(body, false) | ||||
| @@ -109,18 +112,22 @@ func PrintLogs(entity PullEntity, errorOnSystem bool) { | ||||
| func GetRepositories(config *RepositoriesConfig) ([]Repository, error) { | ||||
| 	var repositories = make([]Repository, 0) | ||||
| 	if reflect.DeepEqual(RepositoriesConfig{}, config) { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return repositories, fmt.Errorf("Failed to read repository configuration: %w", errors.New("Eror in configuration, most likely you have entered empty or wrong configuration values. Please make sure that you have correctly specified them. For more information please read the User documentation")) | ||||
| 	} | ||||
| 	if config.RepositoryName == "" && config.BranchName == "" && config.Repositories == "" && len(config.RepositoryNames) == 0 { | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return repositories, fmt.Errorf("Failed to read repository configuration: %w", errors.New("You have not specified any repository configuration. Please make sure that you have correctly specified it. For more information please read the User documentation")) | ||||
| 	} | ||||
| 	if config.Repositories != "" { | ||||
| 		descriptor, err := ReadAddonDescriptor(config.Repositories) | ||||
| 		if err != nil { | ||||
| 			log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 			return repositories, err | ||||
| 		} | ||||
| 		err = CheckAddonDescriptorForRepositories(descriptor) | ||||
| 		if err != nil { | ||||
| 			log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 			return repositories, fmt.Errorf("Error in config file %v, %w", config.Repositories, err) | ||||
| 		} | ||||
| 		repositories = descriptor.Repositories | ||||
|   | ||||
| @@ -40,6 +40,7 @@ func (cf *CFUtils) ReadServiceKey(options ServiceKeyOptions) (string, error) { | ||||
|  | ||||
| 	if err != nil { | ||||
| 		// error while reading service key | ||||
| 		log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 		return "", fmt.Errorf("Reading service key failed: %w", err) | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user