sshkube 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sshkube
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Access kubernetes clusters over ssh
5
5
  Author: Daniel J. B. Clarke
6
6
  Author-email: u8sand@gmail.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sshkube"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Access kubernetes clusters over ssh"
5
5
  authors = [
6
6
  {name = "Daniel J. B. Clarke",email = "u8sand@gmail.com"}
@@ -25,6 +25,14 @@ dotenv.load_dotenv()
25
25
  workdir = pathlib.Path(os.environ.get('SSHKUBE_CONFIG', '~/.sshkube/')).expanduser()
26
26
  dotenv.load_dotenv(workdir/'.env')
27
27
 
28
+ def Popen(*args, **kwargs):
29
+ ''' Fixup some platform-specific oddities
30
+ '''
31
+ if sys.platform == 'win32':
32
+ if kwargs.get('start_new_session'):
33
+ kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
34
+ return subprocess.Popen(*args, **kwargs)
35
+
28
36
  @click.group()
29
37
  @click.version_option()
30
38
  def cli(): pass
@@ -124,7 +132,7 @@ def _install(*, server, user, use_env, identity_file, verify, verbose):
124
132
 
125
133
  # verify connection
126
134
  try:
127
- subprocess.check_call(make_ssh_cmd(server=server, flags=['-v'] if verbose else [], cmd=['echo', 'Success!']), stdout=sys.stdout, stderr=sys.stderr)
135
+ subprocess.check_call(make_ssh_cmd(server=server, flags=['-v'] if verbose else [], cmd=['echo', 'Success!']), stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
128
136
  except subprocess.CalledProcessError as e:
129
137
  raise click.UsageError('Failed to connect, check all options and any above errors') from e
130
138
 
@@ -171,7 +179,7 @@ def _start_server(*, server, force):
171
179
  k8s_server = kubeconfig_['clusters'][0]['cluster']['server']
172
180
  k8s_server_parsed = urlparse(k8s_server)
173
181
  port = get_free_port()
174
- proc = subprocess.Popen(make_ssh_cmd(server=server, flags=[f"-NL{port}:{k8s_server_parsed.netloc}"]), start_new_session=True)
182
+ proc = Popen(make_ssh_cmd(server=server, flags=[f"-NL{port}:{k8s_server_parsed.netloc}"]), start_new_session=True)
175
183
  try:
176
184
  wait_for_port(port)
177
185
  PidFile(pid=proc.pid, port=port).write()
@@ -193,6 +201,7 @@ def _kill_server():
193
201
  pid = PidFile.read()
194
202
  if pid: pid.kill()
195
203
  (workdir/'kube.config').unlink(missing_ok=True)
204
+ (workdir/'proxy.kube.config').unlink(missing_ok=True)
196
205
 
197
206
  @cli.command()
198
207
  @click.option('-s', '--server', envvar='SSHKUBE_SERVER', type=str, required=True)
@@ -209,10 +218,16 @@ def _init(*, server):
209
218
  pid = PidFile.read()
210
219
  assert pid is not None
211
220
  #
212
- print(
213
- f"export KUBECONFIG={workdir/'proxy.kube.config'}",
214
- sep='\n',
215
- )
221
+ if sys.platform == 'win32':
222
+ print(
223
+ f"set KUBECONFIG={workdir/'proxy.kube.config'}",
224
+ sep='\n',
225
+ )
226
+ else:
227
+ print(
228
+ f"export KUBECONFIG={workdir/'proxy.kube.config'}",
229
+ sep='\n',
230
+ )
216
231
 
217
232
  @cli.command(context_settings=dict(
218
233
  ignore_unknown_options=True,
File without changes
File without changes
File without changes
File without changes