-
Notifications
You must be signed in to change notification settings - Fork 9
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
atlasexec: expose atlas exit code #22
Conversation
atlasexec/atlas_test.go
Outdated
require.NoError(t, err) | ||
require.ErrorContains(t, err, "atlas command exited with 1") |
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.
This is suspicions. No error before -> now there is an error. Are you sure this is correct?
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.
Yes, there was a branch in the code that was hiding it (inside runCommand)
We don't want to expose it as an error in MigrateLint for backwards compatibility, but MigrateLintError is new and it's the only way we can tell that the lint failed when running in CI
atlasexec/atlas.go
Outdated
ok := errors.As(err, &cliErr) | ||
if ok && cliErr.hasLintErrors() { | ||
r = strings.NewReader(cliErr.detail) | ||
err = nil | ||
} |
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.
if cliErr := (cliError{}); errors.As(err, &cliErr) && cliErr.summary == "" { | ||
r = strings.NewReader(cliErr.detail) | ||
} | ||
if params.Writer != nil { | ||
_, err = io.Copy(params.Writer, r) | ||
if params.Writer != nil && r != nil { | ||
if _, ioErr := io.Copy(params.Writer, r); ioErr != nil { | ||
err = errors.Join(err, ioErr) | ||
} | ||
} |
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.
cliError
can have stdout and stderr. These summary/details are confusing.
Then, in the linting code, copy stdout to the writer, and return the error.
return jsonDecode[SummaryReport](r, err) | ||
} | ||
|
||
// MigrateLintError runs the 'migrate lint' command, the output is written to params.Writer | ||
func (c *Client) MigrateLintError(ctx context.Context, params *MigrateLintParams) error { | ||
r, err := c.runCommand(ctx, lintArgs(params)) | ||
if err != nil { | ||
return err | ||
if cliErr := (cliError{}); errors.As(err, &cliErr) && cliErr.summary == "" { |
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.
Not sure if the () are needed.
@rotemtam I'm afraid that this change introduces backwards incompatible changes, let's discuss verbally please |
This is part of a multi stage change
atlas-action