Exemplo n.º 1
0
    def ReadFromDisk(cls, path=None):
        """Reads configuration file and meta-data from default Docker location.

    Reads configuration file and meta-data from default Docker location. Returns
    a Configuration object containing the full contents of the configuration
    file, and the configuration file path.

    Args:
      path: string, path to look for the Docker config file. If empty will
      attempt to read from the new config location (default).

    Returns:
      A Configuration object

    Raises:
      ValueError: path or is_new_format are not set.
      InvalidDockerConfigError: config file could not be read as JSON.
    """
        path = path or client_utils.GetDockerConfigPath(True)[0]
        try:
            content = client_utils.ReadConfigurationFile(path)
        except (ValueError, client_utils.DockerError) as err:
            raise client_utils.InvalidDockerConfigError(
                ('Docker configuration file [{}] could not be read as JSON: {}'
                 ).format(path, str(err)))

        return cls(content, path)
Exemplo n.º 2
0
 def testDockerNotInstalled(self):
     self.StartObjectPatch(
         cred_utils.Configuration, 'ReadFromDisk'
     ).side_effect = client_lib.InvalidDockerConfigError(
         'Could not compare Docker client version:[No such file or directory]'
     )
     with self.assertRaisesRegex(client_lib.DockerError,
                                 'No such file or directory'):
         self.WriteInput('Y\n')
         self.Run('auth configure-docker')