-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No "global" exec runner instance inside cloudfoundry pkg #1771
Merged
marcusholl
merged 2 commits into
SAP:master
from
marcusholl:pr/noGlobalExecRunnerInstanceInCloudfoundryPkg
Jul 10, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,21 @@ import ( | |
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/SAP/jenkins-library/pkg/command" | ||
"github.com/SAP/jenkins-library/pkg/log" | ||
"strings" | ||
) | ||
|
||
//ReadServiceKeyAbapEnvironment from Cloud Foundry and returns it. | ||
//Depending on user/developer requirements if he wants to perform further Cloud Foundry actions the cfLogoutOption parameters gives the option to logout after reading ABAP communication arrangement or not. | ||
func ReadServiceKeyAbapEnvironment(options ServiceKeyOptions, cfLogoutOption bool) (ServiceKey, error) { | ||
func (cf *CFUtils) ReadServiceKeyAbapEnvironment(options ServiceKeyOptions, cfLogoutOption bool) (ServiceKey, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method |
||
|
||
_c := cf.Exec | ||
|
||
if _c == nil { | ||
_c = &command.Command{} | ||
} | ||
|
||
var abapServiceKey ServiceKey | ||
var err error | ||
|
||
|
@@ -25,16 +32,16 @@ func ReadServiceKeyAbapEnvironment(options ServiceKeyOptions, cfLogoutOption boo | |
Password: options.Password, | ||
} | ||
|
||
err = Login(config) | ||
err = cf.Login(config) | ||
var serviceKeyBytes bytes.Buffer | ||
c.Stdout(&serviceKeyBytes) | ||
_c.Stdout(&serviceKeyBytes) | ||
if err == nil { | ||
//Reading Service Key | ||
log.Entry().WithField("cfServiceInstance", options.CfServiceInstance).WithField("cfServiceKey", options.CfServiceKey).Info("Read service key for service instance") | ||
|
||
cfReadServiceKeyScript := []string{"service-key", options.CfServiceInstance, options.CfServiceKey} | ||
|
||
err = c.RunExecutable("cf", cfReadServiceKeyScript...) | ||
err = _c.RunExecutable("cf", cfReadServiceKeyScript...) | ||
} | ||
if err == nil { | ||
var serviceKeyJSON string | ||
|
@@ -54,7 +61,7 @@ func ReadServiceKeyAbapEnvironment(options ServiceKeyOptions, cfLogoutOption boo | |
if err != nil { | ||
if cfLogoutOption == true { | ||
var logoutErr error | ||
logoutErr = Logout() | ||
logoutErr = cf.Logout() | ||
if logoutErr != nil { | ||
return abapServiceKey, fmt.Errorf("Failed to Logout of Cloud Foundry: %w", err) | ||
} | ||
|
@@ -65,7 +72,7 @@ func ReadServiceKeyAbapEnvironment(options ServiceKeyOptions, cfLogoutOption boo | |
//Logging out of CF | ||
if cfLogoutOption == true { | ||
var logoutErr error | ||
logoutErr = Logout() | ||
logoutErr = cf.Logout() | ||
if logoutErr != nil { | ||
return abapServiceKey, fmt.Errorf("Failed to Logout of Cloud Foundry: %w", err) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make
stdout
inmutable for LoginCheck function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I already spottet that too. We have to reset the old stdout afterwards. But at the moment it is not possible to retrieve the current stdout via our wrapper. Needs to be added. At least the underlying cmd allow to get the currently set stream(s).
The point is: we have to ensure that the "cmdRunner" is not permanently changed inside the func. I had this already. As a result logging output stopped after calling login. Of course also for the subsequent
cf deploy
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to finalize on discussion in #1760 . This probably solves this whole problem and we can leave the whole function out