Skip to content

Commit 3f6ecab

Browse files
committed
squashme: match port type to crd
1 parent c5b20d9 commit 3f6ecab

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

internal/remote/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ type RemoteSessionControllerConfig struct {
5454
Runai runaiConfig.RunaiConfig
5555

5656
// The port the server will listen to
57-
ServerPort int
57+
ServerPort int32
5858

5959
// FakeStart if true, do not start the remote session and print debug information
6060
FakeStart bool
6161

6262
// SessionPort is the port where the remote session is expected to be serving
63-
SessionPort int
63+
SessionPort int32
6464

6565
// SessionURLPath is the URL path for the HTTP readiness probe
6666
SessionURLPath string
@@ -133,9 +133,9 @@ func GetConfig() (cfg RemoteSessionControllerConfig, err error) {
133133
cfg.Firecrest = firecrestConfig.GetConfig()
134134
cfg.Runai = runaiConfig.GetConfig()
135135

136-
cfg.ServerPort = viper.GetInt(serverPortFlag)
136+
cfg.ServerPort = viper.GetInt32(serverPortFlag)
137137
cfg.FakeStart = viper.GetBool(fakeStartFlag)
138-
cfg.SessionPort = viper.GetInt(sessionPortFlag)
138+
cfg.SessionPort = viper.GetInt32(sessionPortFlag)
139139
cfg.SessionURLPath = viper.GetString(sessionURLPathFlag)
140140
cfg.ReadinessProbeType = viper.GetString(readinessProbeTypeFlag)
141141

internal/remote/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestConfigNewFlags(t *testing.T) {
9494
args []string
9595
env map[string]string
9696
wantProbeType string
97-
wantSessionPort int
97+
wantSessionPort int32
9898
wantURLPath string
9999
wantErr bool
100100
}{

internal/remote/server/server_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (m *mockController) Status(ctx context.Context) (models.RemoteSessionState,
2222
func (m *mockController) Start(ctx context.Context) error { return nil }
2323
func (m *mockController) Stop(ctx context.Context) error { return nil }
2424

25-
func getFreePortOrDie() int {
25+
func getFreePortOrDie() int32 {
2626
var a *net.TCPAddr
2727
var err error
2828
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
@@ -34,7 +34,7 @@ func getFreePortOrDie() int {
3434
panic(err)
3535
}
3636
}()
37-
return l.Addr().(*net.TCPAddr).Port
37+
return int32(l.Addr().(*net.TCPAddr).Port)
3838
}
3939
panic(err)
4040
}
@@ -51,13 +51,13 @@ func TestReadyEndpoint(t *testing.T) {
5151

5252
tests := []struct {
5353
name string
54-
makeCfg func(port int) config.RemoteSessionControllerConfig
55-
setupBackend func(port int) (cleanup func())
54+
makeCfg func(port int32) config.RemoteSessionControllerConfig
55+
setupBackend func(port int32) (cleanup func())
5656
wantStatus int
5757
}{
5858
{
5959
name: "none probe returns 200",
60-
makeCfg: func(int) config.RemoteSessionControllerConfig {
60+
makeCfg: func(int32) config.RemoteSessionControllerConfig {
6161
c := baseCfg
6262
c.ReadinessProbeType = string(amaltheadevv1alpha1.None)
6363
return c
@@ -66,13 +66,13 @@ func TestReadyEndpoint(t *testing.T) {
6666
},
6767
{
6868
name: "interactive tcp open port returns 200",
69-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
69+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
7070
c := baseCfg
7171
c.ReadinessProbeType = string(amaltheadevv1alpha1.TCP)
7272
c.SessionPort = port
7373
return c
7474
},
75-
setupBackend: func(port int) func() {
75+
setupBackend: func(port int32) func() {
7676
ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
7777
if err != nil {
7878
panic(err)
@@ -83,7 +83,7 @@ func TestReadyEndpoint(t *testing.T) {
8383
},
8484
{
8585
name: "interactive tcp closed port returns 503",
86-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
86+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
8787
c := baseCfg
8888
c.ReadinessProbeType = string(amaltheadevv1alpha1.TCP)
8989
c.SessionPort = port
@@ -93,14 +93,14 @@ func TestReadyEndpoint(t *testing.T) {
9393
},
9494
{
9595
name: "interactive http serving 200 returns 200",
96-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
96+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
9797
c := baseCfg
9898
c.ReadinessProbeType = string(amaltheadevv1alpha1.HTTP)
9999
c.SessionPort = port
100100
c.SessionURLPath = "/lab"
101101
return c
102102
},
103-
setupBackend: func(port int) func() {
103+
setupBackend: func(port int32) func() {
104104
ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
105105
if err != nil {
106106
panic(err)
@@ -121,14 +121,14 @@ func TestReadyEndpoint(t *testing.T) {
121121
},
122122
{
123123
name: "interactive http redirect 302 returns 200",
124-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
124+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
125125
c := baseCfg
126126
c.ReadinessProbeType = string(amaltheadevv1alpha1.HTTP)
127127
c.SessionPort = port
128128
c.SessionURLPath = "/"
129129
return c
130130
},
131-
setupBackend: func(port int) func() {
131+
setupBackend: func(port int32) func() {
132132
ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
133133
if err != nil {
134134
panic(err)
@@ -145,14 +145,14 @@ func TestReadyEndpoint(t *testing.T) {
145145
},
146146
{
147147
name: "interactive http serving 500 returns 503",
148-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
148+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
149149
c := baseCfg
150150
c.ReadinessProbeType = string(amaltheadevv1alpha1.HTTP)
151151
c.SessionPort = port
152152
c.SessionURLPath = "/"
153153
return c
154154
},
155-
setupBackend: func(port int) func() {
155+
setupBackend: func(port int32) func() {
156156
ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))
157157
if err != nil {
158158
panic(err)
@@ -169,7 +169,7 @@ func TestReadyEndpoint(t *testing.T) {
169169
},
170170
{
171171
name: "interactive http connection refused returns 503",
172-
makeCfg: func(port int) config.RemoteSessionControllerConfig {
172+
makeCfg: func(port int32) config.RemoteSessionControllerConfig {
173173
c := baseCfg
174174
c.ReadinessProbeType = string(amaltheadevv1alpha1.HTTP)
175175
c.SessionPort = port

0 commit comments

Comments
 (0)