def setup_method(self): self.tmp_keys = [] if sys.platform.startswith('linux'): if find_executable('docker-credential-' + DEFAULT_LINUX_STORE): self.store = Store(DEFAULT_LINUX_STORE) elif find_executable('docker-credential-pass'): self.store = Store('pass') else: raise Exception('No supported docker-credential store in PATH') elif sys.platform.startswith('darwin'): self.store = Store(DEFAULT_OSX_STORE)
def get_credential_store_instance(self, registry, dockercfg_path): ''' Return an instance of docker.credentials.Store used by the given registry. :return: A Store or None :rtype: Union[docker.credentials.Store, NoneType] ''' # Older versions of docker-py don't have this feature. try: credstore_env = self.client.credstore_env except AttributeError: credstore_env = None config = auth.load_config(config_path=dockercfg_path) if hasattr(auth, 'get_credential_store'): store_name = auth.get_credential_store(config, registry) elif 'credsStore' in config: store_name = config['credsStore'] else: store_name = None # Make sure that there is a credential helper before trying to instantiate a # Store object. if store_name: self.log("Found credential store %s" % store_name) return Store(store_name, environment=credstore_env) return DockerFileStore(dockercfg_path)