-
Notifications
You must be signed in to change notification settings - Fork 492
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
Enhance egctl #1020
Enhance egctl #1020
Conversation
Codecov ReportPatch coverage:
❗ 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 #1020 +/- ##
==========================================
- Coverage 81.69% 81.60% -0.10%
==========================================
Files 135 135
Lines 15044 15104 +60
==========================================
+ Hits 12290 12325 +35
- Misses 2197 2222 +25
Partials 557 557
☔ View full report in Codecov by Sentry. |
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.
-
please also fix github action warnings.
-
general
,common
,utils
are all too general names, it is hard to guess their usages.
doc/egctl-cheat-sheet.md
Outdated
# egctl Cheat Sheet | ||
|
||
## Creating resources | ||
Easegress manifests are defined in YAML. The file extension .yaml and .yml be used. Use `egctl create`, or `egctl apply` to create resources. Use `egctl api-resources` to view all available resources and their supported actions. |
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.
please use chatgpt to improve this file.
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.
all updated, please check!
pkg/api/customdata.go
Outdated
kinds, err := s.cds.ListKinds() | ||
if err != nil { | ||
ClusterPanic(err) | ||
} | ||
|
||
for _, k := range kinds { | ||
err = s.cds.DeleteKind(k.Name) | ||
if err != nil { | ||
ClusterPanic(err) | ||
} |
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 could be done via one etcd request, no need list and loops.
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 idea, i will update it now
// Output table: | ||
// NAME ROLE AGE STATE API-ADDR HEARTBEAT | ||
table := [][]string{} | ||
table = append(table, []string{"NAME", "ROLE", "AGE", "STATE", "API-ADDR", "HEARTBEAT"}) |
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.
"API ADDR" would be better (via k8s), and all other fields with multiple words.
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.
Thanks for your advice. I check several k8s commands, I find some of them use seperate words(pod), some of them use "-" to connect words(node, deployment, svc). I am prefer "API-ADDR" over "API ADDR" because "API-ADDR" feel more like one word, and "API ADDR" feel more like two words. And when print table in terminal, sometimes two columns really close to each other, "API-ADDR" may feels better. So, it that ok to keep "API-ADDR"?
cd:➜ ~ |>k get svc -o wide | grep NAME [~]
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
cd:➜ ~ |>k get po -o wide | grep NAME [~]
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
cd:➜ ~ |>k get deploy -o wide | grep NAME [~]
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
cd:➜ ~ |>k get node -o wide | grep NAME [~]
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
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.
Sure
README.md
Outdated
@@ -224,7 +229,7 @@ https: false | |||
rules: | |||
- paths: | |||
- pathPrefix: /pipeline | |||
backend: pipeline-demo' | egctl object create | |||
backend: pipeline-demo' | egctl create |
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.
I was thinking if we should use more idiomatic egctl create|apply -f -
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 idea, i will update it now
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.
I saw your demo not showing this usage, is it supported now?
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, user can create
and apply
resoruce from yaml
file or stdin.
➜ easegress git:(enhance-egctl) ✗ cat httpserver.yaml | egctl create
create HTTPServer httpserver successfully
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.
I thought you will support egctl create -f -
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.
Sorry for misunderstanding... Let me update it.
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.
Updated, now egctl create -f -
and egctl apply -f -
is supported. egctl create/apply
will print the help text. I also update related ducoments. Please check again.
➜ cat httpserver.yaml | egctl create -f -
create HTTPServer httpserver successfully
➜ cat httpserver.yaml | egctl apply -f -
update HTTPServer httpserver successfully
➜ egctl create
Error: yaml file is required
Usage:
...
Examples:
...
...
Error: yaml file is required
resp, body := doRequestV1(httpMethod, url, jsonBody, client, cmd) | ||
|
||
msg := string(body) | ||
if strings.HasPrefix(url, general.HTTPProtocol) && resp.StatusCode == http.StatusBadRequest && strings.Contains(strings.ToUpper(msg), "HTTPS") { |
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.
Server returns 400 if the protocol is wrong?
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.
Here I actually reuse previous logic about updating protocol part. And I just do a test about it to make sure. The answer is yes. Golang http lib will return 400 if the protocol is wrong.
➜ easegress git:(enhance-egctl) ✗ curl http:https://localhost:2381/apis/v2 -v
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 2381 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 2381 (#0)
> GET /apis/v2 HTTP/1.1
> Host: localhost:2381
> User-Agent: curl/7.64.1
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad Request
<
Client sent an HTTP request to an HTTPS server.
* Closing connection 0
cmd/client/general/config.go
Outdated
return "", err | ||
} | ||
|
||
return path.Join(homeDir, ".egctlconfig"), 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.
.egctlrc
would be more idiomatic
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.
all updated, please check!
@@ -15,6 +15,7 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
// Package commandv2 provides the new version of commands. |
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.
add comment to one file of a package could resolve the github action warning, no need to add the comment to all files.
however, as the comments have been added, it is ok to leave them there.
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.
got it!
* finish get command and refactor code * finish describe object * finish all describe * finish create, delete, update * finish other command * add example framework * add more examples, add other missing commands * add command for object status * udpate egctl command * update * add comments * add more comments, add egctl cheat sheet * update egctl cheat sheet * fix random test bug * update based on comment * rewrite apply create get command * finish describe, delete and refactor code * update examples * fix typo * add security for egctl * update doc * refactor code structure * update based on code review comments * update based on github action * update based on github action * update based on github action * update based on github action * update based on github action * update based on github action * support egctl create/apply -f -
No description provided.