Skip to content

Commit

Permalink
Merge pull request #115 from alfadb/release-0.0.12
Browse files Browse the repository at this point in the history
自动生成.envrc文件,包括KUBERNETES_NAMESPACE环境变量
  • Loading branch information
yunlzheng authored Apr 13, 2020
2 parents 0069dc1 + cb8ca5a commit 6913b9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ node_modules/
note/

.jvmrc
.envrc
.DS_Store
vendor/
7 changes: 7 additions & 0 deletions pkg/kt/command/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ func CleanupWorkspace(options *options.DaemonOptions) {
}
}

if _, err := os.Stat(".envrc"); err == nil {
log.Info().Msgf("- Remove .envrc %s", options.RuntimeOptions.PidFile)
if err = os.Remove(".envrc"); err != nil {
log.Error().Err(err).Msg("delete .envrc failed")
}
}

util.DropHosts(options.ConnectOptions.Hosts)
client, err := cluster.GetKubernetesClient(options.KubeConfig)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/kt/connect/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *Shadow) Outbound(name, podIP string, cidrs []string) (err error) {
log.Info().Msgf("Start SOCKS5 Proxy: export http_proxy=socks5://127.0.0.1:%d", options.ConnectOptions.Socke5Proxy)
log.Info().Msgf("==============================================================")
_ = ioutil.WriteFile(".jvmrc", []byte(fmt.Sprintf("-DsocksProxyHost=127.0.0.1\n-DsocksProxyPort=%d", options.ConnectOptions.Socke5Proxy)), 0644)
_ = ioutil.WriteFile(".envrc", []byte(fmt.Sprintf("KUBERNETES_NAMESPACE=%s", options.Namespace)), 0644)
err = exec.BackgroundRun(ssh.DynamicForwardLocalRequestToRemote("127.0.0.1", options.ConnectOptions.SSHPort, options.ConnectOptions.Socke5Proxy), "vpn(ssh)", options.Debug)
} else {
err = exec.BackgroundRun(sshuttle.SSHUttle("127.0.0.1", options.ConnectOptions.SSHPort, podIP, options.ConnectOptions.DisableDNS, cidrs, options.Debug), "vpn(sshuttle)", options.Debug)
Expand Down

0 comments on commit 6913b9c

Please # to comment.