Skip to content

Commit 9df2ee7

Browse files
committed
Always use auth token
For some reason inlets now requires a non-empty auth token to work. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 6649e64 commit 9df2ee7

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cmd/kfwd.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,18 @@ func runKfwd(cmd *cobra.Command, _ []string) error {
7373

7474
fmt.Println(upstream, "=", port)
7575

76-
deployment := makeDeployment(eth, port, upstream, ns)
76+
inletsToken, passwordErr := generateAuth()
77+
if passwordErr != nil {
78+
return passwordErr
79+
}
80+
81+
deployment := makeDeployment(eth, port, upstream, ns, inletsToken)
7782
tmpPath := path.Join(os.TempDir(), "inlets-"+upstream+".yaml")
78-
ioutil.WriteFile(tmpPath, []byte(deployment), 0600)
83+
err = ioutil.WriteFile(tmpPath, []byte(deployment), 0600)
84+
if err != nil {
85+
return err
86+
}
87+
fmt.Printf("%s written.\n", tmpPath)
7988

8089
task := v1.ExecTask{
8190
Command: "kubectl",
@@ -130,6 +139,7 @@ Hit Control+C to cancel.`, eth, port)
130139
Args: []string{
131140
"server",
132141
"--port=" + fmt.Sprintf("%s", port),
142+
"--token=" + inletsToken,
133143
},
134144
}
135145
serverRes, serverErr := serverTask.Execute()
@@ -146,7 +156,7 @@ Hit Control+C to cancel.`, eth, port)
146156
return nil
147157
}
148158

149-
func makeDeployment(remote, port, upstream, ns string) string {
159+
func makeDeployment(remote, port, upstream, ns, inletsToken string) string {
150160

151161
return fmt.Sprintf(`apiVersion: apps/v1
152162
kind: Deployment
@@ -172,5 +182,6 @@ spec:
172182
- "client"
173183
- "--remote=ws://%s:%s"
174184
- "--upstream=http://%s:%s"
175-
`, upstream, ns, remote, port, upstream, port)
185+
- "--token=%s"
186+
`, upstream, ns, remote, port, upstream, port, inletsToken)
176187
}

0 commit comments

Comments
 (0)