smol lint and polish on zrokEdgeSdk (#112)

This commit is contained in:
Michael Quigley 2022-12-15 11:50:30 -05:00
parent 44da809c94
commit c9a96aa473
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
5 changed files with 14 additions and 15 deletions

View File

@ -32,7 +32,7 @@ func (a *privateResourceAllocator) allocate(envZId, svcToken string, params serv
return "", nil, err
}
if err := zrokEdgeSdk.CreateServiceEdgeRouterPolicyForShare(envZId, svcToken, svcZId, edge); err != nil {
if err := zrokEdgeSdk.CreateShareServiceEdgeRouterPolicy(envZId, svcToken, svcZId, edge); err != nil {
return "", nil, err
}

View File

@ -36,7 +36,7 @@ func (a *publicResourceAllocator) allocate(envZId, svcToken string, frontendZIds
return "", nil, err
}
if err := zrokEdgeSdk.CreateServiceEdgeRouterPolicyForShare(envZId, svcToken, svcZId, edge); err != nil {
if err := zrokEdgeSdk.CreateShareServiceEdgeRouterPolicy(envZId, svcToken, svcZId, edge); err != nil {
return "", nil, err
}

View File

@ -11,7 +11,7 @@ import (
"time"
)
func CreateServiceEdgeRouterPolicyForShare(envZId, svcToken, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error {
func CreateShareServiceEdgeRouterPolicy(envZId, svcToken, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement) error {
serpZId, err := CreateServiceEdgeRouterPolicy(svcToken, svcZId, ZrokServiceTags(svcToken).SubTags, edge)
if err != nil {
return err

View File

@ -11,8 +11,7 @@ import (
)
func CreateShareService(envZId, svcToken, cfgZId string, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) {
cfgZIds := []string{cfgZId}
svcZId, err = CreateService(svcToken, cfgZIds, map[string]interface{}{"zrokServiceToken": svcToken}, edge)
svcZId, err = CreateService(svcToken, []string{cfgZId}, map[string]interface{}{"zrokServiceToken": svcToken}, edge)
if err != nil {
return "", errors.Wrapf(err, "error creating service '%v'", svcToken)
}

View File

@ -12,15 +12,15 @@ import (
)
const (
ServicePolicyDial = 1
ServicePolicyBind = 2
servicePolicyDial = 1
servicePolicyBind = 2
)
func CreateServicePolicyBind(name, svcZId, bindZId string, addlTags map[string]interface{}, edge *rest_management_api_client.ZitiEdgeManagement) error {
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)
}
@ -34,8 +34,8 @@ func CreateServicePolicyDial(name, svcZId string, dialZIds []string, addlTags ma
for _, zId := range dialZIds {
identityRoles = append(identityRoles, "@"+zId)
}
serviceRoles := []string{"@"+svcZId}
spZId, err := createServicePolicy(name, semantic, identityRoles, serviceRoles, addlTags, ServicePolicyDial, edge)
serviceRoles := []string{"@" + svcZId}
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)
}
@ -46,9 +46,9 @@ func CreateServicePolicyDial(name, svcZId string, dialZIds []string, addlTags ma
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:
case servicePolicyBind:
dialBindType = rest_model.DialBindBind
case ServicePolicyDial:
case servicePolicyDial:
dialBindType = rest_model.DialBindDial
default:
return "", errors.Errorf("invalid dial bind type")
@ -79,11 +79,11 @@ func createServicePolicy(name string, semantic rest_model.Semantic, identityRole
}
func DeleteServicePolicyBind(envZId, svcToken string, edge *rest_management_api_client.ZitiEdgeManagement) error {
return DeleteServicePolicy(envZId, fmt.Sprintf("tags.zrokServiceToken=\"%v\" and type=%d", svcToken, ServicePolicyBind), edge)
return DeleteServicePolicy(envZId, fmt.Sprintf("tags.zrokServiceToken=\"%v\" and type=%d", svcToken, servicePolicyBind), edge)
}
func DeleteServicePolicyDial(envZId, svcToken string, edge *rest_management_api_client.ZitiEdgeManagement) error {
return DeleteServicePolicy(envZId, fmt.Sprintf("tags.zrokServiceToken=\"%v\" and type=%d", svcToken, ServicePolicyDial), edge)
return DeleteServicePolicy(envZId, fmt.Sprintf("tags.zrokServiceToken=\"%v\" and type=%d", svcToken, servicePolicyDial), edge)
}
func DeleteServicePolicy(envZId, filter string, edge *rest_management_api_client.ZitiEdgeManagement) error {