(c client.Client, service *corev1.Service)
| 9 | ) |
| 10 | |
| 11 | func CreateOrUpdateService(c client.Client, service *corev1.Service) error { |
| 12 | var newer corev1.Service |
| 13 | if err := c.Get(context.TODO(), client.ObjectKeyFromObject(service), &newer); err != nil { |
| 14 | if apierrors.IsNotFound(err) { |
| 15 | return c.Create(context.TODO(), service) |
| 16 | } |
| 17 | |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | service.ResourceVersion = newer.ResourceVersion |
| 22 | return c.Update(context.TODO(), service) |
| 23 | } |