docs: def handle_build_cache(
          conf: Config, name: str, tag: str, icb: ImageCachingBehavior):
      """Handle Docker image build cache.
  
      Return image ID if image is cached, and there's no need to redo the build.
      Return None if need to build the image (whether cached locally or not).
      Raise RuntimeError if not allowed to build the image because of state of
      local cache.
  
      TODO(itamar): figure out a better name for this function, that reflects
      what it returns (e.g. `get_cached_image_id`),
      without "surprising" the caller with the potential of long
      and non-trivial operations that are not usually expected from functions
      with such names.
      """
      if icb.pull_if_cached or (icb.pull_if_not_cached and
                                get_cached_image_id(icb.remote_image) is None):
          try:
              pull_docker_image(icb.remote_image, conf.docker_pull_cmd)
          except CalledProcessError:
              pass
      local_image = '{}:{}'.format(name, tag)
      if (icb.skip_build_if_cached and
              get_cached_image_id(icb.remote_image) is not None):
          tag_docker_image(icb.remote_image, local_image)
          return get_cached_image_id(local_image)
      if ((not icb.allow_build_if_not_cached) and
              get_cached_image_id(icb.remote_image) is None):
          raise RuntimeError('No cached image for {}'.format(local_image))
      return None