Skip to content

Commit

Permalink
Always use auth token
Browse files Browse the repository at this point in the history
For some reason inlets now requires a non-empty auth token to
work.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Nov 29, 2019
1 parent 6649e64 commit 9df2ee7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmd/kfwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,18 @@ func runKfwd(cmd *cobra.Command, _ []string) error {

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

deployment := makeDeployment(eth, port, upstream, ns)
inletsToken, passwordErr := generateAuth()
if passwordErr != nil {
return passwordErr
}

deployment := makeDeployment(eth, port, upstream, ns, inletsToken)
tmpPath := path.Join(os.TempDir(), "inlets-"+upstream+".yaml")
ioutil.WriteFile(tmpPath, []byte(deployment), 0600)
err = ioutil.WriteFile(tmpPath, []byte(deployment), 0600)
if err != nil {
return err
}
fmt.Printf("%s written.\n", tmpPath)

task := v1.ExecTask{
Command: "kubectl",
Expand Down Expand Up @@ -130,6 +139,7 @@ Hit Control+C to cancel.`, eth, port)
Args: []string{
"server",
"--port=" + fmt.Sprintf("%s", port),
"--token=" + inletsToken,
},
}
serverRes, serverErr := serverTask.Execute()
Expand All @@ -146,7 +156,7 @@ Hit Control+C to cancel.`, eth, port)
return nil
}

func makeDeployment(remote, port, upstream, ns string) string {
func makeDeployment(remote, port, upstream, ns, inletsToken string) string {

return fmt.Sprintf(`apiVersion: apps/v1
kind: Deployment
Expand All @@ -172,5 +182,6 @@ spec:
- "client"
- "--remote=ws://%s:%s"
- "--upstream=http://%s:%s"
`, upstream, ns, remote, port, upstream, port)
- "--token=%s"
`, upstream, ns, remote, port, upstream, port, inletsToken)
}

0 comments on commit 9df2ee7

Please sign in to comment.