code: func GenericResourcesToGRPC(genericRes []types.GenericResource) []*swarmapi.GenericResource {
  	var generic []*swarmapi.GenericResource
  	for _, res := range genericRes {
  		var r *swarmapi.GenericResource
  
  		if res.DiscreteResourceSpec != nil {
  			r = genericresource.NewDiscrete(res.DiscreteResourceSpec.Kind, res.DiscreteResourceSpec.Value)
  		} else if res.NamedResourceSpec != nil {
  			r = genericresource.NewString(res.NamedResourceSpec.Kind, res.NamedResourceSpec.Value)
  		}
  
  		generic = append(generic, r)
  	}
  
  	return generic
  }
docs: // GenericResourcesToGRPC converts a GenericResource to a GRPC GenericResource