code: def add_context(
          self,
          name,
          cluster_name=None,
          user_name=None,
          namespace_name=None,
          **attrs
          ):
          
          if self.context_exists(name):
              raise KubeConfError("context with the given name already exists.")
  
          contexts = self.get_contexts()
          
          # Add parameters.
          new_context = {'name': name, 'context':{}}
          
          # Add attributes
          attrs_ = new_context['context']
          if cluster_name is not None:
              attrs_['cluster'] = cluster_name
          if user_name is not None:
              attrs_['user'] = user_name
          if namespace_name is not None:
              attrs_['namespace'] = namespace_name
          attrs_.update(attrs)
  
          contexts.append(new_context)
docs: Add a context to config.