def __init__(self, creds, subject, repo, push_executable, **kwargs): self._username, self._api_key = common.parse_credential_variable(creds) self._subject = subject self._repo = repo self._push_executable = push_executable for key, value in kwargs.items(): setattr(self, key, value)
def __init__(self, creds, subject, repo, push_executable=None, **kwargs): assert creds, "creds is None!" assert subject, "subject is None!" assert repo, "repo is None!" # creds can be a env varname of value "user:api_key" or just the value try: # get from env var self._username, self._api_key = common.parse_credential_variable( creds) except ValueError as e: # not in env var, parse as user:api-key self._username, self._api_key = creds.split(":") self._api_url = "https://api.bintray.com" self._subject = subject self._repo = repo self.session = requests.Session() basic_auth = "Basic {0}".format( base64.b64encode(":".join([self._username, self._api_key]))) self.session.headers.update({'authorization': basic_auth}) self._push_executable = push_executable for key, value in kwargs.items(): setattr(self, key, value)
def __init__(self, creds, repo, api_url): assert creds, "creds is None!" assert repo, "repo is None!" # creds can be a env varname of value "user:password" or just the value try: # get from env var self.username, self.password = common.parse_credential_variable(creds) except ValueError as e: # not in env var, parse as user:pass self.username, self.password = creds.split(":") self.repo = repo self.api_url = api_url or "https://hub.docker.com/v2" self.token = self.retrieve_token() self.session = requests.Session() self.session.headers.update({'authorization': "JWT %s" % self.token})
def to_string(self): cmd_args = [] if self._use_sudo: if self._sudo_creds is None: raise ValueError("sudo credential missing from commands {0}".format(name)) (username, password) = common.parse_credential_variable(self._sudo_creds) cmd_args += ["echo"] cmd_args += [password] cmd_args += ["|sudo -S"] cmd_args += [self._name] if self._arguments: cmd_args += self._arguments command_str = " ".join(cmd_args) return command_str
def __init__(self, creds, repo, api_url): assert creds, "creds is None!" assert repo, "repo is None!" # creds can be a env varname of value "user:password" or just the value try: # get from env var self.username, self.password = common.parse_credential_variable( creds) except ValueError as e: # not in env var, parse as user:pass self.username, self.password = creds.split(":") self.repo = repo self.api_url = api_url or "https://hub.docker.com/v2" self.token = self.retrieve_token() self.session = requests.Session() self.session.headers.update({'authorization': "JWT %s" % self.token})
def to_string(self): cmd_args = [] if self._use_sudo: if self._sudo_creds is None: raise ValueError( "sudo credential missing from commands {0}".format(name)) (username, password) = common.parse_credential_variable(self._sudo_creds) cmd_args += ["echo"] cmd_args += [password] cmd_args += ["|sudo -S"] cmd_args += [self._name] if self._arguments: cmd_args += self._arguments command_str = " ".join(cmd_args) return command_str
def __init__(self, creds, atlas_url, atlas_name): # This class doesn't use user:pass format creds because # just atlas_token is enough for call atlas API. assert creds, "creds is None!" assert atlas_name, "atlas_name is None!" # creds can be a env varname of value "user:token" or just the value try: # get from env var self.atlas_username, self.atlas_token = common.parse_credential_variable(creds) except ValueError as e: # not in env var, parse as user:api-key self.atlas_username, self.atlas_token = creds.split(":") self.atlas_url = atlas_url or "https://atlas.hashicorp.com/api/v1" self.atlas_name = atlas_name self.box = "/".join(["box", self.atlas_username, self.atlas_name]) self.session = requests.Session() self.session.headers.update({'X-Atlas-Token': self.atlas_token})
def __init__(self, creds, atlas_url, atlas_name): # This class doesn't use user:pass format creds because # just atlas_token is enough for call atlas API. assert creds, "creds is None!" assert atlas_name, "atlas_name is None!" # creds can be a env varname of value "user:token" or just the value try: # get from env var self.atlas_username, self.atlas_token = common.parse_credential_variable( creds) except ValueError as e: # not in env var, parse as user:api-key self.atlas_username, self.atlas_token = creds.split(":") self.atlas_url = atlas_url or "https://atlas.hashicorp.com/api/v1" self.atlas_name = atlas_name self.box = "/".join(["box", self.atlas_username, self.atlas_name]) self.session = requests.Session() self.session.headers.update({'X-Atlas-Token': self.atlas_token})
def __init__(self, creds, subject, repo, push_executable=None, **kwargs): assert creds, "creds is None!" assert subject, "subject is None!" assert repo, "repo is None!" # creds can be a env varname of value "user:api_key" or just the value try: # get from env var self._username, self._api_key = common.parse_credential_variable(creds) except ValueError as e: # not in env var, parse as user:api-key self._username, self._api_key = creds.split(":") self._api_url = "https://api.bintray.com" self._subject = subject self._repo = repo self.session = requests.Session() basic_auth = "Basic {0}".format(base64.b64encode(":".join([self._username, self._api_key]))) self.session.headers.update({'authorization': basic_auth}) self._push_executable = push_executable for key, value in kwargs.items(): setattr(self, key, value)