Skip to content

Commit

Permalink
Reuse insecure flag for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vapopov committed Oct 25, 2024
1 parent 4edd36a commit 9fe5ed7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion integration/autoupdate/tools/updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
)

func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
ctx, _ = signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)

Expand Down
1 change: 1 addition & 0 deletions integrations/terraform/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ require (
github.com/google/go-tspi v0.3.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/safetext v0.0.0-20240104143208-7a7d9b3d812f // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down
1 change: 0 additions & 1 deletion integrations/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,6 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM=
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
Expand Down
3 changes: 2 additions & 1 deletion lib/autoupdate/tools/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (u *Updater) CheckLocal() (version string, reExec bool, err error) {
// the `webapi/find` handler, which stores information about the required client tools version to
// operate with this cluster. It returns the semantic version that needs updating and whether
// re-execution is necessary, by re-execution flag we understand that update and re-execute is required.
func (u *Updater) CheckRemote(ctx context.Context, proxyAddr string) (version string, reExec bool, err error) {
func (u *Updater) CheckRemote(ctx context.Context, proxyAddr string, insecure bool) (version string, reExec bool, err error) {
// Check if the user has requested a specific version of client tools.
requestedVersion := os.Getenv(teleportToolsVersionEnv)
switch requestedVersion {
Expand Down Expand Up @@ -179,6 +179,7 @@ func (u *Updater) CheckRemote(ctx context.Context, proxyAddr string) (version st
ProxyAddr: proxyAddr,
Pool: certPool,
Timeout: 30 * time.Second,
Insecure: insecure,
})
if err != nil {
return "", false, trace.Wrap(err)
Expand Down
2 changes: 1 addition & 1 deletion lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ func RetryWithRelogin(ctx context.Context, tc *TeleportClient, fn func() error,
return trace.Wrap(err)
}
updater := tools.NewUpdater(tools.DefaultClientTools(), toolsDir, teleport.Version)
toolsVersion, reExec, err := updater.CheckRemote(ctx, tc.WebProxyAddr)
toolsVersion, reExec, err := updater.CheckRemote(ctx, tc.WebProxyAddr, tc.InsecureSkipVerify)
if err != nil {
return trace.Wrap(err)
}
Expand Down
12 changes: 6 additions & 6 deletions tool/tsh/common/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ func onLogin(cf *CLIConf) error {
// The user is not logged in and has typed in `tsh --proxy=... login`, if
// the running binary needs to be updated, update and re-exec.
if profile == nil {
if err := updateAndRun(cf.Context, tc.WebProxyAddr); err != nil {
if err := updateAndRun(cf.Context, tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
return trace.Wrap(err)
}
}
Expand All @@ -1896,7 +1896,7 @@ func onLogin(cf *CLIConf) error {

// The user has typed `tsh login`, if the running binary needs to
// be updated, update and re-exec.
if err := updateAndRun(cf.Context, tc.WebProxyAddr); err != nil {
if err := updateAndRun(cf.Context, tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
return trace.Wrap(err)
}

Expand All @@ -1916,7 +1916,7 @@ func onLogin(cf *CLIConf) error {

// The user has typed `tsh login`, if the running binary needs to
// be updated, update and re-exec.
if err := updateAndRun(cf.Context, tc.WebProxyAddr); err != nil {
if err := updateAndRun(cf.Context, tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
return trace.Wrap(err)
}

Expand Down Expand Up @@ -1992,7 +1992,7 @@ func onLogin(cf *CLIConf) error {
default:
// The user is logged in and has typed in `tsh --proxy=... login`, if
// the running binary needs to be updated, update and re-exec.
if err := updateAndRun(context.Background(), tc.WebProxyAddr); err != nil {
if err := updateAndRun(context.Background(), tc.WebProxyAddr, tc.InsecureSkipVerify); err != nil {
return trace.Wrap(err)
}
}
Expand Down Expand Up @@ -5558,7 +5558,7 @@ const (
"https://goteleport.com/docs/access-controls/guides/headless/#troubleshooting"
)

func updateAndRun(ctx context.Context, proxy string) error {
func updateAndRun(ctx context.Context, proxy string, insecure bool) error {
// The user has typed a command like `tsh ssh ...` without being logged in,
// if the running binary needs to be updated, update and re-exec.
//
Expand All @@ -5570,7 +5570,7 @@ func updateAndRun(ctx context.Context, proxy string) error {
return trace.Wrap(err)
}
updater := tools.NewUpdater(tools.DefaultClientTools(), toolsDir, teleport.Version)
toolsVersion, reExec, err := updater.CheckRemote(ctx, proxy)
toolsVersion, reExec, err := updater.CheckRemote(ctx, proxy, insecure)
if err != nil {
return trace.Wrap(err)
}
Expand Down

0 comments on commit 9fe5ed7

Please sign in to comment.