code: func genericResourcesFromGRPC(genericRes []*swarmapi.GenericResource) []swarm.GenericResource {
  	var generic []swarm.GenericResource
  	for _, res := range genericRes {
  		var current swarm.GenericResource
  
  		switch r := res.Resource.(type) {
  		case *swarmapi.GenericResource_DiscreteResourceSpec:
  			current.DiscreteResourceSpec = &swarm.DiscreteGenericResource{
  				Kind:  r.DiscreteResourceSpec.Kind,
  				Value: r.DiscreteResourceSpec.Value,
  			}
  		case *swarmapi.GenericResource_NamedResourceSpec:
  			current.NamedResourceSpec = &swarm.NamedGenericResource{
  				Kind:  r.NamedResourceSpec.Kind,
  				Value: r.NamedResourceSpec.Value,
  			}
  		}
  
  		generic = append(generic, current)
  	}
  
  	return generic
  }
docs: // genericResourcesFromGRPC converts a GRPC GenericResource to a GenericResource