code: func scaleFromReplicaSet(rs *apps.ReplicaSet) (*autoscaling.Scale, error) {
  	selector, err := metav1.LabelSelectorAsSelector(rs.Spec.Selector)
  	if err != nil {
  		return nil, err
  	}
  	return &autoscaling.Scale{
  		// TODO: Create a variant of ObjectMeta type that only contains the fields below.
  		ObjectMeta: metav1.ObjectMeta{
  			Name:              rs.Name,
  			Namespace:         rs.Namespace,
  			UID:               rs.UID,
  			ResourceVersion:   rs.ResourceVersion,
  			CreationTimestamp: rs.CreationTimestamp,
  		},
  		Spec: autoscaling.ScaleSpec{
  			Replicas: rs.Spec.Replicas,
  		},
  		Status: autoscaling.ScaleStatus{
  			Replicas: rs.Status.Replicas,
  			Selector: selector.String(),
  		},
  	}, nil
  }
docs: // scaleFromReplicaSet returns a scale subresource for a replica set.