-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor buildpack output #157
base: main
Are you sure you want to change the base?
Conversation
5ff9921
to
99ae2fb
Compare
99bda9e
to
8a69593
Compare
Note: The test is updated as `BuildpackOutputTextSection::Command` doesn't currently wrap the command in backticks
This also drops the fun_run dependency, and produces more accurate output (e.g. by not escaping command parameters unnecessarily)
1354344
to
6a49988
Compare
Adds backticks to command and URL values, and command output is now indented with 6 space characters
6a49988
to
4cad9ea
Compare
@@ -98,7 +98,7 @@ fn test_dotnet_publish_with_global_json_and_custom_verbosity_level() { | |||
&formatdoc! {r#" | |||
- Publish solution | |||
- Using `Release` build configuration | |||
- Running dotnet publish /workspace/foo.csproj --runtime {rid} "-p:PublishDir=bin/publish" --verbosity normal | |||
- Running dotnet publish /workspace/foo.csproj --runtime {rid} -p:PublishDir=bin/publish --verbosity normal |
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.
Seems like a bug in fun-run. I filed the first ever issue on the repo! schneems/fun_run#13
Also I think there be backticks around the command i.e.
Running `dotnet publish /workspace/foo.csproj --runtime {rid} -p:PublishDir=bin/publish --verbosity normal`
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.
Huh I thought it was intentional :) I believe it's the regex here that causes the -p:PublishDir=bin/publish
argument to be quoted -- and more specifically the =
character.
If this should be allowed, maybe the regex needs to be updated to something like ([^A-Za-z0-9_\-.,:=/@\n])
? Not sure it's a bug though.
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.
Also, yes there should be backticks around the command - and there is (since 4cad9ea which included this change).
You're commenting on an old commit :)
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.
We can close this conversation, it's more an FYI than a blocker
The regex was a "works for now" solution and as they say...there's no such thing as a temporary fix. I just hadn't hit any situations where it didn't give me what I wanted.
FWIW if you still want to use something like https://docs.rs/bullet_stream/0.5.0/bullet_stream/global/print/fn.sub_stream_cmd.html (or the CmdError
enum), a core feature of fun_run is the ability to re-name commands, I would still like to investigate and fix this upstream, but if you ever need an escape valve like for just one function you can always BYO naming, via named
or named_fn
like:
sub_stream_cmd(cmd.named_fn(command_to_string));
result.push_str(&arg.to_string_lossy()); | ||
} | ||
result | ||
} |
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.
The current output won't produce entirely valid copy/pasteable commands (which is the goal, so users can run them locally and debug/reproduce) in the event that one of the args has a space in it i.e. if someone's path to their cs proj has a space
dotnet publish /workspace/path to a/Foo.csproj
Will be interpreted as dotnet publish /workspace/path
rather than dotnet publish " /workspace/path to a/Foo.csproj"
or /workspace/path\ to\ a/Foo.csproj
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.
Good catch! Fixed in ed3b93e
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.
Hmm...this commit added quotes back in:
dotnet publish /workspace/foo.csproj --runtime {rid} '-p:PublishDir=bin/publish' --verbosity normal
While you're poking at alternative interfaces, this is another one https://docs.rs/bullet_stream/0.5.0/bullet_stream/global/print/index.html |
@schneems I did see that change and it looks interesting for sure, but the interface itself isn't the reason I'm looking to refactor the output implementation here. The primary reason is that I want to be able print output in different styles (e.g. both our CNB style and the classic buildpack style) so I don't have to reformat the CNB output in the classic buildpack. This PR currently uses the code from the JVM buildpack PR, but that has mostly been to help test that implementation, and verify the implementation of the I figured it's a bit out of scope for both the shared JVM |
ed3b93e
to
068c114
Compare
I would like to pave a path towards deprecating and ending maintenance of my classic buildpack, even if that horizon is 2+ years, even if Classic never goes away. From that angle, I don't think that supporting output for a classic buildpack is entirely out of scope. I'm not sure where the boundry should be though, nor am I entirely aware of the UI/UX problems faced in running a CNB buildpack alongside of classic. I don't think there's much consistency, rhyme or reason with between the One way to hack around indentation could be by providing a writer that added indentation, something like: if is_classic() {
let writer = libcnb::line_mapped(&mut std::io::stderr(), |line| format!(" {line}"))
bullet_stream::global::set_writer(writer);
}
let mut log = Print::global().h2("Heroku .NET Buildpack"); |
No description provided.