From 44da809c94b775db5fce2b22004af901df616513 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 14 Dec 2022 17:21:56 -0500 Subject: [PATCH] further cleanup of sp dial and bind (#112) --- controller/bootstrap.go | 4 ++-- controller/createIdentity.go | 2 +- controller/zrokEdgeSdk/sp.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/bootstrap.go b/controller/bootstrap.go index 67df5a15..70748555 100644 --- a/controller/bootstrap.go +++ b/controller/bootstrap.go @@ -314,7 +314,7 @@ func assertCtrlMetricsBind(ctrlZId, metricsSvcZId string, edge *rest_management_ } if len(listResp.Payload.Data) != 1 { logrus.Info("creating 'ctrl-metrics-bind' service policy") - if _, err = zrokEdgeSdk.CreateServicePolicy("ctrl-metrics-bind", rest_model.SemanticAllOf, []string{"@"+ctrlZId}, []string{"@"+metricsSvcZId}, nil, zrokEdgeSdk.ServicePolicyBind, edge); err != nil { + if err = zrokEdgeSdk.CreateServicePolicyBind("ctrl-metrics-bind", metricsSvcZId, ctrlZId, nil, edge); err != nil { return errors.Wrap(err, "error creating 'ctrl-metrics-bind' service policy") } } @@ -338,7 +338,7 @@ func assertFrontendMetricsDial(frontendZId, metricsSvcZId string, edge *rest_man } if len(listResp.Payload.Data) != 1 { logrus.Info("creating 'frontend-metrics-dial' service policy") - if _, err = zrokEdgeSdk.CreateServicePolicy("frontend-metrics-dial", rest_model.SemanticAllOf, []string{"@"+frontendZId}, []string{"@"+metricsSvcZId}, nil, zrokEdgeSdk.ServicePolicyDial, edge); err != nil { + if err = zrokEdgeSdk.CreateServicePolicyDial("frontend-metrics-dial", metricsSvcZId, []string{frontendZId}, nil, edge); err != nil { return errors.Wrap(err, "error creating 'frontend-metrics-dial' service policy") } } diff --git a/controller/createIdentity.go b/controller/createIdentity.go index 4589f220..f6b0f863 100644 --- a/controller/createIdentity.go +++ b/controller/createIdentity.go @@ -73,7 +73,7 @@ func (h *createIdentityHandler) Handle(params admin.CreateIdentityParams, princi svcZId := *listSvcResp.Payload.Data[0].ID spName := fmt.Sprintf("%v-%v-dial", name, cfg.Metrics.ServiceName) - if _, err := zrokEdgeSdk.CreateServicePolicy(spName, rest_model_edge.SemanticAllOf, []string{zId}, []string{svcZId}, nil, zrokEdgeSdk.ServicePolicyDial, edge); err != nil { + if err := zrokEdgeSdk.CreateServicePolicyDial(spName, svcZId, []string{zId}, nil, edge); err != nil { logrus.Errorf("error creating named dial service policy '%v': %v", spName, err) return admin.NewCreateIdentityInternalServerError() } diff --git a/controller/zrokEdgeSdk/sp.go b/controller/zrokEdgeSdk/sp.go index 8a28c55c..a7f0ac7e 100644 --- a/controller/zrokEdgeSdk/sp.go +++ b/controller/zrokEdgeSdk/sp.go @@ -20,7 +20,7 @@ func CreateServicePolicyBind(name, svcZId, bindZId string, addlTags map[string]i semantic := rest_model.SemanticAllOf identityRoles := []string{"@" + bindZId} serviceRoles := []string{"@" + svcZId} - spZId, err := CreateServicePolicy(name, semantic, identityRoles, serviceRoles, addlTags, ServicePolicyBind, edge) + spZId, err := createServicePolicy(name, semantic, identityRoles, serviceRoles, addlTags, ServicePolicyBind, edge) if err != nil { return errors.Wrapf(err, "error creating bind service policy for service '%v' for identity '%v'", svcZId, bindZId) } @@ -35,7 +35,7 @@ func CreateServicePolicyDial(name, svcZId string, dialZIds []string, addlTags ma identityRoles = append(identityRoles, "@"+zId) } serviceRoles := []string{"@"+svcZId} - spZId, err := CreateServicePolicy(name, semantic, identityRoles, serviceRoles, addlTags, ServicePolicyDial, edge) + spZId, err := createServicePolicy(name, semantic, identityRoles, serviceRoles, addlTags, ServicePolicyDial, edge) if err != nil { return errors.Wrapf(err, "error creating dial service policy for service '%v' for identities '%v'", svcZId, dialZIds) } @@ -43,7 +43,7 @@ func CreateServicePolicyDial(name, svcZId string, dialZIds []string, addlTags ma return nil } -func CreateServicePolicy(name string, semantic rest_model.Semantic, identityRoles, serviceRoles []string, addlTags map[string]interface{}, dialBind int, edge *rest_management_api_client.ZitiEdgeManagement) (spZId string, err error) { +func createServicePolicy(name string, semantic rest_model.Semantic, identityRoles, serviceRoles []string, addlTags map[string]interface{}, dialBind int, edge *rest_management_api_client.ZitiEdgeManagement) (spZId string, err error) { var dialBindType rest_model.DialBind switch dialBind { case ServicePolicyBind: