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

add egctl edit, egctl logs, update egctl create cmd #1067

Merged
merged 15 commits into from
Aug 31, 2023

Conversation

suchen-sci
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2023

Codecov Report

Patch coverage: 83.00% and project coverage change: -0.07% ⚠️

Comparison is base (fbb4f90) 81.47% compared to head (2ad235c) 81.41%.
Report is 3 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1067      +/-   ##
==========================================
- Coverage   81.47%   81.41%   -0.07%     
==========================================
  Files         136      141       +5     
  Lines       15404    15710     +306     
==========================================
+ Hits        12551    12790     +239     
- Misses       2276     2331      +55     
- Partials      577      589      +12     
Files Changed Coverage Δ
cmd/client/commandv2/create/create.go 37.14% <37.14%> (ø)
cmd/client/commandv2/create/createhttpproxy.go 87.23% <87.23%> (ø)
cmd/builder/utils/context.go 100.00% <100.00%> (ø)
cmd/builder/utils/env.go 100.00% <100.00%> (ø)
cmd/builder/utils/validation.go 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

var sb strings.Builder
sb.Grow(len(yamlBody))
for _, l := range lines {
if strings.HasPrefix(l, "name: ") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if strings.HasPrefix(l, "name: ") {
if strings.HasPrefix(l, "name:") {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

cmd/client/resources/object.go Show resolved Hide resolved
cmd/client/resources/object.go Show resolved Hide resolved
@suchen-sci suchen-sci marked this pull request as draft August 21, 2023 04:27
@suchen-sci suchen-sci changed the title add egctl edit command add egctl edit, egctl logs, update egctl create cmd Aug 24, 2023
@suchen-sci suchen-sci marked this pull request as ready for review August 25, 2023 10:04
README.md Outdated
Comment on lines 260 to 266
You can also create them using `egctl create httpproxy` command.
```bash
egctl create httpproxy demo --port 10080 \
--rule="/pipeline=http:https://127.0.0.1:9095,http:https://127.0.0.1:9096,http:https://127.0.0.1:9097"
```
this command will create `HTTPServer` `demo-server` and `Pipeline` `demo-pipeline-0` which work exactly same to `server-demo` and `pipeline-demo`. See more about [`egctl create httpproxy`](./doc/egctl-cheat-sheet.md#create-httpproxy).

Copy link
Collaborator

Choose a reason for hiding this comment

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

propose not adding -server suffix to the name, user may get confused what he/she has created.
for the pipeline names, also propose not using the pipeline-x suffixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. I will update that!

cmd.Flags().BoolVar(&o.TLS, "tls", false, "Enable TLS")
cmd.Flags().BoolVar(&o.AutoCert, "auto-cert", false, "Enable auto cert")
cmd.Flags().StringVar(&o.CaCertFile, "ca-cert-file", "", "CA cert file")
cmd.Flags().StringArrayVar(&o.CertFiles, "cert-file", []string{}, "Cert file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Cert Files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It use as --cert-file filename1 --cert-file filename2... If use --cert-files it feels more like --cert-files filename1,filename2,filename3, and it should use cmd.Flags().StringSliceVar. But it may cause some problem, since filename may itself contains ,.
Is this ok?

cmd.Flags().BoolVar(&o.AutoCert, "auto-cert", false, "Enable auto cert")
cmd.Flags().StringVar(&o.CaCertFile, "ca-cert-file", "", "CA cert file")
cmd.Flags().StringArrayVar(&o.CertFiles, "cert-file", []string{}, "Cert file")
cmd.Flags().StringArrayVar(&o.KeyFiles, "key-file", []string{}, "Key file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Key Files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as --cert-file part...

var n int
var follow bool
examples := []general.Example{
{Desc: "Print the most recent 500 logs by default.", Command: "egctl logs"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not print all logs like other logs by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Here are my concerns.

  1. kubectl logs will print help information. If print logs kubectl logs <pod-name>. And actually egctl create, egctl apply will print help information. So, based on this, user may think egctl logs will print help information. They may think there are commands like egctl logs std or egctl logs http-access etc. So, by default, I choose egctl logs not print all logs, just a few.
  2. easegress logs can be really really long. So print all logs may be not necessary...

Just my naive opinions, I am ok to change it to print all logs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know another command line to do like this, does this usage have a precedent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I am not sure these cases are precedent. But for really long logs, these tools not print them all by default.

  • git log only show a screen of logs, and allow scroll it.
  • journalctl, systemctl status is similar.

Copy link
Contributor

Choose a reason for hiding this comment

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

git log | cat will output all of them with cat to dismantle the pager effect. It just uses a pager to display logs, essentially it prints all of the logs. But egctl logs | cat outputs the last 500 lines. Well, I just provided another thought as I don't strongly insist on my point. You can decide on the design.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I am just a little afraid that in practice, when user run egctl logs, and terminal starts to print logs, then they press CTRL+C... (It happens to me all the time).
I am more prefer current design that provides a user-friendly default setting...

Copy link
Contributor

Choose a reason for hiding this comment

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

Then it is.

// EditCmd returns edit command.
func EditCmd() *cobra.Command {
examples := []general.Example{
{Desc: "Edit a resource with name", Command: "egctl edit <resource> <name>"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we specify editor like vim, nano.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in egctl-cheat-sheet.md, mentioned use of env variable of EGCTL_EDITOR to change editor. I will add an example about that in examples.

@xxx7xxxx xxx7xxxx added this pull request to the merge queue Aug 31, 2023
Merged via the queue into easegress-io:main with commit 8f2dc59 Aug 31, 2023
7 checks passed
@suchen-sci suchen-sci deleted the egctl-edit branch August 31, 2023 03:26
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.

None yet

4 participants