MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / CreateWebhookClusterRole

Function CreateWebhookClusterRole

pkg/webhook/cluster_roles.go:29–56  ·  view source on GitHub ↗
(client crclient.Client,
	ctx context.Context)

Source from the content-addressed store, hash-verified

27)
28
29func 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
58func getSpecClusterRole() (*v1.ClusterRole, error) {
59 clusterRole := &v1.ClusterRole{

Callers 1

setUpWebhookServerRBACFunction · 0.85

Calls 2

getSpecClusterRoleFunction · 0.85
getExistingClusterRoleFunction · 0.85

Tested by

no test coverage detected