Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
StrongMonkey committed Mar 30, 2021
1 parent 6eb05f7 commit 864f393
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 1,324 deletions.
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main

import (
"github.com/rancher/tunnelware/pkg/cmd"
_ "github.com/rancher/tunnelware/pkg/generated/controllers/cert-manager.io"
cli "github.com/rancher/wrangler-cli"
_ "github.com/rancher/wrangler/pkg/generated/controllers/networking.k8s.io"
)
Expand Down
21 changes: 0 additions & 21 deletions pkg/apis/certmanager/v1/doc.go

This file was deleted.

42 changes: 0 additions & 42 deletions pkg/apis/certmanager/v1/zz_generated_list_types.go

This file was deleted.

60 changes: 0 additions & 60 deletions pkg/apis/certmanager/v1/zz_generated_register.go

This file was deleted.

24 changes: 0 additions & 24 deletions pkg/apis/certmanager/zz_generated_register.go

This file was deleted.

43 changes: 23 additions & 20 deletions pkg/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/dgrijalva/jwt-go"
"github.com/pkg/browser"
"github.com/pkg/errors"
"github.com/rancher/remotedialer"
"github.com/rancher/tunnelware/pkg/questions"
cli "github.com/rancher/wrangler-cli"
"github.com/rancher/wrangler/pkg/randomtoken"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -88,24 +88,24 @@ func (c *Client) Run(cmd *cobra.Command, args []string) error {
}
}

finished, err := questions.PromptBool("Once you finish github login, enter y to continue", true)
if err != nil {
return err
}
if !finished {
return nil
}
resp, err := http.Get(fmt.Sprintf("https://%s/jwt/%s", serverURL.Host, state))
if err != nil {
return err
}
defer resp.Body.Close()
token, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if err := ioutil.WriteFile(tokenFile, token, 0755); err != nil {
return err
for {
resp, err := http.Get(fmt.Sprintf("https://%s/jwt/%s", serverURL.Host, state))
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode == 503 {
continue
}
token, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if err := ioutil.WriteFile(tokenFile, token, 0755); err != nil {
return err
}
break
}
}

Expand Down Expand Up @@ -142,7 +142,10 @@ func (c *Client) Run(cmd *cobra.Command, args []string) error {
domainWithUsername := fmt.Sprintf("%s.%s", strings.ToLower(claim.Username), domain)
go func() {
fmt.Printf("http://%v --------> %v\nhttps://%v -------> %v\n", domainWithUsername, forwardHost, domainWithUsername, forwardHost)
remotedialer.ClientConnect(cmd.Context(), u.String(), headers, nil, func(string, string) bool { return true }, nil)
for {
remotedialer.ClientConnect(cmd.Context(), u.String(), headers, nil, func(string, string) bool { return true }, nil)
time.Sleep(time.Second * 5)
}
}()
<-cmd.Context().Done()
return nil
Expand Down
6 changes: 5 additions & 1 deletion pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,12 @@ func (h *Handler) jwtToken(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
state := vars["state"]
jwtToken := jwtTokenMap[state]
defer delete(jwtTokenMap, state)
if jwtToken == "" {
rw.WriteHeader(503)
return
}

defer delete(jwtTokenMap, state)
rw.Write([]byte(jwtToken))
rw.WriteHeader(200)
}
13 changes: 0 additions & 13 deletions pkg/codegen/cleanup/main.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/codegen/main.go

This file was deleted.

67 changes: 0 additions & 67 deletions pkg/generated/controllers/cert-manager.io/factory.go

This file was deleted.

43 changes: 0 additions & 43 deletions pkg/generated/controllers/cert-manager.io/interface.go

This file was deleted.

Loading

0 comments on commit 864f393

Please sign in to comment.