Skip to content
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

plan and apply terraform commands error outputs printed after a new line Fixes #121 #132

Merged
merged 3 commits into from
Aug 24, 2017

Conversation

anubhavmishra
Copy link
Collaborator

No description provided.

@@ -63,7 +63,7 @@ func (c *Client) RunCommandWithVersion(log *logging.SimpleLogger, path string, a
out, err := terraformCmd.CombinedOutput()
commandStr := strings.Join(terraformCmd.Args, " ")
if err != nil {
err := fmt.Errorf("%s: running %q in %q: %s", err, commandStr, path, out)
err := fmt.Errorf("%s: running %q in %q: \n%s", err, commandStr, path, out)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in plan executor

	output, err := p.terraform.RunCommandWithVersion(ctx.Log, filepath.Join(repoDir, project.Path), tfPlanCmd, terraformVersion)
	if err != nil {
		// plan failed so unlock the state
		if _, err := p.lockingClient.Unlock(lockAttempt.LockKey); err != nil {
			ctx.Log.Err("error unlocking state: %v", err)
		}
		return ProjectResult{Error: fmt.Errorf("%s\n%s", err.Error(), output)}
	}

it uses the output result.

Same as in apply

	output, err := a.terraform.RunCommandWithVersion(ctx.Log, absolutePath, tfApplyCmd, terraformVersion)
	if err != nil {
		return ProjectResult{Error: fmt.Errorf("%s\n%s", err.Error(), output)}
	}

So we could return the output instead of just the err. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you mean for the ProjectResult return something like this:

return ProjectResult{Error: fmt.Errorf("%s", output)}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no that code is fine, I just mean from terraform_client return the output and err, right now it does return "", err

Copy link
Collaborator Author

@anubhavmishra anubhavmishra Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right. yea that makes sense to me.

@anubhavmishra anubhavmishra merged commit 078dbb0 into master Aug 24, 2017
@anubhavmishra anubhavmishra deleted the fix-error-output branch August 24, 2017 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants