-
Notifications
You must be signed in to change notification settings - Fork 950
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 <yaozengzeng@zju.edu.cn>
- Loading branch information
1 parent
7d8d6fc
commit fb10eab
Showing
17 changed files
with
328 additions
and
75 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,37 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_extractPortFromAddresses(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args []string | ||
want string | ||
}{ | ||
{ | ||
name: "listening addresses are nil", | ||
args: nil, | ||
want: "", | ||
}, | ||
{ | ||
name: "listening addresses have no tcp address", | ||
args: []string{"unix:///var/run/pouchd.sock"}, | ||
want: "", | ||
}, | ||
{ | ||
name: "listening addresses have valid address", | ||
args: []string{"unix:///var/run/pouchd.sock", "tcp://0.0.0.0:4345"}, | ||
want: "4345", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := extractPortFromAddresses(tt.args) | ||
if got != tt.want { | ||
t.Errorf("extractPortFromAddresses() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.