INNER CODE UNIT · Python

generate_cache_hash

GoogleCloudPlatform/terraform-python-testing-helper · tftest.py:378

  def generate_cache_hash(self, method_kwargs):
    """Returns a hash value using the instance's attributes and method keyword arguments"""
    params = {
        **{
            k: v for k, v in self.__dict__.items()
            # only uses instance attributes that are involved in the results of
            # the decorated method
            if k in ["binary", "_basedir", "tfdir", "_env"]
        },
        **method_kwargs,
    }

    # creates hash of file contents
    for path_param in ["extra_files", "tf_var_file"]:
      if path_param in method_kwargs:
        if isinstance(method_kwargs[path_param], list):
          params[path_param] = [
              sha1(open(fp, 'rb').read()).hexdigest()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…