code: func NodeSpecToGRPC(s types.NodeSpec) (swarmapi.NodeSpec, error) {
  	spec := swarmapi.NodeSpec{
  		Annotations: swarmapi.Annotations{
  			Name:   s.Name,
  			Labels: s.Labels,
  		},
  	}
  	if role, ok := swarmapi.NodeRole_value[strings.ToUpper(string(s.Role))]; ok {
  		spec.DesiredRole = swarmapi.NodeRole(role)
  	} else {
  		return swarmapi.NodeSpec{}, fmt.Errorf("invalid Role: %q", s.Role)
  	}
  
  	if availability, ok := swarmapi.NodeSpec_Availability_value[strings.ToUpper(string(s.Availability))]; ok {
  		spec.Availability = swarmapi.NodeSpec_Availability(availability)
  	} else {
  		return swarmapi.NodeSpec{}, fmt.Errorf("invalid Availability: %q", s.Availability)
  	}
  
  	return spec, nil
  }
docs: // NodeSpecToGRPC converts a NodeSpec to a grpc NodeSpec.