forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make CRI Stream Server share port(http server) with pouchd
Signed-off-by: YaoZengzeng <[email protected]>
- Loading branch information
1 parent
7d8d6fc
commit e5914d5
Showing
17 changed files
with
369 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package stream | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
// Router exports a set of CRI Stream Server's handlers. | ||
// We could reuse the pouchd's http server to handle | ||
// the Stream Server's requests, so pouchd only has to | ||
// export one port. | ||
type Router interface { | ||
ServeExec(w http.ResponseWriter, r *http.Request) | ||
ServeAttach(w http.ResponseWriter, r *http.Request) | ||
ServePortForward(w http.ResponseWriter, r *http.Request) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_extractIPAndPortFromAddresses(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args []string | ||
wantIP string | ||
wantPort string | ||
}{ | ||
{ | ||
name: "listening addresses are nil", | ||
args: nil, | ||
wantIP: "", | ||
wantPort: "", | ||
}, | ||
{ | ||
name: "listening addresses have no tcp address", | ||
args: []string{"unix:///var/run/pouchd.sock"}, | ||
wantIP: "", | ||
wantPort: "", | ||
}, | ||
{ | ||
name: "listening addresses have valid address", | ||
args: []string{"unix:///var/run/pouchd.sock", "tcp://0.0.0.0:4345"}, | ||
wantIP: "0.0.0.0", | ||
wantPort: "4345", | ||
}, | ||
{ | ||
name: "listening addresses have two tcp addresses", | ||
args: []string{"tcp://10.10.10.10:1234", "tcp://0.0.0.0:4345"}, | ||
wantIP: "10.10.10.10", | ||
wantPort: "1234", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotIP, gotPort := extractIPAndPortFromAddresses(tt.args) | ||
if gotIP != tt.wantIP { | ||
t.Errorf("extractIPAndPortFromAddresses() IP = %v, want IP %v", gotIP, tt.wantIP) | ||
} | ||
if gotPort != tt.wantPort { | ||
t.Errorf("extractIPAndPortFromAddresses() Port = %v, want Port %v", gotPort, tt.wantPort) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.