-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrap command #18
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18 +/- ##
==========================================
- Coverage 88.23% 86.17% -2.07%
==========================================
Files 8 9 +1
Lines 374 470 +96
==========================================
+ Hits 330 405 +75
- Misses 44 65 +21
Continue to review full report at Codecov.
|
My 2 cents: If you want to bootstrap the Linux plugin (as we made internally on GetNinjas), you can use https://github.com/getninjas/unix_ar Our internal CLI is something alike this: SSM_PLUGIN_PATH = {
'darwin': {
'download': 'https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/sessionmanager-bundle.zip',
'bundlepath': 'sessionmanager-bundle/bin/session-manager-plugin',
},
'linux': { # yapf: nolint
'download': 'https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb',
'bundlepath': 'usr/local/sessionmanagerplugin/bin/session-manager-plugin',
}
}
def _extract_from_deb(debfile: 'filelike', targetfile: str) -> 'filelike':
"""Extract `targetfile` from debfile"""
import unix_ar
import tarfile
logger.debug('Extracting from debfile: %s', targetfile)
ar_file = unix_ar.open(debfile)
tarball = ar_file.open('data.tar.gz/') # default interest location on .deb files
tar_file = tarfile.open(fileobj=tarball) # handles gz decompression internally
return tar_file.extractfile(targetfile)
def _extract_from_zip(zipball: 'filelike', targetfile: str) -> 'filelike':
"""Extract `targetfile` from zipball"""
logger.debug('Extracting from zipball: %s', targetfile)
import zipfile
return zipfile.ZipFile(zipball).open(targetfile)
(...)
# download = io.BytesIO()
final_binary = open('session-manager-plugin', 'wb')
if platform == 'darwin':
filelike = _extract_from_zip(download, SSM_PLUGIN_PATH[platform]['bundlepath'])
elif platform == 'linux':
filelike = _extract_from_deb(download, SSM_PLUGIN_PATH[platform]['bundlepath'])
final_binary.write(filelike.read())
final_binary.flush()
os.chmod(final_binary.name, stat.S_IREAD | stat.S_IEXEC) # chmod u+rw |
This PR adds bootstrap command, which allows to download session-manager-plugin and install it, so it doesn't require sudo. Fixes #15.