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
Prev Previous commit
Next Next commit
udpate based on comments
  • Loading branch information
suchen-sci committed Aug 28, 2023
commit 2ad235c3d79bfbaa78999cae0def84905555e9fb
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ You can also create them using `egctl create httpproxy` command.
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).
this command will create `HTTPServer` `demo` and `Pipeline` `demo-0` which work exactly same to `server-demo` and `pipeline-demo`. See more about [`egctl create httpproxy`](./doc/egctl-cheat-sheet.md#create-httpproxy).

Additionally, we provide a [dashboard](https://cloud.megaease.com) that
streamlines the aforementioned steps, this intuitive tool can help you create,
Expand Down
4 changes: 2 additions & 2 deletions build/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,11 @@ func TestCreateHTTPProxy(t *testing.T) {

output, err := getResource("httpserver")
assert.NoError(err)
assert.True(strings.Contains(output, "http-proxy-test-server"))
assert.True(strings.Contains(output, "http-proxy-test"))

output, err = getResource("pipeline")
assert.NoError(err)
assert.True(strings.Contains(output, "http-proxy-test-pipeline-0"))
assert.True(strings.Contains(output, "http-proxy-test-0"))

testFn := func(p string, expected string) {
req, err := http.NewRequest(http.MethodGet, "http:https://127.0.0.1:10080"+p, nil)
Expand Down
4 changes: 2 additions & 2 deletions cmd/client/commandv2/create/createhttpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ func (o *HTTPProxyOptions) Parse() error {
}

func (o *HTTPProxyOptions) getServerName() string {
return o.Name + "-server"
return o.Name
}

func (o *HTTPProxyOptions) getPipelineName(id int) string {
return fmt.Sprintf("%s-pipeline-%d", o.Name, id)
return fmt.Sprintf("%s-%d", o.Name, id)
}

// Translate translates HTTPProxyOptions to HTTPServerSpec and PipelineSpec.
Expand Down
10 changes: 5 additions & 5 deletions cmd/client/commandv2/create/createhttpproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func TestCreateHTTPProxyOptions(t *testing.T) {
hs, pls := o.Translate()

// meta
assert.Equal("test-server", hs.Name)
assert.Equal("test", hs.Name)
assert.Equal("HTTPServer", hs.Kind)
assert.Equal(uint16(10080), hs.Port)

Expand All @@ -285,17 +285,17 @@ func TestCreateHTTPProxyOptions(t *testing.T) {
assert.Len(hs.Rules, 2)
assert.Equal("foo.com", hs.Rules[0].Host)
assert.Equal(routers.Paths{
{Path: "/barz", Backend: "test-pipeline-0"},
{PathPrefix: "/bar", Backend: "test-pipeline-1"},
{Path: "/barz", Backend: "test-0"},
{PathPrefix: "/bar", Backend: "test-1"},
}, hs.Rules[0].Paths)
assert.Equal(routers.Paths{
{Path: "/bar", Backend: "test-pipeline-2"},
{Path: "/bar", Backend: "test-2"},
}, hs.Rules[1].Paths)

// pipelines
assert.Len(pls, 3)
for i, pl := range pls {
assert.Equal(fmt.Sprintf("test-pipeline-%d", i), pl.Name)
assert.Equal(fmt.Sprintf("test-%d", i), pl.Name)
assert.Equal("Pipeline", pl.Kind)
assert.Len(pl.Filters, 1)
}
Expand Down
10 changes: 5 additions & 5 deletions doc/egctl-cheat-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ egctl create httpproxy demo --port 10080 \
this equals to
```yaml
kind: HTTPServer
name: demo-server
name: demo
port: 10080
https: false
rules:
- paths:
- path: /bar
backend: demo-pipeline-0
backend: demo-0
- path: /foo
backend: demo-pipeline-1
backend: demo-1

---
name: demo-pipeline-0
name: demo-0
kind: Pipeline
filters:
- name: proxy
Expand All @@ -68,7 +68,7 @@ filters:
policy: roundRobin

---
name: demo-pipeline-1
name: demo-1
kind: Pipeline
filters:
- name: proxy
Expand Down
Loading