func (r *ServiceTraitReconciler) renderService(ctx context.Context,
	trait *corev1alpha2.ServiceTrait, obj oam.Object) (*corev1.Service, error) {

	// create a service for the servicetrait
	resources, err := ServiceInjector(ctx, trait, []oam.Object{obj})
	if err != nil {
		return nil, err
	}
	service, ok := resources[1].(*corev1.Service)
	if !ok {
		return nil, fmt.Errorf("internal error, service is not rendered correctly")
	}
	// k8s server-side patch complains if the protocol is not set
	for i := 0; i < len(service.Spec.Ports); i++ {
		service.Spec.Ports[i].Protocol = corev1.ProtocolTCP
	}
	// always set the controller reference so that we can watch this service
	if err := ctrl.SetControllerReference(trait, service, r.Scheme); err != nil {
		return nil, err
	}
	return service, nil
}
// TODO:ServiceTrait can more than create services for the statefulset
// create a service for the statefulset
ServiceTrait can more than create services for the statefulset
create a service for the statefulset
// TODO : ServiceTrait can more than create services for the statefulset // create a service for the statefulset
func (r *ServiceTraitReconciler) renderService(ctx context.Context,
	trait *corev1alpha2.ServiceTrait, obj oam.Object) (*corev1.Service, error) {
	resources, err := ServiceInjector(ctx, trait, []oam.Object{obj})
	if err != nil {
		return nil, err
	}
	service, ok := resources[1].(*corev1.Service)
	if !ok {
		return nil, fmt.Errorf("internal error, service is not rendered correctly")
	}
	for i := 0; i < len(service.Spec.Ports); i++ {
		service.Spec.Ports[i].Protocol = corev1.ProtocolTCP
	}
	if err := ctrl.SetControllerReference(trait, service, r.Scheme); err != nil {
		return nil, err
	}
	return service, nil
}
func ( r * ServiceTraitReconciler ) renderService ( ctx context . Context , trait * corev1alpha2 . ServiceTrait , obj oam . Object ) ( * corev1 . Service , error ) { resources , err := ServiceInjector ( ctx , trait , [ ] oam . Object { obj } ) if err != nil { return nil , err } service , ok := resources [ 1 ] . ( * corev1 . Service ) if ! ok { return nil , fmt . Errorf ( " " ) } for i := 0 ; i < len ( service . Spec . Ports ) ; i ++ { service . Spec . Ports [ i ] . Protocol = corev1 . ProtocolTCP } if err := ctrl . SetControllerReference ( trait , service , r . Scheme ) ; err != nil { return nil , err } return service , nil }
ServiceTrait can more than create services for the statefulset
create a service for the statefulset
ServiceTrait can more than create services for the statefulset create a service for the statefulset
// create a service for the servicetrait // k8s server-side patch complains if the protocol is not set // always set the controller reference so that we can watch this service