mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
Reverts refactoring method
This commit is contained in:
parent
a75281c88c
commit
040a18f928
@ -120,9 +120,14 @@ func runGitopsUpdateDeployment(config *gitopsUpdateDeploymentOptions, command gi
|
||||
return errors.New("deploy tool " + config.DeployTool + " is not supported")
|
||||
}
|
||||
|
||||
commit, err := saveChanges(config, err, fileUtils, filePath, outputBytes, gitUtils)
|
||||
err = fileUtils.FileWrite(filePath, outputBytes, 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "changes could not get saved")
|
||||
return errors.Wrap(err, "failed to write file")
|
||||
}
|
||||
|
||||
commit, err := commitAndPushChanges(config, gitUtils)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to commit and push changes")
|
||||
}
|
||||
|
||||
log.Entry().Infof("Changes committed with %s", commit.String())
|
||||
@ -130,19 +135,6 @@ func runGitopsUpdateDeployment(config *gitopsUpdateDeploymentOptions, command gi
|
||||
return nil
|
||||
}
|
||||
|
||||
func saveChanges(config *gitopsUpdateDeploymentOptions, err error, fileUtils gitopsUpdateDeploymentFileUtils, filePath string, outputBytes []byte, gitUtils iGitopsUpdateDeploymentGitUtils) (plumbing.Hash, error) {
|
||||
err = fileUtils.FileWrite(filePath, outputBytes, 0755)
|
||||
if err != nil {
|
||||
return plumbing.Hash{}, errors.Wrap(err, "failed to write file")
|
||||
}
|
||||
|
||||
commit, err := commitAndPushChanges(config, gitUtils)
|
||||
if err != nil {
|
||||
return plumbing.Hash{}, errors.Wrap(err, "failed to commit and push changes")
|
||||
}
|
||||
return commit, nil
|
||||
}
|
||||
|
||||
func executeKubectl(config *gitopsUpdateDeploymentOptions, command gitopsUpdateDeploymentExecRunner, outputBytes []byte, filePath string) ([]byte, error) {
|
||||
registryImage, err := buildRegistryPlusImage(config)
|
||||
if err != nil {
|
||||
|
@ -136,14 +136,14 @@ func TestRunGitopsUpdateDeploymentWithKubectl(t *testing.T) {
|
||||
gitUtils := &gitUtilsMock{failOnCommit: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, gitUtils, filesMock{})
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to commit and push changes: committing changes failed: error on commit")
|
||||
assert.EqualError(t, err, "failed to commit and push changes: committing changes failed: error on commit")
|
||||
})
|
||||
|
||||
t.Run("error on push commits", func(t *testing.T) {
|
||||
gitUtils := &gitUtilsMock{failOnPush: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, gitUtils, filesMock{})
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to commit and push changes: pushing changes failed: error on push")
|
||||
assert.EqualError(t, err, "failed to commit and push changes: pushing changes failed: error on push")
|
||||
})
|
||||
|
||||
t.Run("error on get working directory", func(t *testing.T) {
|
||||
@ -164,7 +164,7 @@ func TestRunGitopsUpdateDeploymentWithKubectl(t *testing.T) {
|
||||
fileUtils := filesMock{failOnWrite: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, &gitUtilsMock{}, fileUtils)
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to write file: error appeared")
|
||||
assert.EqualError(t, err, "failed to write file: error appeared")
|
||||
})
|
||||
|
||||
t.Run("error on temp dir deletion", func(t *testing.T) {
|
||||
@ -291,14 +291,14 @@ func TestRunGitopsUpdateDeploymentWithHelm(t *testing.T) {
|
||||
gitUtils := &gitUtilsMock{failOnCommit: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, gitUtils, filesMock{})
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to commit and push changes: committing changes failed: error on commit")
|
||||
assert.EqualError(t, err, "failed to commit and push changes: committing changes failed: error on commit")
|
||||
})
|
||||
|
||||
t.Run("error on push commits", func(t *testing.T) {
|
||||
gitUtils := &gitUtilsMock{failOnPush: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, gitUtils, filesMock{})
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to commit and push changes: pushing changes failed: error on push")
|
||||
assert.EqualError(t, err, "failed to commit and push changes: pushing changes failed: error on push")
|
||||
})
|
||||
|
||||
t.Run("error on get working directory", func(t *testing.T) {
|
||||
@ -319,7 +319,7 @@ func TestRunGitopsUpdateDeploymentWithHelm(t *testing.T) {
|
||||
fileUtils := filesMock{failOnWrite: true}
|
||||
|
||||
err := runGitopsUpdateDeployment(validConfiguration, &gitOpsExecRunnerMock{}, &gitUtilsMock{}, fileUtils)
|
||||
assert.EqualError(t, err, "changes could not get saved: failed to write file: error appeared")
|
||||
assert.EqualError(t, err, "failed to write file: error appeared")
|
||||
})
|
||||
|
||||
t.Run("error on temp dir deletion", func(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user