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

Support write to local file instead of post on github #654

Merged
merged 13 commits into from Feb 15, 2023
Merged

Support write to local file instead of post on github #654

merged 13 commits into from Feb 15, 2023

Conversation

NikitaCOEUR
Copy link
Contributor

#194

Why

I have also the requirement to obtain the results of the Terraform plan/apply parsed and nicely formatted by tfcmt. So I am trying (for the first time) to contribute to this enhancement with my proposal.
The old method is still fully functional, I have just added a new parameter "output" to specify a file to write the result to.

To use it :

Simply use it same way before but now we can do this :

plan

tfcmt --output plan.md plan -- terraform plan -no-color

image

apply

tfcmt --output apply.md apply-- terraform apply-no-color

image


I attempted to preserve the essence of what I saw in the code.
I hope it will be useful and accurate... Don't hesitate to provide feedback as this is my first time working with Go.

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Feb 14, 2023
@suzuki-shunsuke
Copy link
Owner

Thank you for your contribution!

Copy link
Owner

@suzuki-shunsuke suzuki-shunsuke left a comment

Choose a reason for hiding this comment

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

The package name localFile isn't good.

https://go.dev/blog/package-names

They are lower case, with no under_scores or mixedCaps.

Copy link
Owner

@suzuki-shunsuke suzuki-shunsuke left a comment

Choose a reason for hiding this comment

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

It isn't bad to implement Notifier for local file, but I wonder if there is better approach. 🤔
Maintaining both github and local file isn't desirable.

NikitaCOEUR and others added 4 commits February 14, 2023 14:26
force output_file to be explicitly used by command line argument.

Co-authored-by: Shunsuke Suzuki <suzuki-shunsuke@users.noreply.github.com>
Co-authored-by: Shunsuke Suzuki <suzuki-shunsuke@users.noreply.github.com>
@NikitaCOEUR
Copy link
Contributor Author

It isn't bad to implement Notifier for local file, but I wonder if there is better approach. 🤔 Maintaining both github and local file isn't desirable.

I also wondered about it, but I wanted to reuse as much existing code as possible without having to refactor everything. In the "controller.go" file, we return "client.Notify", so I wanted to keep that intact. That's why I decided to create a new notifier. Do you have a better suggestion?

@suzuki-shunsuke
Copy link
Owner

It isn't bad to implement Notifier for local file, but I wonder if there is better approach. 🤔 Maintaining both github and local file isn't desirable.

I also wondered about it, but I wanted to reuse as much existing code as possible without having to refactor everything. In the "controller.go" file, we return "client.Notify", so I wanted to keep that intact. That's why I decided to create a new notifier. Do you have a better suggestion?

I see. Thank you for your explanation. As you said, we shouldn't change existing code as much as possible in this pull request.
We can refactor after merging this pull request.

@suzuki-shunsuke
Copy link
Owner

@NikitaCOEUR
Copy link
Contributor Author

Please fix CI. https://github.com/suzuki-shunsuke/tfcmt/actions/runs/4174408268/jobs/7228404508

I'm on it.

@NikitaCOEUR
Copy link
Contributor Author

Using underscores in package names is not allowed, so I renamed "local_file" to "tofile". I find "tofile" to be a more preferable name than "localfile". What is your opinion on this?

@suzuki-shunsuke
Copy link
Owner

I prefer localfile than tofile because localfile is more consistent with the Notifier package github.

@suzuki-shunsuke
Copy link
Owner

I'm not sure why GitHub Actions wasn't triggered. 🤔
I couldn't approve the workflow run in UI.

image

@NikitaCOEUR
Copy link
Contributor Author

Uh... Maybe my force push ? I've amended a commit yesterday.

@NikitaCOEUR
Copy link
Contributor Author

Have you try it via actions tab ?

@suzuki-shunsuke
Copy link
Owner

I added a commit, then I can approve and run.

image

Copy link
Owner

@suzuki-shunsuke suzuki-shunsuke left a comment

Choose a reason for hiding this comment

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

Thanks!

@suzuki-shunsuke suzuki-shunsuke merged commit ac8092e into suzuki-shunsuke:main Feb 15, 2023
@suzuki-shunsuke suzuki-shunsuke added this to the v4.2.0 milestone Feb 15, 2023
@NikitaCOEUR NikitaCOEUR deleted the permit-output-to-localFile-instead-of-post-on-github branch February 16, 2023 08:31
@suzuki-shunsuke
Copy link
Owner

#194 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants