From a77f39e97dd07c7d67a171ecaaa35abbb2c5f44c Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 14 Dec 2022 14:11:50 -0500 Subject: [PATCH] CreateShareService (#112) --- controller/edge.go | 12 ------------ controller/share_private.go | 2 +- controller/share_public.go | 2 +- controller/zrok_edge_sdk/service.go | 12 ++++++++++++ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/controller/edge.go b/controller/edge.go index 73e0efaf..2343024b 100644 --- a/controller/edge.go +++ b/controller/edge.go @@ -10,22 +10,10 @@ import ( rest_model_edge "github.com/openziti/edge/rest_model" sdk_config "github.com/openziti/sdk-golang/ziti/config" "github.com/openziti/sdk-golang/ziti/enroll" - "github.com/pkg/errors" "github.com/sirupsen/logrus" "time" ) -func createShareService(envZId, svcToken, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) { - configs := []string{cfgId} - tags := zrok_edge_sdk.ZrokServiceTags(svcToken) - svcZId, err = zrok_edge_sdk.CreateService(svcToken, configs, tags.SubTags, edge) - if err != nil { - return "", errors.Wrapf(err, "error creating service '%v'", svcToken) - } - logrus.Infof("created zrok service named '%v' (with ziti id '%v') for environment '%v'", svcToken, svcZId, envZId) - return svcZId, nil -} - func createEdgeRouterPolicy(name, zId string, edge *rest_management_api_client.ZitiEdgeManagement) error { edgeRouterRoles := []string{"#all"} identityRoles := []string{fmt.Sprintf("@%v", zId)} diff --git a/controller/share_private.go b/controller/share_private.go index 1c7c891b..40826d30 100644 --- a/controller/share_private.go +++ b/controller/share_private.go @@ -23,7 +23,7 @@ func (a *privateResourceAllocator) allocate(envZId, svcToken string, params serv return "", nil, err } - svcZId, err = createShareService(envZId, svcToken, cfgId, edge) + svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge) if err != nil { return "", nil, err } diff --git a/controller/share_public.go b/controller/share_public.go index c0545f9d..aed58add 100644 --- a/controller/share_public.go +++ b/controller/share_public.go @@ -23,7 +23,7 @@ func (a *publicResourceAllocator) allocate(envZId, svcToken string, frontendZIds return "", nil, err } - svcZId, err = createShareService(envZId, svcToken, cfgId, edge) + svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge) if err != nil { return "", nil, err } diff --git a/controller/zrok_edge_sdk/service.go b/controller/zrok_edge_sdk/service.go index 75922f53..20f70abc 100644 --- a/controller/zrok_edge_sdk/service.go +++ b/controller/zrok_edge_sdk/service.go @@ -5,10 +5,22 @@ import ( "github.com/openziti/edge/rest_management_api_client" edge_service "github.com/openziti/edge/rest_management_api_client/service" "github.com/openziti/edge/rest_model" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "time" ) +func CreateShareService(envZId, svcToken, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) { + configs := []string{cfgId} + tags := ZrokServiceTags(svcToken) + svcZId, err = CreateService(svcToken, configs, tags.SubTags, edge) + if err != nil { + return "", errors.Wrapf(err, "error creating service '%v'", svcToken) + } + logrus.Infof("created zrok service named '%v' (with ziti id '%v') for environment '%v'", svcToken, svcZId, envZId) + return svcZId, nil +} + func CreateService(name string, cfgIds []string, moreTags map[string]interface{}, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) { encryptionRequired := true svc := &rest_model.ServiceCreate{