(client crclient.Client, ctx context.Context)
| 27 | ) |
| 28 | |
| 29 | func CreateWebhookClusterRole(client crclient.Client, |
| 30 | ctx context.Context) error { |
| 31 | |
| 32 | clusterRole, err := getSpecClusterRole() |
| 33 | if err != nil { |
| 34 | return err |
| 35 | } |
| 36 | |
| 37 | if err := client.Create(ctx, clusterRole); err != nil { |
| 38 | if !apierrors.IsAlreadyExists(err) { |
| 39 | return err |
| 40 | } |
| 41 | existingCfg, err := getExistingClusterRole(ctx, client) |
| 42 | if err != nil { |
| 43 | return err |
| 44 | } |
| 45 | clusterRole.ResourceVersion = existingCfg.ResourceVersion |
| 46 | err = client.Update(ctx, clusterRole) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | log.Info("Updated webhook server cluster role") |
| 51 | } else { |
| 52 | log.Info("Created webhook server cluster role") |
| 53 | } |
| 54 | |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | func getSpecClusterRole() (*v1.ClusterRole, error) { |
| 59 | clusterRole := &v1.ClusterRole{ |
no test coverage detected