further cleanup of sp dial and bind (#112)

This commit is contained in:
Michael Quigley 2022-12-14 17:21:56 -05:00
parent 1c5b030472
commit 44da809c94
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 6 additions and 6 deletions

View File

@ -314,7 +314,7 @@ func assertCtrlMetricsBind(ctrlZId, metricsSvcZId string, edge *rest_management_
} }
if len(listResp.Payload.Data) != 1 { if len(listResp.Payload.Data) != 1 {
logrus.Info("creating 'ctrl-metrics-bind' service policy") 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") 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 { if len(listResp.Payload.Data) != 1 {
logrus.Info("creating 'frontend-metrics-dial' service policy") 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") return errors.Wrap(err, "error creating 'frontend-metrics-dial' service policy")
} }
} }

View File

@ -73,7 +73,7 @@ func (h *createIdentityHandler) Handle(params admin.CreateIdentityParams, princi
svcZId := *listSvcResp.Payload.Data[0].ID svcZId := *listSvcResp.Payload.Data[0].ID
spName := fmt.Sprintf("%v-%v-dial", name, cfg.Metrics.ServiceName) 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) logrus.Errorf("error creating named dial service policy '%v': %v", spName, err)
return admin.NewCreateIdentityInternalServerError() return admin.NewCreateIdentityInternalServerError()
} }

View File

@ -20,7 +20,7 @@ func CreateServicePolicyBind(name, svcZId, bindZId string, addlTags map[string]i
semantic := rest_model.SemanticAllOf semantic := rest_model.SemanticAllOf
identityRoles := []string{"@" + bindZId} identityRoles := []string{"@" + bindZId}
serviceRoles := []string{"@" + svcZId} 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 { if err != nil {
return errors.Wrapf(err, "error creating bind service policy for service '%v' for identity '%v'", svcZId, bindZId) 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) identityRoles = append(identityRoles, "@"+zId)
} }
serviceRoles := []string{"@"+svcZId} 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 { if err != nil {
return errors.Wrapf(err, "error creating dial service policy for service '%v' for identities '%v'", svcZId, dialZIds) 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 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 var dialBindType rest_model.DialBind
switch dialBind { switch dialBind {
case ServicePolicyBind: case ServicePolicyBind: